yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Tim FoleyConvert more tests to use shader objects (#1659)2a5d5b323

master
842 B44 linesraw
1// enum-conversion2.slang
2
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
5//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
6
7// More significant stress testing of `enum` types
8
9enum Flower
10{
11	Rose,
12	Violet,
13	Tulip,
14	Orchid,
15	Chrysanthemum,
16}
17
18int test(int val)
19{
20	Flower a = Flower(val);
21	Flower b = Flower(uint(val));
22
23	uint x = uint(a);
24	int y = int(b);
25
26	uint z = (x + y)/2 + uint(Flower.Violet);
27
28	Flower c = Flower(z);
29	return int(c);
30}
31
32//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
33RWStructuredBuffer<int> outputBuffer;
34
35[numthreads(4, 1, 1)]
36void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
37{
38    uint tid = dispatchThreadID.x;
39
40    int val = int(tid);
41    val = test(val);
42
43    outputBuffer[tid] = val;
44}