yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
adaea0e99
master
1// constant-fold.slang 2 3//TEST(compute):COMPARE_COMPUTE: -shaderobj 4//DISABLE_TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 5 6struct AnotherStruct<let SomeValue : int> 7{ 8 __init() 9 { 10 value = SomeValue; 11 } 12 int value; 13}; 14 15struct SomeStruct<let SomeValue : bool> 16{ 17 __init() 18 { 19 value = SomeValue; 20 } 21 bool value; 22}; 23 24//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer 25RWStructuredBuffer<int> outputBuffer; 26 27[numthreads(8, 1, 1)] 28void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 29{ 30 SomeStruct<true> a; 31 SomeStruct<false> b; 32 SomeStruct<bool(1)> c; 33 SomeStruct<bool(0)> d; 34 35 AnotherStruct<true> e; 36 AnotherStruct<false> f; 37 AnotherStruct<2> g; 38 AnotherStruct<-2> h; 39 40 41 uint tid = dispatchThreadID.x; 42 43 int outVal; 44 switch (tid) 45 { 46 default: 47 case 0: outVal = a.value; break; 48 case 1: outVal = b.value; break; 49 case 2: outVal = c.value; break; 50 case 3: outVal = d.value; break; 51 case 4: outVal = e.value; break; 52 case 5: outVal = f.value; break; 53 case 6: outVal = g.value; break; 54 case 7: outVal = h.value; break; 55 } 56 57 outputBuffer[tid] = outVal; 58}