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//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj 3//TEST:COMPARE_COMPUTE_EX:-slang -compute -cuda -profile cs_6_0 -shaderobj 4//TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 5//TEST:COMPARE_COMPUTE_EX:-wgpu -compute -shaderobj 6//TEST:COMPARE_COMPUTE_EX:-metal -compute -shaderobj 7 8//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 9RWStructuredBuffer<int> outputBuffer; 10 11[numthreads(4, 1, 1)] 12void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 13{ 14 int idx = int(dispatchThreadID.x); 15 16 int value = 0; 17 18 // Scalar 19 20 value += WaveBroadcastLaneAt(idx, 1); 21 22 // vector 23 24 { 25 float2 v = float2(idx + 1, idx + 2); 26 float2 readValue = WaveBroadcastLaneAt(v, 4 & 3); 27 28 value += int(readValue[0] + readValue[1]); 29 } 30 31 outputBuffer[idx] = value; 32}