summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/structuredbuffer-resource-struct-recursive-mutual.slang
blob: ac94499651c9ff05ff628537c0443f81f2cd5b63 (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
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv

struct MutualB
{
    //CHECK-DAG: ([[# @LINE+1]]): error 38205
    StructuredBuffer<MutualA> aBuffer;
}

struct MutualA
{
    //CHECK-DAG: ([[# @LINE+1]]): error 38205
    StructuredBuffer<MutualB> bBuffer;
}

StructuredBuffer<MutualA> mutualRoot;
RWStructuredBuffer<float> output;

// External function to force consumption of recursive types
float consumeMutual(MutualA a, MutualB b);

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint i = dispatchThreadID.x;

    float result = 0;
    // Force usage of mutual recursion
    MutualA a = mutualRoot[i];
    MutualB b = a.bBuffer[0];
    result += consumeMutual(a, b);

    output[i] = result;
}