summaryrefslogtreecommitdiff
path: root/tests/compute
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/enum.slang66
-rw-r--r--tests/compute/enum.slang.expected.txt4
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/compute/enum.slang b/tests/compute/enum.slang
new file mode 100644
index 000000000..2619d8eb5
--- /dev/null
+++ b/tests/compute/enum.slang
@@ -0,0 +1,66 @@
+// enum.slang
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+
+// Confirm that basic `enum` declarations are supported.
+
+enum Color
+{
+ Red,
+ Green = 2,
+ Blue,
+}
+
+
+int test(int val)
+{
+ Color c = Color.Red;
+
+ if(val > 1)
+ {
+ c = Color.Green;
+ }
+
+ if(c == Color.Red)
+ {
+ if(val & 1)
+ {
+ c = Color.Blue;
+ }
+ }
+
+ switch(c)
+ {
+ case Color.Red:
+ val = 1;
+ break;
+
+ case Color.Green:
+ val = 2;
+ break;
+
+ case Color.Blue:
+ val = 3;
+ break;
+
+ default:
+ val = -1;
+ break;
+ }
+
+ return (val << 4) + int(c);
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ int val = int(tid);
+ val = test(val);
+
+ outputBuffer[tid] = val;
+} \ No newline at end of file
diff --git a/tests/compute/enum.slang.expected.txt b/tests/compute/enum.slang.expected.txt
new file mode 100644
index 000000000..946476280
--- /dev/null
+++ b/tests/compute/enum.slang.expected.txt
@@ -0,0 +1,4 @@
+10
+33
+22
+22