[clang] [HLSL] Get the index for resource bindings from the slot (PR #117303)

Steven Perron via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 22 06:31:54 PST 2024


================
@@ -588,7 +588,7 @@ llvm::Function *CGHLSLRuntime::createResourceBindingInitFn() {
       auto *Slot = llvm::ConstantInt::get(CGM.IntTy, RBA->getSlotNumber());
       // FIXME: resource arrays are not yet implemented
       auto *Range = llvm::ConstantInt::get(CGM.IntTy, 1);
-      auto *Index = llvm::ConstantInt::get(CGM.IntTy, 0);
+      auto *Index = llvm::ConstantInt::get(CGM.IntTy, RBA->getSlotNumber());
----------------
s-perron wrote:

This is not the way I implemented this for SPIR-V. This assumes the `Slot` and `Index` as interwined, which they are in DXIL, but not in SPIR-V.

In SPIR-V, the `Slot` is the binding number, and all elements of the resource array are accessed through the same binding number. The element does not get their own binding number. The binding and index are independent.

Would it be possible to keep this as is, and have the DXIL backend add the slot number to the index?

https://github.com/llvm/llvm-project/pull/117303


More information about the cfe-commits mailing list