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