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.6 KiB48 linesraw
1// This is similar to wave-lane-at.slang but tests more limited supported types for vk.
2// We have this 'simple' test, because we can't do matrix (or imat) operations on GLSL/Vk target
3
4//TEST_CATEGORY(wave-mask, compute)
5//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj -render-feature hardware-device
6//TEST:COMPARE_COMPUTE_EX:-cuda -compute -profile cs_6_0 -shaderobj -render-feature hardware-device
7//TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
8
9//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
10RWStructuredBuffer<int> outputBuffer;
11
12// `The input lane index must be uniform across the wave.`. 
13// The same restriction applies to glsl/SPIR-V 1.5
14// So we are going to use the input buffer to achieve this.
15
16//TEST_INPUT:ubuffer(data=[1 2 3 0], stride=4):name inputBuffer
17RWStructuredBuffer<int> inputBuffer;
18
19[numthreads(4, 1, 1)]
20void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
21{
22    WaveMask mask = 0xf;
23  
24    int idx = int(dispatchThreadID.x);
25    
26    int value = 0;
27    
28    for (int i = 0; i < 4; ++i)
29    {
30        // Scalar
31        
32        // The landId is 'dynamic' but it also uniform across the wave (as required by spec)
33        const int laneId = inputBuffer[i];
34        
35        value += WaveMaskReadLaneAt(mask, idx, laneId);
36        
37        // vector
38        
39        {
40            float2 v = float2(idx + 1, idx + 2);
41            float2 readValue = WaveMaskReadLaneAt(mask, v, (laneId + 1) & 3);
42            
43            value += int(readValue[0] + readValue[1]);
44        }            
45    }
46   
47    outputBuffer[idx] = value;
48}