From 0836b13bb1b6fd9160653f427dc6298588f6c510 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Mon, 2 Oct 2023 21:25:33 +0200 Subject: [PATCH 1/2] [vulkan] set spir-v capabilities based on downlevel flags --- wgpu-hal/src/vulkan/adapter.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index b515628726..768d8411e3 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1223,6 +1223,8 @@ impl super::Adapter { let naga_options = { use naga::back::spv; + // The following capabilities are always available + // see https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap51.html#spirvenv-capabilities let mut capabilities = vec![ spv::Capability::Shader, spv::Capability::Matrix, @@ -1230,15 +1232,23 @@ impl super::Adapter { spv::Capability::Image1D, spv::Capability::ImageQuery, spv::Capability::DerivativeControl, - spv::Capability::SampledCubeArray, - spv::Capability::SampleRateShading, - //Note: this is requested always, no matter what the actual - // adapter supports. It's not the responsibility of SPV-out - // translation to handle the storage support for formats. spv::Capability::StorageImageExtendedFormats, - //TODO: fill out the rest ]; + if self + .downlevel_flags + .contains(wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES) + { + capabilities.push(spv::Capability::SampledCubeArray); + } + + if self + .downlevel_flags + .contains(wgt::DownlevelFlags::MULTISAMPLED_SHADING) + { + capabilities.push(spv::Capability::SampleRateShading); + } + if features.contains(wgt::Features::MULTIVIEW) { capabilities.push(spv::Capability::MultiView); } From 9a95e5103062e369c6ca273ab8b395b07d894dcc Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Tue, 3 Oct 2023 14:57:44 +0200 Subject: [PATCH 2/2] fix link --- wgpu-hal/src/vulkan/adapter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 768d8411e3..2986777029 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1224,7 +1224,7 @@ impl super::Adapter { use naga::back::spv; // The following capabilities are always available - // see https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap51.html#spirvenv-capabilities + // see https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap52.html#spirvenv-capabilities let mut capabilities = vec![ spv::Capability::Shader, spv::Capability::Matrix,