summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/generics/generic-interface-1.slang
blob: 217e7f06f630db725e5911092530b9682a55328a (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
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type

interface IEqlTestable<T>
{
    bool testEql(T v1);
}

bool test<T>(IEqlTestable<T> v0, T v1)
{
    return v0.testEql(v1);
}

struct MyType : IEqlTestable<MyType>
{
    int val;
    bool testEql(MyType v1)
    {
        return val == v1.val;
    }
}

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

[numthreads(2, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    MyType obj1, obj2;
    obj1.val = tid;
    obj2.val = 1;
    let result = test(obj1, obj2);
    outputBuffer[tid] = result ? 1 : 0;
    // CHECK: 0
    // CHECK: 1
}