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-mask, 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_5 -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 -shaderobj 7 8//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 9RWStructuredBuffer<int> outputBuffer; 10 11[numthreads(8, 1, 1)] 12void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 13{ 14 const WaveMask mask = 0xff; 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 = WaveMaskSum(mask, v0); 24 float2 r1 = WaveMaskSum(mask, v1); 25 int2 r2 = int2(WaveMaskBitXor(mask, uv0)); 26 int2 r3 = int2(WaveMaskBitOr(mask, uv0)); 27 int2 r4 = int2(WaveMaskBitAnd(mask, uv0)); 28 29 int2 r = r0 + int2(r1) + r2 + r3 + r4; 30 31 outputBuffer[idx] = r.x + r.y; 32}