From cf8d1ceffcfbbb64734e6180a2c0cebd033f5b2e Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:16:28 -0400 Subject: Implementing `tbuffer` layout(s) (#4436) * Implementing `tbuffer` layouts. 1. Add to layout options 'TextureBuffer' layouts. 2. Add on to existing logic a way to allocate appropriate registers for TextureBufferType (this was made to work with parameter block logic). 3. Added asserts so objects missing a layout will gracefully crash This means `tbuffer` now works for hlsl,glsl,metal targets, spirv has yet to implement logic for `TextureBufferType`. * disable metal tests and fix emitting code a bit fixing the emitting code means metal compilation emits a useful error (help point users/developers to #4435) * fix warning --- tests/hlsl/tbuffer.slang | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/hlsl/tbuffer.slang (limited to 'tests/hlsl/tbuffer.slang') diff --git a/tests/hlsl/tbuffer.slang b/tests/hlsl/tbuffer.slang new file mode 100644 index 000000000..a1bebf2e1 --- /dev/null +++ b/tests/hlsl/tbuffer.slang @@ -0,0 +1,40 @@ +//TEST:SIMPLE(filecheck=HLSL): -target hlsl -stage compute -entry computeMain +//TEST:SIMPLE(filecheck=GLSL): -target glsl -stage compute -entry computeMain + +// Metal backend requires a new legalization pass to support emitting `TextureBufferType` +//DISABLE_TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain + +// SPIRV backend has no support for emitting `TextureBufferType` +//DISABLE_TEST:SIMPLE(filecheck=SPIRV): -target spirv -stage compute -entry computeMain + +tbuffer tbuf : register(t0) +{ + float4 tb_val1; +} + +tbuffer tbuf2 : register(t1) +{ + Texture2D texture2D; + float4 tb_val2; +} + + +// HLSL-DAG: t0 +// HLSL-DAG: t1 +// HLSL-DAG: t2 + +// GLSL-DAG: binding = 0 +// GLSL-DAG: binding = 1 +// GLSL-DAG: binding = 2 + +// METAL-DAG: [texture(0)] +// METAL-DAG: [texture(1)] +// METAL-DAG: [texture(2)] +// METALLIB: @computeMain + +RWStructuredBuffer outputBuffer; +[numthreads(1,1,1)] +float4 computeMain() { + outputBuffer[0] = tb_val1 + texture2D[0] + tb_val2; +} -- cgit v1.2.3