yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
3d7552582
master
1//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj 2//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj 3 4// Test overload resolution for nested generic definitions 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 7RWStructuredBuffer<float> outputBuffer; 8 9 10__generic<T : __BuiltinFloatingPointType> 11struct Foo 12{ 13 T test(uint index, T x) 14 { 15 return __realCast<T, float>(1.f); 16 } 17 18 __generic<let N: int> 19 T test(vector<uint, N> index, T x) 20 { 21 return __realCast<T, float>(2.f); 22 } 23}; 24 25 26[numthreads(1, 1, 1)] 27void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 28{ 29 uint tid = dispatchThreadID.x + 2; 30 31 Foo<float> obj; 32 33 float outVal = obj.test(tid, 0.f); 34 outputBuffer[0] = outVal; // Expect: 1 35 36 float outVal2 = obj.test(uint2(tid, tid), 0.f); 37 outputBuffer[1] = outVal2; // Expect: 2 38}