yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1// enum-equality.slang 2 3// Test that equality (and inequality) of `enum` 4// types works as expected. 5 6//TEST(compute):COMPARE_COMPUTE: -shaderobj 7 8enum Channel 9{ 10 Red, 11 Green, 12 Blue, 13 Alpha, 14} 15 16int test(int val) 17{ 18 Channel channel= Channel(val); 19 20 int result = 0; 21 if(channel == Channel.Red) result += 1; 22 if(channel != Channel.Green) result += 16; 23 if(channel == Channel.Blue) result += 16*16; 24 if(channel != Channel.Alpha) result += 16*16*16; 25 26 return result; 27} 28 29 30//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 31RWStructuredBuffer<int> outputBuffer; 32 33[numthreads(4, 1, 1)] 34void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 35{ 36 int tid = dispatchThreadID.x; 37 int inVal = tid; 38 int outVal = test(inVal); 39 outputBuffer[tid] = outVal; 40}