blob: 07b1a43152e4e5a8b826deb204d1de1ccc39b63f (
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
|
// enum-conversion2.slang
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
// More significant stress testing of `enum` types
enum Flower
{
Rose,
Violet,
Tulip,
Orchid,
Chrysanthemum,
}
int test(int val)
{
Flower a = Flower(val);
Flower b = Flower(uint(val));
uint x = uint(a);
int y = int(b);
uint z = (x + y)/2 + uint(Flower.Violet);
Flower c = Flower(z);
return int(c);
}
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
uint tid = dispatchThreadID.x;
int val = int(tid);
val = test(val);
outputBuffer[tid] = val;
}
|