forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface-assoc-type-param.slang
59 lines (51 loc) · 1.15 KB
/
interface-assoc-type-param.slang
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
54
55
56
57
58
59
// Tests using associated types through an existential-struct-typed param.
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj
[anyValueSize(8)]
interface IInterface
{
associatedtype TEval:IEval;
TEval getEval();
}
[anyValueSize(8)]
interface IEval
{
uint eval();
}
//TEST_INPUT: type_conformance Impl:IInterface = 0
struct Impl : IInterface
{
uint val;
struct TEval : IEval
{
uint val;
uint eval()
{
return val;
}
};
TEval getEval()
{
TEval rs;
rs.val = val;
return rs;
}
};
struct Params
{
StructuredBuffer<IInterface> obj;
};
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<uint> gOutputBuffer;
void compute(uint tid, Params p)
{
gOutputBuffer[tid] = p.obj[0].getEval().eval();
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,
//TEST_INPUT:set params.obj = new StructuredBuffer<IInterface>{ new Impl{1}}
uniform Params params)
{
uint tid = dispatchThreadID.x;
compute(tid, params);
}