yum-mirror/slang

Making it easier to work with shaders

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

Anders LeinoEnable a bunch of WGPU tests (#5513)43df1da01

master
694 B34 linesraw
1// legalize-struct-init.slang
2
3//TEST(compute):COMPARE_COMPUTE: -shaderobj
4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
5//TEST_INPUT:ubuffer(data=[4 3 2 1], stride=4):name inputBuffer
6
7
8RWStructuredBuffer<uint> outputBuffer;
9RWStructuredBuffer<uint> inputBuffer;
10
11struct Helper
12{
13    RWStructuredBuffer<uint> o;
14    RWStructuredBuffer<uint> i;
15    uint                    t;  
16};
17
18void test(Helper h)
19{
20    h.o[h.t] = h.i[h.t] * 16 + h.t;    
21}
22
23void test(uint t)
24{
25    Helper h = { outputBuffer, inputBuffer, t };
26    test(h);
27}
28
29[numthreads(4, 1, 1)]
30void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
31{
32    uint tid = dispatchThreadID.x;
33    test(tid);
34}