yum-mirror/slang

Making it easier to work with shaders

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

Yong HeUse two-stage parsing to disambiguate generic app and comparison. (#6281)7911c9437

master
1.4 KiB49 linesraw
1//TEST:SIMPLE(filecheck=CHECK1):-target spirv -DERROR1
2//TEST:SIMPLE(filecheck=CHECK2):-target spirv -DERROR2
3extern static const int constValue = 1;
4
5struct RWTex<T : __BuiltinRealType, let N : uint>
6{
7#ifdef ERROR2
8    // expect error: cannot define static member with unsized type.
9    // CHECK2:([[# @LINE+1]]): error 30071
10    static [[vk::binding(0, 0)]] vector<T,N> rwtable[];
11#else
12    static [[vk::binding(0, 0)]] vector<T,N> rwtable[4];
13#endif
14    static vector<T, N> get(uint image_index) { return rwtable[image_index]; }
15}    
16
17struct Push
18{
19    uint image_id;
20};
21[[vk::push_constant]] Push p;
22RWStructuredBuffer<float3> output;
23[shader("compute")]
24[numthreads(8, 8, 1)]
25void main(uint3 pixel_i : SV_DispatchThreadID)
26{
27    output[0] =
28#ifdef ERROR1
29        // expect error: trying to specialize RWTex, which has two arguments, with only one argument.
30        // CHECK1-DAG:([[# @LINE+1]]): error 30075
31        RWTex<float3>::get(p.image_id);
32#else
33        RWTex<float, 3>::get(p.image_id);
34#endif
35    //CHECK1-DAG:([[# @LINE+1]]): error 30071
36    static float sa1[];
37
38    //CHECK1-DAG:([[# @LINE+1]]): error 30071
39    float sa2[];
40
41    //CHECK1-NOT:([[# @LINE+1]]): error
42    static float sa3[] = { 1, 2, 3 }; // should be ok.
43
44    //CHECK1-NOT:([[# @LINE+1]]): error
45    float sa4[] = { 1, 2, 3 }; // should be ok.
46
47    //CHECK1-NOT:([[# @LINE+1]]): error
48    float sa5[constValue]; // should be ok.
49}