summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/cast-zero-to-struct.slang36
-rw-r--r--tests/compute/cast-zero-to-struct.slang.expected.txt4
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/compute/cast-zero-to-struct.slang b/tests/compute/cast-zero-to-struct.slang
new file mode 100644
index 000000000..c2ed8fb6d
--- /dev/null
+++ b/tests/compute/cast-zero-to-struct.slang
@@ -0,0 +1,36 @@
+// cast-zero-to-struct.slang
+
+// Test that HLSL legacy syntax for casting from literal zero
+// to a `struct` type works.
+
+//TEST(compute):COMPARE_COMPUTE:
+
+struct S
+{
+ int2 a;
+ int2 b;
+ int2 c;
+}
+
+int test(int val)
+{
+ S s = (S) 0;
+
+ s.a.x = val;
+ s.b.y = val;
+ s.c.x = val;
+
+ int2 t = s.a + s.b*256 + s.c*65536;
+ return t.x + t.y*16;
+}
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<int> gOutputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 tid : SV_DispatchThreadID)
+{
+ int inVal = tid.x;
+ int outVal = test(inVal);
+ gOutputBuffer[tid.x] = outVal;
+}
diff --git a/tests/compute/cast-zero-to-struct.slang.expected.txt b/tests/compute/cast-zero-to-struct.slang.expected.txt
new file mode 100644
index 000000000..7e1d6b7b7
--- /dev/null
+++ b/tests/compute/cast-zero-to-struct.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+11001
+22002
+33003 \ No newline at end of file