From fb44993b38dd98261f20e718c3e282634902b391 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 15 Oct 2019 15:19:46 -0400 Subject: GetDimension on GLSL for StructuredBuffer (#1081) * Fix GetDimensions for glsl. * Add test for Load on RWStructuredBuffer as part of GetDimension. --- tests/cross-compile/get-dimensions.slang | 59 ++++++++++++++++++++++ .../get-dimensions.slang.expected.txt | 8 +++ 2 files changed, 67 insertions(+) create mode 100644 tests/cross-compile/get-dimensions.slang create mode 100644 tests/cross-compile/get-dimensions.slang.expected.txt (limited to 'tests') diff --git a/tests/cross-compile/get-dimensions.slang b/tests/cross-compile/get-dimensions.slang new file mode 100644 index 000000000..eaa9b0cca --- /dev/null +++ b/tests/cross-compile/get-dimensions.slang @@ -0,0 +1,59 @@ +//DISABLE_TEST:REFLECTION: -profile cs_5_0 -entry computeMain -target cpp +//TEST(compute):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute +//TEST(compute):COMPARE_COMPUTE_EX:-d3d11 -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute + +struct Thing +{ + int a; + float b; +}; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):dxbinding(0),glbinding(0),out,name outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[7 2 9 53], stride=4):dxbinding(1),glbinding(1),name buffer0 +RWStructuredBuffer buffer0; + +//TEST_INPUT:ubuffer(data=[23 2], stride=4):dxbinding(2),glbinding(2),name buffer1 +RWStructuredBuffer buffer1; + +//TEST_INPUT:ubuffer(data=[-10 17 9 4 2 0], stride=4):dxbinding(3),glbinding(3),name buffer2 +RWStructuredBuffer buffer2; + +//TEST_INPUT:ubuffer(data=[1 0 3 0 7 0], stride=8):dxbinding(4),glbinding(4),name buffer3 +RWStructuredBuffer buffer3; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = int(dispatchThreadID.x); + int last = -1; + + uint count, stride; + if (index == 0) + { + buffer0.GetDimensions(count, stride); + last = buffer0.Load(count - 1); + } + else if (index == 1) + { + buffer1.GetDimensions(count, stride); + last = buffer1[count - 1]; + } + else if (index == 2) + { + buffer2.GetDimensions(count, stride); + last = int(buffer2.Load(count -1)); + } + else + { + buffer3.GetDimensions(count, stride); + + last = buffer3.Load(count - 1).a; + } + + outputBuffer[index * 2] = int(count); + outputBuffer[index * 2 + 1] = last; +} \ No newline at end of file diff --git a/tests/cross-compile/get-dimensions.slang.expected.txt b/tests/cross-compile/get-dimensions.slang.expected.txt new file mode 100644 index 000000000..b90b9551c --- /dev/null +++ b/tests/cross-compile/get-dimensions.slang.expected.txt @@ -0,0 +1,8 @@ +4 +35 +2 +2 +6 +0 +3 +7 -- cgit v1.2.3