diff options
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/comma-operator.slang | 35 | ||||
| -rw-r--r-- | tests/compute/comma-operator.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/comma-operator.slang.glsl | 24 |
3 files changed, 63 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 diff --git a/tests/compute/comma-operator.slang.expected.txt b/tests/compute/comma-operator.slang.expected.txt new file mode 100644 index 000000000..9b4237ab1 --- /dev/null +++ b/tests/compute/comma-operator.slang.expected.txt @@ -0,0 +1,4 @@ +1 +3 +5 +7 diff --git a/tests/compute/comma-operator.slang.glsl b/tests/compute/comma-operator.slang.glsl new file mode 100644 index 000000000..3107f5773 --- /dev/null +++ b/tests/compute/comma-operator.slang.glsl @@ -0,0 +1,24 @@ +// comma-operator.slang.glsl +#version 450 + +//TEST_IGNORE_FILE: + +layout(std430, binding = 0) +buffer _S1 { + int _data[]; +} outputBuffer_0; + +int test_0(int inVal_0) +{ + return inVal_0 * 2 + 1; +} + +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;void main() +{ + uint tid_0 = gl_GlobalInvocationID.x; + + int outVal_0 = test_0(outputBuffer_0._data[tid_0]); + + outputBuffer_0._data[tid_0] = outVal_0; + return; +} |
