yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Anders LeinoRefresh of disabled WGPU tests (#5614)93f5d13fc

master
1.5 KiB38 linesraw
1// atomics-buffer.slang
2
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
5// Doesn't work on VK - GLSL output doesn't replace InterlockedAdd.  
6//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -shaderobj
7// Cannot work on CUDA, as outputBuffer becomes a CUsurfObject - which do not appear to have atomics available.
8// If the buffer was a StructuredBuffer this would work on CUDA.
9//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj
10// Atomics not available on CPU currently
11//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj
12// RWBuffer does not work with the GFX backend as expected with Metal
13//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
14//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
15// Not supported in WGSL: Use of traditional atomics intrinsics (InterlockedXXX functions)
16//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu
17
18//METALLIB: @computeMain
19
20//TEST_INPUT:ubuffer(format=R_UInt32, data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]):out,name outputBuffer
21
22RWBuffer<uint> outputBuffer;
23
24void test(uint val)
25{
26    uint originalValue;
27
28	InterlockedAdd(outputBuffer[val], 		val, 		originalValue);
29	InterlockedAdd(outputBuffer[val ^ 1], 	val*16, 	originalValue);
30	InterlockedAdd(outputBuffer[val ^ 2], 	val*16*16, 	originalValue);
31}
32
33[numthreads(4, 1, 1)]
34void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
35{
36    uint tid = dispatchThreadID.x;
37    test(tid);
38}