summaryrefslogtreecommitdiff
path: root/tests/compute/struct-default-init.slang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compute/struct-default-init.slang')
-rw-r--r--tests/compute/struct-default-init.slang40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/compute/struct-default-init.slang b/tests/compute/struct-default-init.slang
new file mode 100644
index 000000000..9638465b0
--- /dev/null
+++ b/tests/compute/struct-default-init.slang
@@ -0,0 +1,40 @@
+// struct-default-init.slang
+//TEST(compute):COMPARE_COMPUTE:
+
+struct Test
+{
+ int a;
+ int b = 1;
+ int c;
+ int d = 1 + 1;
+}
+
+int test(int inVal)
+{
+ Test myArray[4] = {
+ { 3, 4, 5, 6 },
+ { 7, 8, 9, },
+ { 10, 11 },
+ { 12, }
+ };
+
+ Test t = myArray[inVal];
+ return t.a * 4096
+ + t.b * 256
+ + t.c * 16
+ + t.d;
+}
+
+//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ int inVal = int(tid);
+ int outVal = test(inVal);
+
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file