yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
447b7e0e2
master
1//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 2 3/* This test trys to specialize an algorithm through generic parameters. 4 5Using parameters in this way ensures the algorithm in function form 6will have those values known at compile time, and presumably lead to a specialized version. 7 8Does not work because 9 10.slang(24): error 30019: expected an expression of type 'int', got 'Enum' 11 let v = doThing<true, false, Enum::A>(); 12 ^ 13 14Note that docs say doesn't support any other than int, but error is a bit confusing. No error at declaration. 15*/ 16 17//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 18RWStructuredBuffer<int> outputBuffer; 19 20enum class Enum 21{ 22 A, B 23}; 24 25int doThing<let a : bool, let b : int, let c : Enum>() 26{ 27 if (a) 28 { 29 return 1; 30 } 31 return 0; 32 // A more complex scenario 33 //return a ? b + b + int(c) : b - int(c); 34} 35 36[numthreads(4, 1, 1)] 37void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 38{ 39 int index = dispatchThreadID.x; 40 41 let v = doThing<true, false, Enum::A>(); 42 43 outputBuffer[dispatchThreadID.x] = v; 44}