diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/groupshared.slang | 39 | ||||
| -rw-r--r-- | tests/compute/groupshared.slang.expected.txt | 4 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/compute/groupshared.slang b/tests/compute/groupshared.slang new file mode 100644 index 000000000..e471e6148 --- /dev/null +++ b/tests/compute/groupshared.slang @@ -0,0 +1,39 @@ +// groupshared.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +#define THREAD_COUNT 4 + +groupshared int gA[THREAD_COUNT]; +int test(int val) +{ + gA[val] = val; + GroupMemoryBarrierWithGroupSync(); + val = gA[val ^ 1]; + +/* TODO: once function-scope `static` works + static groupshared int gB[THREAD_COUNT]; + + gB[val] = val; + GroupMemoryBarrierWithGroupSync(); + val = gB[val ^ 2]; +*/ + + return val; +} + +RWStructuredBuffer<int> gBuffer; + +[numthreads(THREAD_COUNT, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int val = int(tid); + val = test(val); + gBuffer[tid] = val; +}
\ No newline at end of file diff --git a/tests/compute/groupshared.slang.expected.txt b/tests/compute/groupshared.slang.expected.txt new file mode 100644 index 000000000..8a5d99f5b --- /dev/null +++ b/tests/compute/groupshared.slang.expected.txt @@ -0,0 +1,4 @@ +1 +0 +3 +2 |
