yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
1.5 KiB45 linesraw
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//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 -shaderobj
6// Disabled because vk doesn't currently support matrix types. See wave-shuffle-vk.slang
7//DISABLE_TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
8//TEST:COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
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    const WaveMask mask = 0xf;
17    
18    int idx = int(dispatchThreadID.x);
19    
20    int value = 0;
21    
22    // Scalar
23    
24    value += WaveMaskShuffle(mask, idx, (idx + 1) & 3);
25    
26    // vector
27    
28    {
29        float2 v = float2(idx + 1, idx + 2);
30        float2 readValue = WaveMaskShuffle(mask, v, (idx - 1) & 3);
31        
32        value += int(readValue[0] + readValue[1]);
33    }
34        
35    // matrix
36    {
37        matrix<int, 2, 2> v = matrix<int, 2, 2>(idx, idx - 1, idx * 3, idx - 2);
38        
39        matrix<int, 2, 2> readValue = WaveMaskShuffle(mask, v, (idx - 1) & 3);
40        
41        value += int(readValue[0][0] + readValue[0][1] + readValue[1][0] + readValue[1][1]);
42    }
43    
44    outputBuffer[idx] = value;
45}