diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 84f8581521..6c96fa09e3 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1463,7 +1463,7 @@ impl<'w> BlockContext<'w> { // but we expect these checks to almost always succeed, and keeping branches to a // minimum is essential. let mut accumulated_checks = None; - // Is true if we are accessing into a binding array of buffers with a non-uniform index. + // Is true if we are accessing into a binding array with a non-uniform index. let mut is_non_uniform_binding_array = false; self.temp_list.clear(); @@ -1473,20 +1473,14 @@ impl<'w> BlockContext<'w> { if let crate::Expression::GlobalVariable(var_handle) = self.ir_function.expressions[base] { - let gvar: &crate::GlobalVariable = - &self.ir_module.global_variables[var_handle]; - match gvar.space { - crate::AddressSpace::Storage { .. } | crate::AddressSpace::Uniform => { - if let crate::TypeInner::BindingArray { .. } = - self.ir_module.types[gvar.ty].inner - { - is_non_uniform_binding_array = self.fun_info[index] - .uniformity - .non_uniform_result - .is_some(); - } - } - _ => {} + // The access chain needs to be decorated as NonUniform + // see VUID-RuntimeSpirv-NonUniform-06274 + let gvar = &self.ir_module.global_variables[var_handle]; + if let crate::TypeInner::BindingArray { .. } = + self.ir_module.types[gvar.ty].inner + { + is_non_uniform_binding_array = + self.fun_info[index].uniformity.non_uniform_result.is_some(); } } @@ -1571,7 +1565,7 @@ impl<'w> BlockContext<'w> { (pointer_id, expr_pointer) }; // Subsequent load, store and atomic operations require the pointer to be decorated as NonUniform - // if the buffer binding array was accessed with a non-uniform index + // if the binding array was accessed with a non-uniform index // see VUID-RuntimeSpirv-NonUniform-06274 if is_non_uniform_binding_array { self.writer diff --git a/naga/tests/out/spv/binding-arrays.spvasm b/naga/tests/out/spv/binding-arrays.spvasm index 3d3b9f8e57..143ee269af 100644 --- a/naga/tests/out/spv/binding-arrays.spvasm +++ b/naga/tests/out/spv/binding-arrays.spvasm @@ -35,27 +35,49 @@ OpMemberDecorate %43 0 Offset 0 OpDecorate %47 Location 0 OpDecorate %47 Flat OpDecorate %50 Location 0 +OpDecorate %90 NonUniform OpDecorate %91 NonUniform +OpDecorate %113 NonUniform OpDecorate %114 NonUniform +OpDecorate %115 NonUniform OpDecorate %116 NonUniform +OpDecorate %140 NonUniform OpDecorate %141 NonUniform +OpDecorate %142 NonUniform OpDecorate %143 NonUniform +OpDecorate %179 NonUniform OpDecorate %180 NonUniform +OpDecorate %207 NonUniform OpDecorate %208 NonUniform +OpDecorate %223 NonUniform OpDecorate %224 NonUniform +OpDecorate %239 NonUniform OpDecorate %240 NonUniform +OpDecorate %260 NonUniform OpDecorate %261 NonUniform +OpDecorate %262 NonUniform OpDecorate %263 NonUniform +OpDecorate %284 NonUniform OpDecorate %285 NonUniform +OpDecorate %286 NonUniform OpDecorate %287 NonUniform +OpDecorate %308 NonUniform OpDecorate %309 NonUniform +OpDecorate %310 NonUniform OpDecorate %311 NonUniform +OpDecorate %332 NonUniform OpDecorate %333 NonUniform +OpDecorate %334 NonUniform OpDecorate %335 NonUniform +OpDecorate %356 NonUniform OpDecorate %357 NonUniform +OpDecorate %358 NonUniform OpDecorate %359 NonUniform +OpDecorate %380 NonUniform OpDecorate %381 NonUniform +OpDecorate %382 NonUniform OpDecorate %383 NonUniform +OpDecorate %405 NonUniform OpDecorate %406 NonUniform %2 = OpTypeVoid %3 = OpTypeInt 32 0