yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
93f5d13fc
master
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 2//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj 3//TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl 4// Not supported in WGSL: Use of traditional atomics intrinsics (InterlockedXXX functions) 5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu 6 7//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer 8RWStructuredBuffer<int> outputBuffer; 9 10groupshared uint gs_values[2]; 11 12[shader("compute")] 13[numthreads(4, 1, 1)] 14void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 15{ 16 int index = (int)dispatchThreadID.x; 17 18 // Initialize first 19 if (index < 2) 20 { 21 gs_values[index] = 2; 22 } 23 24 GroupMemoryBarrierWithGroupSync(); 25 26 // NOTE! We have to cast to uint, to make atomic work 27 InterlockedAdd(gs_values[index & 1], uint(index * index)); 28 29 outputBuffer[index] = gs_values[index & 1]; 30}