summaryrefslogtreecommitdiffstats
path: root/tests/compute/generic-struct-with-constraint.slang
blob: b17e2b05e91059aa0fb96a29cb25f9d9edde553f (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
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj

// Confirm that generics syntax can be used in user
// code and generates valid output.

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

interface IElement
{
    float4 getValue();
};

struct SingleElement : IElement
{
    float4 value;
    float4 getValue()
    {
        return value;
    }
};

struct ListElement<THead : IElement> : IElement
{
    THead head;
    float4 getValue()
    {
        return head.getValue();
    }
};

float4 test<T : IElement>(T val)
{
	return val.getValue();
}


[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    ListElement<SingleElement> list;
    list.head.value = float4(1.0);
    float4 outVal = test<ListElement<SingleElement> >(list);
	outputBuffer[0] = outVal;
}