diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/paren-insertion-bug.slang | 34 | ||||
| -rw-r--r-- | tests/bugs/paren-insertion-bug.slang.expected.txt | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/bugs/paren-insertion-bug.slang b/tests/bugs/paren-insertion-bug.slang new file mode 100644 index 000000000..608f8a9dd --- /dev/null +++ b/tests/bugs/paren-insertion-bug.slang @@ -0,0 +1,34 @@ +// paren-insertion-bug.slang + +// Confirm that precedence is correctly handled +// for cast from scalar to vector. + +//TEST(compute):COMPARE_COMPUTE: + +int test(float a) +{ + // This line performs a cast from a scalar result to a vector + float3 b = pow(a, 2.0); + + // If the computation of `b` above gets folded into this + // line of code (and we expect it to) we need to correctly + // parenthesize the generated cast so that the `.xyz` swizzle + // applies to the result of the cast, rather than the input. + // + return int(float4(b.xyz * 2.0, 1.0).x); +} + + +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<uint> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + uint inVal = tid; + uint outVal = test(inVal); + + outputBuffer[tid] = outVal; +} diff --git a/tests/bugs/paren-insertion-bug.slang.expected.txt b/tests/bugs/paren-insertion-bug.slang.expected.txt new file mode 100644 index 000000000..51033ef27 --- /dev/null +++ b/tests/bugs/paren-insertion-bug.slang.expected.txt @@ -0,0 +1,4 @@ +0 +2 +8 +12 |
