summaryrefslogtreecommitdiffstats
path: root/tests/compute/extension-on-interface.slang
blob: 594413714d7635b9118211c29fb5b1201636a29b (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Note: disabled because extension of interfaces shouldn't
// work the way this test assumes it does...

//TEST_DISABLED(compute):COMPARE_COMPUTE:
//TEST_DISABLED(compute):COMPARE_COMPUTE:-cpu

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

interface IOp
{
    float addf(float u, float v);
}

interface ISub
{
    float subf(float u, float v);
}

extension IOp : ISub
{
}

struct Simple : IOp
{
    float base;
    float addf(float u, float v)
    {
        return u+v;
    }
};

__extension Simple : ISub
{
    float subf(float u, float v)
    {
        return base+u-v;
    }
};

float testAddSub<T:IOp>(T t)
{
    return t.subf(t.addf(1.0, 1.0), 1.0);
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    Simple s;
    s.base = 0.0;
	float outVal = testAddSub(s);
	outputBuffer[dispatchThreadID.x] = outVal;
}