forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric-constant-fold.slang
58 lines (48 loc) · 1.22 KB
/
generic-constant-fold.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
// constant-fold.slang
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
struct AnotherStruct<let SomeValue : int>
{
__init()
{
value = SomeValue;
}
int value;
};
struct SomeStruct<let SomeValue : bool>
{
__init()
{
value = SomeValue;
}
bool value;
};
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(8, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
SomeStruct<true> a;
SomeStruct<false> b;
SomeStruct<bool(1)> c;
SomeStruct<bool(0)> d;
AnotherStruct<true> e;
AnotherStruct<false> f;
AnotherStruct<2> g;
AnotherStruct<-2> h;
uint tid = dispatchThreadID.x;
int outVal;
switch (tid)
{
default:
case 0: outVal = a.value; break;
case 1: outVal = b.value; break;
case 2: outVal = c.value; break;
case 3: outVal = d.value; break;
case 4: outVal = e.value; break;
case 5: outVal = f.value; break;
case 6: outVal = g.value; break;
case 7: outVal = h.value; break;
}
outputBuffer[tid] = outVal;
}