From 62de7ce2b2360f13f256ff31a6505158d69136d1 Mon Sep 17 00:00:00 2001 From: Vecvec Date: Sat, 30 Mar 2024 10:06:48 +1300 Subject: [PATCH 1/2] fix unused acceleration structures causing invalid SPIR-V --- naga/src/back/spv/writer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index de3220bbda..f6223ce693 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1858,8 +1858,13 @@ impl Writer { .iter() .flat_map(|entry| entry.function.arguments.iter()) .any(|arg| has_view_index_check(ir_module, arg.binding.as_ref(), arg.ty)); - let has_ray_query = ir_module.special_types.ray_desc.is_some() - | ir_module.special_types.ray_intersection.is_some(); + let mut has_ray_query = false; + + for (_, &crate::Type { ref inner, .. }) in ir_module.types.iter() { + if let &crate::TypeInner::AccelerationStructure | &crate::TypeInner::RayQuery = inner { + has_ray_query = true + } + } if self.physical_layout.version < 0x10300 && has_storage_buffers { // enable the storage buffer class on < SPV-1.3 From df5b9e12f3923dc0cf775f39cbda38d78868ade2 Mon Sep 17 00:00:00 2001 From: Vecvec Date: Sun, 31 Mar 2024 16:38:59 +1300 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + naga/src/back/spv/writer.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b98734c5e3..aba1d83d14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,6 +145,7 @@ Bottom level categories: #### Naga - In spv-in, remove unnecessary "gl_PerVertex" name check so unused builtins will always be skipped. By @Imberflur in [#5227](https://github.com/gfx-rs/wgpu/pull/5227). - GLSL 410 does not support layout(binding = ...), enable only for GLSL 420. By @bes in [#5357](https://github.com/gfx-rs/wgpu/pull/5357) +- In spv-out, check for acceleration and ray-query types when enabling ray-query extension to prevent validation error. By @Vecvec in [#5463](https://github.com/gfx-rs/wgpu/pull/5463) #### Tests diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index f6223ce693..e3e2bd57e4 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1858,7 +1858,8 @@ impl Writer { .iter() .flat_map(|entry| entry.function.arguments.iter()) .any(|arg| has_view_index_check(ir_module, arg.binding.as_ref(), arg.ty)); - let mut has_ray_query = false; + let mut has_ray_query = ir_module.special_types.ray_desc.is_some() + | ir_module.special_types.ray_intersection.is_some(); for (_, &crate::Type { ref inner, .. }) in ir_module.types.iter() { if let &crate::TypeInner::AccelerationStructure | &crate::TypeInner::RayQuery = inner {