forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempty-struct2.slang
54 lines (48 loc) · 1005 Bytes
/
empty-struct2.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
//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj
// This is a basic test for Slang compute shader.
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
interface IInterface
{
associatedtype T;
T getT();
[mutating]
void setT(T val);
}
interface IEmptyS
{
float emptyFunc();
};
struct EmptyS : IEmptyS
{
float emptyFunc() {return 0.0;}
};
struct Empty<TT : IEmptyS> : IInterface
{
typedef TT T;
TT value = TT();
float a = 0;
TT getT()
{
return value;
}
[mutating]
void setT(TT val)
{
value = val;
a = value.emptyFunc();
}
}
void test<Obj : IInterface>(Obj obj)
{
Obj.T v = obj.getT();
obj.setT(v);
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
Empty<EmptyS> obj = {};
test(obj);
outputBuffer[dispatchThreadID.x] = dispatchThreadID.x;
}