summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/extensions/this-in-extension.slang
blob: f9cc31fca0e5831cf6409347aacd8b9185734e30 (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
35
36
37
38
39
// this-in-extension.slang

// Test that an `This` type works correctly when there is an extension.

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

interface IFoo
{
    static const This identity;
}

__generic<T:IFoo>
extension T
{
    This getIdentity()
    {
        return identity;
    }
}

struct FooImpl : IFoo
{
    int v = 1;
    static const This identity = This();   
}


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

[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    FooImpl foo = {};
    var ident = foo.getIdentity();
    // CHECK: 1
    outputBuffer[0] = ident.v;
}