Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spv-out] decorate non-uniform image/sampler access chains #4766

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions naga/src/back/spv/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions naga/tests/out/spv/binding-arrays.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading