added raw_loaded_extensions() to Instance to allow querying of all extensions, not just known ones. (#1255)

This commit is contained in:
Austin Johnson 2019-10-27 17:47:10 -05:00 committed by GitHub
parent e5d6c2cb1a
commit 08d635c977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -11,6 +11,8 @@
- Update Winit to 0.20.0 - Update Winit to 0.20.0
- Update dependencies: lazy_static, half, syn, quote & proc-macro2 - Update dependencies: lazy_static, half, syn, quote & proc-macro2
- Swapchain can now be recreated with dimensions of corresponding surface using `recreate()`. - Swapchain can now be recreated with dimensions of corresponding surface using `recreate()`.
- Added `raw_loaded_extensions()` to `Instance` to allow querying of all extensions, not just known ones.
- **Breaking Change** `loaded_extensions()` on `Instance` no longer returns a reference.
- Add support for GLSL macro defines to the `shader!` macro. - Add support for GLSL macro defines to the `shader!` macro.
- Switch to Vulkan 1.1 and inherently SpirV 1.3 (shaderc default version for vulkan 1.1) - Switch to Vulkan 1.1 and inherently SpirV 1.3 (shaderc default version for vulkan 1.1)

View File

@ -95,7 +95,7 @@ pub struct Instance {
//alloc: Option<Box<Alloc + Send + Sync>>, //alloc: Option<Box<Alloc + Send + Sync>>,
physical_devices: Vec<PhysicalDeviceInfos>, physical_devices: Vec<PhysicalDeviceInfos>,
vk: vk::InstancePointers, vk: vk::InstancePointers,
extensions: InstanceExtensions, extensions: RawInstanceExtensions,
layers: SmallVec<[CString; 16]>, layers: SmallVec<[CString; 16]>,
function_pointers: OwnedOrRef<FunctionPointers<Box<dyn Loader + Send + Sync>>>, function_pointers: OwnedOrRef<FunctionPointers<Box<dyn Loader + Send + Sync>>>,
} }
@ -283,12 +283,11 @@ impl Instance {
devices devices
}; };
// TODO: should be Into let vk_khr_get_physical_device_properties2 = CString::new(b"VK_KHR_get_physical_device_properties2".to_vec()).unwrap();
let extensions: InstanceExtensions = (&extensions).into();
// Getting the properties of all physical devices. // Getting the properties of all physical devices.
// If possible, we use VK_KHR_get_physical_device_properties2. // If possible, we use VK_KHR_get_physical_device_properties2.
let physical_devices = if extensions.khr_get_physical_device_properties2 { let physical_devices = if extensions.iter().any(|v| *v == vk_khr_get_physical_device_properties2) {
Instance::init_physical_devices2(&vk, physical_devices, &extensions) Instance::init_physical_devices2(&vk, physical_devices, &extensions)
} else { } else {
Instance::init_physical_devices(&vk, physical_devices) Instance::init_physical_devices(&vk, physical_devices)
@ -354,7 +353,7 @@ impl Instance {
/// TODO: Query extension-specific physical device properties, once a new instance extension is supported. /// TODO: Query extension-specific physical device properties, once a new instance extension is supported.
fn init_physical_devices2(vk: &vk::InstancePointers, fn init_physical_devices2(vk: &vk::InstancePointers,
physical_devices: Vec<vk::PhysicalDevice>, physical_devices: Vec<vk::PhysicalDevice>,
extensions: &InstanceExtensions) extensions: &RawInstanceExtensions)
-> Vec<PhysicalDeviceInfos> { -> Vec<PhysicalDeviceInfos> {
let mut output = Vec::with_capacity(physical_devices.len()); let mut output = Vec::with_capacity(physical_devices.len());
@ -450,10 +449,15 @@ impl Instance {
/// ///
/// let extensions = InstanceExtensions::supported_by_core().unwrap(); /// let extensions = InstanceExtensions::supported_by_core().unwrap();
/// let instance = Instance::new(None, &extensions, None).unwrap(); /// let instance = Instance::new(None, &extensions, None).unwrap();
/// assert_eq!(instance.loaded_extensions(), &extensions); /// assert_eq!(instance.loaded_extensions(), extensions);
/// ``` /// ```
#[inline] #[inline]
pub fn loaded_extensions(&self) -> &InstanceExtensions { pub fn loaded_extensions(&self) -> InstanceExtensions {
InstanceExtensions::from(&self.extensions)
}
#[inline]
pub fn raw_loaded_extensions(&self) -> &RawInstanceExtensions {
&self.extensions &self.extensions
} }