diff options
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/atomic-coerce.slang | 27 | ||||
| -rw-r--r-- | tests/bugs/atomic-coerce.slang.expected.txt | 4 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/bugs/atomic-coerce.slang b/tests/bugs/atomic-coerce.slang new file mode 100644 index 000000000..1e56a8d25 --- /dev/null +++ b/tests/bugs/atomic-coerce.slang @@ -0,0 +1,27 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +groupshared uint gs_values[2]; + +[shader("compute")] +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = (int)dispatchThreadID.x; + + // Initialize first + if (index < 2) + { + gs_values[index] = 2; + } + + GroupMemoryBarrierWithGroupSync(); + + // NOTE! We have to cast to uint, to make atomic work + InterlockedAdd(gs_values[index & 1], uint(index * index)); + + outputBuffer[index] = gs_values[index & 1]; +} diff --git a/tests/bugs/atomic-coerce.slang.expected.txt b/tests/bugs/atomic-coerce.slang.expected.txt new file mode 100644 index 000000000..9f774a3a1 --- /dev/null +++ b/tests/bugs/atomic-coerce.slang.expected.txt @@ -0,0 +1,4 @@ +6 +C +6 +C |
