summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/array-of-struct-with-parameterblock.slang
blob: 07ca3a50f722bddad696bd5a339fda4fc1d5bcda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Test that arrays of structs containing ParameterBlocks are properly diagnosed
// with error 30027 instead of causing a compiler crash

//TEST:SIMPLE(filecheck=CHECK): -target spirv

// A struct that contains a ParameterBlock member
struct MyStruct
{
    ParameterBlock<IMyInterface> pb;
    int data;
}

interface IMyInterface
{
    int getValue();
}

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain()
{
    // CHECK: ([[# @LINE+1]]): error 30027:
    MyStruct arr[2];
    
    // Also test with dynamic arrays
    // CHECK: ([[# @LINE+1]]): error 30027: 
    MyStruct dynamicArr[];
}

// Test nested structs as well
struct OuterStruct
{
    MyStruct inner;
    float value;
}

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain2()
{
    // Nested struct containing ParameterBlock should also trigger the error
    // CHECK: ([[# @LINE+1]]): error 30027:
    OuterStruct nestedArr[3];
}