yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1// Test calling a generic member method with partially specified generic arguments. 2 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 4//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 7RWStructuredBuffer<int> outputBuffer; 8 9interface INothing 10{ 11 int getVal(); 12} 13 14struct Nothing : INothing 15{ 16 int getVal() { return 0; } 17} 18 19interface IImpl 20{ 21 int computeAdd<TNothing : INothing, TNothing2 : INothing>(TNothing nothingArg, TNothing2 nothing, int otherVal); 22} 23 24struct Impl : IImpl 25{ 26 int thisVal; 27 __init() 28 { 29 thisVal = 1; 30 } 31 // Introduce two generic parameters so we can construct a partially specialized invoke. 32 int computeAdd<TNothing : INothing, TNothing2 : INothing>(TNothing nothingArg, TNothing2 nothing, int otherVal) 33 { 34 return thisVal + otherVal + nothingArg.getVal(); 35 } 36 int doThing(int otherVal) 37 { 38 Nothing nothing; 39 // Partially specialize the invoke. 40 // This will result in construction of `PartiallySpecializedInvokeExpr`. 41 // We need to make sure the baseExpr is persisted during this step. 42 return computeAdd<Nothing>(nothing, nothing, otherVal); 43 } 44} 45 46[numthreads(1, 1, 1)] 47void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) 48{ 49 Impl impl; 50 Nothing nothing; 51 outputBuffer[0] = impl.doThing(2); 52}