From 57874e5c540330c8183e19ee87654cf24bb5c250 Mon Sep 17 00:00:00 2001 From: hybcloud <43987901+hybcloud@users.noreply.github.com> Date: Tue, 15 Aug 2023 17:29:24 +1000 Subject: [PATCH] improved PR#4038 by using ash's definition instead (#4044) of hard-coded c_str. --- CHANGELOG.md | 2 ++ wgpu-hal/src/vulkan/instance.rs | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de7f7c7706..1f47fc075b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,8 @@ By @Valaphee in [#3402](https://github.com/gfx-rs/wgpu/pull/3402) - Don't pass `vk::InstanceCreateFlags::ENUMERATE_PORTABILITY_KHR` unless the `VK_KHR_portability_enumeration` extension is available. By @jimblandy in[#4038](https://github.com/gfx-rs/wgpu/pull/4038). +- Enhancement of [#4038], using ash's definition instead of hard-coded c_str. By @hybcloud in[#4044](https://github.com/gfx-rs/wgpu/pull/4044). + #### DX12 - DX12 doesn't support `Features::POLYGON_MODE_POINT``. By @teoxoy in [#4032](https://github.com/gfx-rs/wgpu/pull/4032). diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index adaa4f1c11..4fa4a3e27d 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -228,8 +228,7 @@ impl super::Instance { if cfg!(target_os = "macos") { // VK_EXT_metal_surface extensions.push(ext::MetalSurface::name()); - extensions - .push(CStr::from_bytes_with_nul(b"VK_KHR_portability_enumeration\0").unwrap()); + extensions.push(ash::vk::KhrPortabilityEnumerationFn::name()); } if flags.contains(crate::InstanceFlags::DEBUG) { @@ -589,11 +588,6 @@ impl crate::Instance for super::Instance { let extensions = Self::required_extensions(&entry, driver_api_version, desc.flags)?; - let portability_enumeration_extension = - CStr::from_bytes_with_nul(b"VK_KHR_portability_enumeration\0").unwrap(); - let has_portability_enumeration_extension = - extensions.contains(&portability_enumeration_extension); - let instance_layers = entry.enumerate_instance_layer_properties().map_err(|e| { log::info!("enumerate_instance_layer_properties: {:?}", e); crate::InstanceError @@ -667,7 +661,7 @@ impl crate::Instance for super::Instance { // Avoid VUID-VkInstanceCreateInfo-flags-06559: Only ask the instance to // enumerate incomplete Vulkan implementations (which we need on Mac) if // we managed to find the extension that provides the flag. - if has_portability_enumeration_extension { + if extensions.contains(&ash::vk::KhrPortabilityEnumerationFn::name()) { flags |= vk::InstanceCreateFlags::ENUMERATE_PORTABILITY_KHR; }