summaryrefslogtreecommitdiff
path: root/tests/bugs/interface-type-self-ref.slang
blob: 9c823ffa52dccfea60858ed6d10223bea01b6409 (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
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;

interface IFoo
{
    int compute(out IFoo param);
}

struct Impl : IFoo
{
    int compute(out IFoo param)
    {
        param = this;
        return 0;
    }
}

int f(IFoo p)
{
    IFoo r;
    return p.compute(r);
}

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
    int index = dispatchThreadID.x;
    Impl impl;
    outputBuffer[index] = f(impl);
}