yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST_CATEGORY(wave, compute) 2//DISABLE_TEST:COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 3//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -shaderobj 4//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj -render-feature hardware-device 5//TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -render-feature hardware-device 6//TEST:COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0 -shaderobj 7//TEST:COMPARE_COMPUTE_EX:-wgpu -compute -shaderobj 8//TEST:COMPARE_COMPUTE_EX:-metal -compute -shaderobj 9 10//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 11RWStructuredBuffer<int> outputBuffer; 12 13[numthreads(8, 1, 1)] 14void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 15{ 16 const int idx = int(dispatchThreadID.x); 17 18 int2 v0 = int2(idx + 1, idx + 2); 19 float2 v1 = float2(idx + 2, idx + 3); 20 // NOTE! dxc only supports bit ops on uint and associated types NOT int 21 uint2 uv0 = v0; 22 23 int2 r0 = WaveActiveSum(v0); 24 float2 r1 = WaveActiveSum(v1); 25 int2 r2 = int2(WaveActiveBitXor(uv0)); 26 int2 r3 = int2(WaveActiveBitOr(uv0)); 27 int2 r4 = int2(WaveActiveBitAnd(uv0)); 28 29 int2 r = r0 + int2(r1) + r2 + r3 + r4; 30 31 outputBuffer[idx] = r.x + r.y; 32}