summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/extensions/extension-method-simple.slang
blob: d3162c053cd4a7dafaf1b6521d391ef62e161f72 (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
// interface-extension.slang

// Test that an `extension` applied to an interface type works as users expect

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

struct MyType
{
    int v;
}

extension MyType
{
    int foo()
    {
        return v;
    }
}

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

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    MyType t;
    t.v = 1;
    // CHECK: 1
    outputBuffer[dispatchThreadID.x] = t.foo();
}