summaryrefslogtreecommitdiff
path: root/tests/wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wgsl')
-rw-r--r--tests/wgsl/uniform-array-2.slang23
-rw-r--r--tests/wgsl/uniform-array.slang21
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/wgsl/uniform-array-2.slang b/tests/wgsl/uniform-array-2.slang
new file mode 100644
index 000000000..10cf39990
--- /dev/null
+++ b/tests/wgsl/uniform-array-2.slang
@@ -0,0 +1,23 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -wgpu -output-using-type
+
+struct Params{
+ int2 data[2];
+ int scalarData[2];
+}
+
+//TEST_INPUT:set params = cbuffer(data=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15])
+ConstantBuffer<Params> params;
+
+//TEST_INPUT:set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<float> outputBuffer;
+
+float helper(float2 v)
+{return v.y;}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // CHECK: 17
+ outputBuffer[0] = helper(params.data[1]) + params.scalarData[1];
+}
+
diff --git a/tests/wgsl/uniform-array.slang b/tests/wgsl/uniform-array.slang
new file mode 100644
index 000000000..5956f6755
--- /dev/null
+++ b/tests/wgsl/uniform-array.slang
@@ -0,0 +1,21 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -wgpu -output-using-type
+
+struct MyPoint { int x; int y; int type; }
+
+struct Params{
+ MyPoint data[2];
+}
+
+//TEST_INPUT:set params = cbuffer(data=[0 1 2 3 4 5 6 7 8 9 10 11])
+ConstantBuffer<Params> params;
+
+//TEST_INPUT:set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // CHECK: 5
+ outputBuffer[0] = params.data[1].y;
+}
+