summaryrefslogtreecommitdiff
path: root/tests/language-feature/interfaces/zero-init-interface.slang
blob: ee38f4d83e0213222eab1178b086e0c6f0f7de48 (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
// Test that we can zero-init a struct with interface typed member.

//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER): -shaderobj

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

interface IFoo
{
    int method();
}

//TEST_INPUT: type_conformance Impl1:IFoo = 0
struct Impl1 : IFoo
{
    int data;
    int method() { return data + 1; }
}

struct MyType
{
    IFoo foo;
}


[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
{
    MyType t = {};
    // BUFFER: 1
    outputBuffer[0] = t.foo.method();
}