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_0 -shaderobj 5// Disabled on VK because glsl can't do WaveReadLaneAt on matrix. 6//DISABLE_TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 7//TEST:COMPARE_COMPUTE_EX:-cuda -compute -shaderobj 8 9//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 10RWStructuredBuffer<int> outputBuffer; 11 12[numthreads(4, 1, 1)] 13void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 14{ 15 int idx = int(dispatchThreadID.x); 16 17 const WaveMask mask = 0xf; 18 19 int value = 0; 20 21 // Scalar 22 23 value += WaveMaskBroadcastLaneAt(mask, idx, 1); 24 25 // vector 26 27 { 28 float2 v = float2(idx + 1, idx + 2); 29 float2 readValue = WaveMaskBroadcastLaneAt(mask, v, 2); 30 31 value += int(readValue[0] + readValue[1]); 32 } 33 34 // matrix 35 { 36 matrix<int, 2, 2> v = matrix<int, 2, 2>(idx, idx - 1, idx * 3, idx - 2); 37 38 matrix<int, 2, 2> readValue = WaveMaskBroadcastLaneAt(mask, v, 3); 39 40 value += int(readValue[0][0] + readValue[0][1] + readValue[1][0] + readValue[1][1]); 41 } 42 43 outputBuffer[idx] = value; 44}