summaryrefslogtreecommitdiff
path: root/tests/compute/generic-struct-with-constraint.slang
blob: 1c2fdf4f3392dfa1fdf8adc7e57204d6a098db37 (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
//TEST(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<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;
}