From f00aa0f20a8b181ce1598c67c69359da72f3e185 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Mon, 1 Aug 2022 17:21:39 -0500 Subject: [PATCH] vulkan: fix issues querying multiview support --- CHANGELOG.md | 4 ++++ wgpu-hal/src/vulkan/adapter.rs | 27 +++++++++------------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df77e009c9..d8333c2b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -102,6 +102,10 @@ the same every time it is rendered, we now warn if it is missing. - `DownlevelCapabilities::default()` now returns the `ANISOTROPIC_FILTERING` flag set to true so DX12 lists `ANISOTROPIC_FILTERING` as true again by @cwfitzgerald in [#2851](https://github.com/gfx-rs/wgpu/pull/2851) - Properly query format features for UAV/SRV usages of depth formats by @cwfitzgerald in [#2856](https://github.com/gfx-rs/wgpu/pull/2856) +#### Vulkan +- Vulkan 1.0 drivers that support `VK_KHR_multiview` now properly report the `MULTIVIEW` feature as supported by @i509VCB in [#2934](https://github.com/gfx-rs/wgpu/pull/2934). +- Stop using `VkPhysicalDevice11Features` in Vulkan 1.1 which is confusingly provided in Vulkan 1.2 by @i509VCB in [#2934](https://github.com/gfx-rs/wgpu/pull/2934). + #### GLES - Fix depth stencil texture format capability by @jinleili in [#2854](https://github.com/gfx-rs/wgpu/pull/2854) - `get_texture_format_features` now only returns usages for formats it actually supports by @cwfitzgerald in [#2856](https://github.com/gfx-rs/wgpu/pull/2856) diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index b2a0058ca6..ca086f2f2f 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -15,7 +15,6 @@ fn indexing_features() -> wgt::Features { #[derive(Debug, Default)] pub struct PhysicalDeviceFeatures { core: vk::PhysicalDeviceFeatures, - vulkan_1_1: Option, pub(super) vulkan_1_2: Option, pub(super) descriptor_indexing: Option, imageless_framebuffer: Option, @@ -177,15 +176,6 @@ impl PhysicalDeviceFeatures { //.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY)) .geometry_shader(requested_features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX)) .build(), - vulkan_1_1: if api_version >= vk::API_VERSION_1_1 { - Some( - vk::PhysicalDeviceVulkan11Features::builder() - .multiview(requested_features.contains(wgt::Features::MULTIVIEW)) - .build(), - ) - } else { - None - }, vulkan_1_2: if api_version >= vk::API_VERSION_1_2 { Some( vk::PhysicalDeviceVulkan12Features::builder() @@ -316,7 +306,9 @@ impl PhysicalDeviceFeatures { } else { None }, - multiview: if enabled_extensions.contains(&vk::KhrMultiviewFn::name()) { + multiview: if api_version >= vk::API_VERSION_1_1 + || enabled_extensions.contains(&vk::KhrMultiviewFn::name()) + { Some( vk::PhysicalDeviceMultiviewFeatures::builder() .multiview(requested_features.contains(wgt::Features::MULTIVIEW)) @@ -451,10 +443,6 @@ impl PhysicalDeviceFeatures { let intel_windows = caps.properties.vendor_id == db::intel::VENDOR && cfg!(windows); - if let Some(ref vulkan_1_1) = self.vulkan_1_1 { - features.set(F::MULTIVIEW, vulkan_1_1.multiview != 0); - } - if let Some(ref vulkan_1_2) = self.vulkan_1_2 { const STORAGE: F = F::STORAGE_RESOURCE_BINDING_ARRAY; if Self::all_features_supported( @@ -891,10 +879,13 @@ impl super::InstanceShared { let core = vk::PhysicalDeviceFeatures::default(); let mut builder = vk::PhysicalDeviceFeatures2KHR::builder().features(core); - if capabilities.properties.api_version >= vk::API_VERSION_1_1 { + // `VK_KHR_multiview` is promoted to 1.1 + if capabilities.properties.api_version >= vk::API_VERSION_1_1 + || capabilities.supports_extension(vk::KhrMultiviewFn::name()) + { let next = features - .vulkan_1_1 - .insert(vk::PhysicalDeviceVulkan11Features::default()); + .multiview + .insert(vk::PhysicalDeviceMultiviewFeatures::default()); builder = builder.push_next(next); }