blob: 3a3a4a5b8203c67ed8870edd662da99e409fb54a (
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
|
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
// Check that user code can declare and use a generic
// `struct` type.
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
interface ITest
{
int doThing(int x);
};
struct Impl1 : ITest
{
int doThing(int x)
{
return x * 2;
}
};
struct Impl2 : ITest
{
int doThing(int x)
{
return x * 3;
}
};
__generic<T : ITest = Impl1>
struct GenStruct
{
T obj = T();
};
int test(GenStruct gs, int val)
{
return gs.obj.doThing(val);
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int tid = dispatchThreadID.x;
int outVal = 0;
GenStruct<Impl1> gs;
outVal += test(gs, tid);
outputBuffer[tid] = outVal;
}
|