logo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2016 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.

use crate::device::physical::PhysicalDevice;
pub use crate::extensions::{
    ExtensionRestriction, ExtensionRestrictionError, OneOfRequirements, SupportedExtensionsError,
};
use crate::instance::InstanceExtensions;
use crate::Version;
use std::ffi::{CStr, CString};
use std::fmt::Formatter;

// Generated by build.rs
include!(concat!(env!("OUT_DIR"), "/device_extensions.rs"));

impl DeviceExtensions {
    /// See the docs of supported_by_device().
    #[deprecated(
        since = "0.25",
        note = "Use PhysicalDevice::supported_extensions instead"
    )]
    pub fn supported_by_device_raw(
        physical_device: PhysicalDevice,
    ) -> Result<Self, SupportedExtensionsError> {
        Ok(*physical_device.supported_extensions())
    }

    /// Returns a `DeviceExtensions` object with extensions supported by the `PhysicalDevice`.
    #[deprecated(
        since = "0.25",
        note = "Use PhysicalDevice::supported_extensions instead"
    )]
    pub fn supported_by_device(physical_device: PhysicalDevice) -> Self {
        *physical_device.supported_extensions()
    }
}

#[cfg(test)]
mod tests {
    use crate::device::DeviceExtensions;
    use std::ffi::CString;

    #[test]
    fn empty_extensions() {
        let d: Vec<CString> = (&DeviceExtensions::none()).into();
        assert!(d.iter().next().is_none());
    }
}