summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-15 15:19:46 -0400
committerGitHub <noreply@github.com>2019-10-15 15:19:46 -0400
commitfb44993b38dd98261f20e718c3e282634902b391 (patch)
tree3483d51b1c804fc5988183f62c7e45e80d840c8e /tests
parent2420f47b56647d33e5dbb6730718905a767c7244 (diff)
GetDimension on GLSL for StructuredBuffer (#1081)
* Fix GetDimensions for glsl. * Add test for Load on RWStructuredBuffer as part of GetDimension.
Diffstat (limited to 'tests')
-rw-r--r--tests/cross-compile/get-dimensions.slang59
-rw-r--r--tests/cross-compile/get-dimensions.slang.expected.txt8
2 files changed, 67 insertions, 0 deletions
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<int> outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[7 2 9 53], stride=4):dxbinding(1),glbinding(1),name buffer0
+RWStructuredBuffer<int> buffer0;
+
+//TEST_INPUT:ubuffer(data=[23 2], stride=4):dxbinding(2),glbinding(2),name buffer1
+RWStructuredBuffer<int> buffer1;
+
+//TEST_INPUT:ubuffer(data=[-10 17 9 4 2 0], stride=4):dxbinding(3),glbinding(3),name buffer2
+RWStructuredBuffer<float> buffer2;
+
+//TEST_INPUT:ubuffer(data=[1 0 3 0 7 0], stride=8):dxbinding(4),glbinding(4),name buffer3
+RWStructuredBuffer<Thing> 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