summaryrefslogtreecommitdiffstats
path: root/tests/initializer-list/extension-overload-2.slang
blob: 3937127f440f53eec59842b8a118d787b9741ae7 (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
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj

struct Foo
{
    int a;
}

extension Foo
{
    __init(int a)
    {
        this.a = a + 5;
    }
}

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

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain()
{
    // it will prefer the explicit constructor defined in the extension instead of the synthesized one in the struct
    Foo foo = {1.0f};
    //CHECK: BUFFER: 6
    outputBuffer[0] = foo.a;
}