From bf69c7275e2a1a8545efb8842b662bd4bd213f02 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Fri, 23 Oct 2026 18:30:39 +0200 Subject: [PATCH 1/2] Support bindless Call SetDescriptorHeaps to support bindless HLSL. --- src/backend/dx12.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/dx12.rs b/src/backend/dx12.rs index 3b9f864..90742a1 100644 --- a/src/backend/dx12.rs +++ b/src/backend/dx12.rs @@ -2425,6 +2425,9 @@ impl Backend for Dx12Backend { }, } + if let Some(heap) = &self.descriptor_heap { + cmds.SetDescriptorHeaps(&[Some(heap.clone())]); + } cmds.SetComputeRootSignature(root_sig.or(pipe_root_sig).map(|r| &self.root_sigs[&r])); if let Some(heap) = self.descriptor_heap.clone() { cmds.SetDescriptorHeaps(&[Some(heap)]); From 3edca4a2eac305302bd724539114ab1f8bbecb5e Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Sat, 31 Oct 2026 12:36:27 +0100 Subject: [PATCH 2/2] Add example --- examples/AddTwoBindless.sm | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 examples/AddTwoBindless.sm diff --git a/examples/AddTwoBindless.sm b/examples/AddTwoBindless.sm new file mode 100644 index 0000000..2c87bc7 --- /dev/null +++ b/examples/AddTwoBindless.sm @@ -0,0 +1,59 @@ +# Copyright (c) Advanced Micro Devices, Inc., or its affiliates. +# +# SPDX-License-Identifier: MIT OR Apache-2.0 + +# Create a HLSL source called csshader +SOURCE csshader + +[numthreads(32, 1, 1)] +void CSMain(uint3 DTid : SV_DispatchThreadID) +{ + ByteAddressBuffer inbuf0 = ResourceDescriptorHeap[0]; + ByteAddressBuffer inbuf1 = ResourceDescriptorHeap[1]; + RWByteAddressBuffer outbuf = ResourceDescriptorHeap[2]; + + // Take 2 numbers from first buffer, one from second, and sum them + unsigned int first_idx = DTid.x * 2; + float first = inbuf0.Load(first_idx * 4) + inbuf0.Load((first_idx + 1) * 4); + float sum = first + inbuf1.Load(DTid.x * 4); + outbuf.Store(DTid.x * 4, sum); +} +END + +# Compile the source with dxc into a binary called csobj +OBJECT csobj csshader cs_6_6 CSMain + +# Allocate buffers in GPU memory for input and output +BUFFER inbuf DATA_TYPE float SIZE 64 SERIES_FROM 0 INC_BY .25 +BUFFER inbuf2 DATA_TYPE float SIZE 32 SERIES_FROM 10.0 INC_BY .25 +BUFFER outbuf DATA_TYPE float SIZE 32 FILL 0 + +# The root signature +ROOT default + TABLE UAV REGISTER 0 NUMBER 1 SPACE 0 + TABLE SRV REGISTER 0 NUMBER 2 SPACE 0 + CONFIG cbv_srv_uav_heap_directly_indexed +END + +# Create a compute pipeline called cspipe +PIPELINE cspipe COMPUTE + ATTACH csobj + ROOT default +END + +# Create views that point to the complete buffers +# The descriptor heap with these views is bound, so they are accessed as 0, 1 and 2 +VIEW inview inbuf AS SRV +VIEW inview2 inbuf2 AS SRV +VIEW outview outbuf AS UAV + +# Run the pipeline in a 1x1x1 dispatch +DISPATCH cspipe +RUN 1 1 1 + +# Check that the shaders worked as expected +EXPECT outbuf float OFFSET 0 EQ 10.25 11.5 12.75 14 +EXPECT outbuf float OFFSET 64 EQ 30.25 31.5 32.75 34 + +# Use DUMP to see a buffer's content +#DUMP outbuf float