summaryrefslogtreecommitdiff
path: root/tests/compute/assoctype-simple.slang
blob: d12c2962027ce353920451b5d2492a002c7ceef9 (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
//TEST(smoke,compute):COMPARE_COMPUTE:
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
// Confirm that generics syntax can be used in user
// code and generates valid output.

RWStructuredBuffer<float> outputBuffer;

interface ISimple
{
    associatedtype U;
    U addt(U v0, U v1);
}

struct Simple : ISimple
{
    typedef float U;
    U addt(U v0, float v1)
    {
        return v0 + v1;
    }
};

__generic<T:ISimple>
T.U test(T simple, T.U v0, T.U v1)
{
    return simple.addt(v0, v1);
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    Simple s;
	float outVal = test<Simple>(s, 2.0, 1.0); // == 3.0
	outputBuffer[dispatchThreadID.x] = outVal;
}