diff options
Diffstat (limited to 'tests/compute/enum-conversion2.slang')
| -rw-r--r-- | tests/compute/enum-conversion2.slang | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/compute/enum-conversion2.slang b/tests/compute/enum-conversion2.slang new file mode 100644 index 000000000..13d807277 --- /dev/null +++ b/tests/compute/enum-conversion2.slang @@ -0,0 +1,44 @@ +// enum-conversion2.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute + +// 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; +}
\ No newline at end of file |
