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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
//TEST:CPP_COMPILER_COMPILE: -profile cs_5_0 -entry computeMain -target callable
enum Color
{
Red,
Green = 2,
Blue,
}
int test(int val)
{
Color c = Color.Red;
if(val > 1)
{
c = Color.Green;
}
if(c == Color.Red)
{
if(val & 1)
{
c = Color.Blue;
}
}
switch(c)
{
case Color.Red:
val = 1;
break;
case Color.Green:
val = 2;
break;
case Color.Blue:
val = 3;
break;
default:
val = -1;
break;
}
return (val << 4) + int(c);
}
float sum(float a[3])
{
float total = a[0];
for (int i = 1; i < 3; ++i)
{
total += a[i];
}
return total;
}
struct Thing
{
int a;
float b;
};
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out
RWStructuredBuffer<int> outputBuffer;
RWStructuredBuffer<int> outputBuffer2;
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
uint tid = dispatchThreadID.x;
Thing thing = { 10, -1.0 };
float array[3] = { thing.a, 2, 3};
float anotherArray[] = { 1, 2, 5 };
array[0] += anotherArray[1];
matrix<float, 2, 3> mat = { { sum(array), 1, 2 }, { 3, 4, 5} };
vector<float, 2> vec = { float(tid + 1), float(tid + 2) };
vector<float, 3> vec2 = max(sin(mul(vec, mat)), float3(1, 2, -1));
vector<float, 3> vec3 = mul(vec, mat);
float3 vec4 = lerp(vec2, vec3, float3(tid * (1.0f / 4), 1, 1));
float3 crossVec = normalize(cross(vec4, vec4));
vec2.x = fmod(crossVec.y, crossVec.x);
vec2 = fmod(vec2, crossVec);
vec2 += (-vec2.zyx) * 2 + crossVec * length(crossVec) + reflect(vec4, normalize(crossVec));
vector<bool, 3> z = vec2 > 0;
int val = (int(tid) + (any(z) ? 1 : 0) + (all(z) ? 2 : 0)) % 100;
val = asint(asfloat(asuint(asfloat(val))));
val = test(val);
outputBuffer[tid] = val + int(dot(vec2, vec4));
outputBuffer2[tid] = int(tid);
}
|