yum-mirror/slang

Making it easier to work with shaders

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

Ellie HermaszewskaFix segfault on arrays of structs containing parameter blocks (#8555)96df31a9f

master
909 B44 linesraw
1// Test that arrays of structs containing ParameterBlocks are properly diagnosed
2// with error 30027 instead of causing a compiler crash
3
4//TEST:SIMPLE(filecheck=CHECK): -target spirv
5
6// A struct that contains a ParameterBlock member
7struct MyStruct
8{
9    ParameterBlock<IMyInterface> pb;
10    int data;
11}
12
13interface IMyInterface
14{
15    int getValue();
16}
17
18[shader("compute")]
19[numthreads(1, 1, 1)]
20void computeMain()
21{
22    // CHECK: ([[# @LINE+1]]): error 30027:
23    MyStruct arr[2];
24    
25    // Also test with dynamic arrays
26    // CHECK: ([[# @LINE+1]]): error 30027: 
27    MyStruct dynamicArr[];
28}
29
30// Test nested structs as well
31struct OuterStruct
32{
33    MyStruct inner;
34    float value;
35}
36
37[shader("compute")]
38[numthreads(1, 1, 1)]
39void computeMain2()
40{
41    // Nested struct containing ParameterBlock should also trigger the error
42    // CHECK: ([[# @LINE+1]]): error 30027:
43    OuterStruct nestedArr[3];
44}