yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2a5d5b323
master
1//TEST(compute):COMPARE_COMPUTE: -shaderobj 2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 3 4// test specialization of nested generic functions 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 7RWStructuredBuffer<int> outputBuffer; 8 9interface IGetF 10{ 11 float getF(); 12} 13 14struct GetFImpl : IGetF 15{ 16 float getF() { return 1.0; } 17}; 18 19struct GetFImpl2 : IGetF 20{ 21 float getF() { return -1.0; } 22}; 23 24struct GenStruct<T : IGetF> 25{ 26 T x; 27 float genGet<U : IGetF>(U y) 28 { 29 return x.getF() + y.getF(); 30 } 31}; 32 33[numthreads(1, 1, 1)] 34void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 35{ 36 uint tid = dispatchThreadID.x; 37 GenStruct<GetFImpl> obj1; 38 GetFImpl2 obj2; 39 float outVal = obj1.genGet(obj2); 40 outputBuffer[tid] = int(outVal); 41}