summaryrefslogtreecommitdiff
path: root/tests/compute/comma-operator.slang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compute/comma-operator.slang')
-rw-r--r--tests/compute/comma-operator.slang35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/compute/comma-operator.slang b/tests/compute/comma-operator.slang
new file mode 100644
index 000000000..1036482ef
--- /dev/null
+++ b/tests/compute/comma-operator.slang
@@ -0,0 +1,35 @@
+// comma-operator.slang
+
+//TEST(compute):COMPARE_COMPUTE:-cpu
+//TEST(compute):COMPARE_COMPUTE:
+
+// Test that the "comma operator" behaves as expected
+
+// We will also include a cross-compilation test just to
+// confirm that the generated SPIR-V (and by extension DXIL/DXBC)
+// doesn't include a subroutine defintion/call for `operator,`
+
+//TEST:CROSS_COMPILE:-target spirv-assembly -entry computeMain -stage compute
+
+int test(int inVal)
+{
+ int a = inVal;
+
+ // We expect the left operand to `operator,` to be
+ // evaluated before the right operand, and for the
+ // result to be the value of the right operand
+ //
+ return a*=2, a+1;
+}
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = outputBuffer[tid];
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file