yum-mirror/slang

Making it easier to work with shaders

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

ArielG-NVInit expressions for struct fields support, #3738 (#3907)d5d39dda2

master
837 B45 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain
2RWStructuredBuffer<int> outputBuffer;
3
4//CHECK: error 30851
5
6struct DefaultStructNoInit
7{
8    int data0 = 2;
9    int data1 = 2;
10
11};
12extension DefaultStructNoInit
13{
14}
15
16struct DefaultStructWithInit
17{
18    int data0;
19    int data1 = 3;
20    int data2;
21};
22extension DefaultStructWithInit
23{
24    __init()
25    {
26        data0 = 3;
27        data2 = 3;
28    }
29}
30
31[numthreads(1, 1, 1)]
32void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
33{
34    DefaultStructNoInit noInit = DefaultStructNoInit();
35    DefaultStructWithInit withInit = DefaultStructWithInit();
36    // BUF: 1
37    outputBuffer[0] = true
38        && noInit.data0 == 2
39        && noInit.data1 == 2
40
41        && withInit.data0 == 3
42        && withInit.data1 == 3
43        && withInit.data2 == 3
44        ;
45}