yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8ce7c6f69
master
1//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj 2//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj 3 4// Use interface constraints on a generic parameter 5 6interface Helper 7{ 8 float getHelp(); 9} 10 11struct A : Helper 12{ 13 float a; 14 15 float getHelp() 16 { 17 // TODO: we should be able to reference a member variable here, 18 // but the front-end isn't handling references through `this` 19 // properly yet. 20 return a; 21 } 22}; 23 24__generic<T : Helper> 25float testHelp(T helper) 26{ 27 return helper.getHelp(); 28} 29 30//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 31RWStructuredBuffer<float> outputBuffer; 32 33 34[numthreads(4, 1, 1)] 35void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 36{ 37 uint tid = dispatchThreadID.x; 38 float inVal = float(tid); 39 40 A a; 41 a.a = inVal; 42 float outVal = testHelp<A>(a); 43 44 outputBuffer[tid] = outVal; 45}