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 3//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute 4//Disabled on D3D, because in general WaveShuffle requires hardware that doesn't have the 'uniform laneId across Wave' restriction. 5//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 6// Disabled because vk doesn't currently support matrix types. See wave-shuffle-vk.slang 7//DISABLE_TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute 8TEST:COMPARE_COMPUTE_EX:-cuda -compute -render-features cuda_sm_7_0 9 10//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 11RWStructuredBuffer<int> outputBuffer; 12 13[numthreads(4, 1, 1)] 14void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 15{ 16 int idx = int(dispatchThreadID.x); 17 18 int value = 0; 19 20 // Scalar 21 22 value += WaveShuffle(idx, (idx + 1) & 3); 23 24 // vector 25 26 { 27 float2 v = float2(idx + 1, idx + 2); 28 float2 readValue = WaveShuffle(v, (idx - 1) & 3); 29 30 value += int(readValue[0] + readValue[1]); 31 } 32 33 // matrix 34 { 35 matrix<int, 2, 2> v = matrix<int, 2, 2>(idx, idx - 1, idx * 3, idx - 2); 36 37 matrix<int, 2, 2> readValue = WaveShuffle(v, (idx - 1) & 3); 38 39 value += int(readValue[0][0] + readValue[0][1] + readValue[1][0] + readValue[1][1]); 40 } 41 42 outputBuffer[idx] = value; 43}