[llvm] [SPIR-V] Add capability for non-uniform indexing for `StructuredBuffer` types. (PR #163424)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 16 08:41:12 PDT 2025
================
@@ -1200,6 +1200,18 @@ void addOpAccessChainReqs(const MachineInstr &Instr,
return;
}
+ bool IsNonUniform =
+ hasNonUniformDecoration(Instr.getOperand(0).getReg(), MRI);
+ if (StorageClass == SPIRV::StorageClass::StorageClass::StorageBuffer) {
+ if (IsNonUniform)
+ Handler.addRequirements(
+ SPIRV::Capability::StorageBufferArrayNonUniformIndexingEXT);
+ else
+ Handler.addRequirements(
+ SPIRV::Capability::StorageBufferArrayDynamicIndexing);
+ return;
+ }
----------------
s-perron wrote:
I'm wondering if this it too general. I think I did it wrong for the resources below as well.
What will happen in this case https://godbolt.org/z/r9MWcqxr5? I don't think it needs the dynamic indexing capability because the `3`, which in an integral constant, determines which storage buffer will be accessed. `index` is not relevant because that is indexing within a particular storage buffer. This needs to be fixed for the other resource types too.
This becomes more difficult for for storage buffers because the access chain could have multiple indices in one access change. You need to find the one that indexes into the array of storage buffers.
https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-StandaloneSpirv-StorageBufferArrayDynamicIndexing-10129
https://github.com/llvm/llvm-project/pull/163424
More information about the llvm-commits
mailing list