yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
11111e573
master
1// Test using interface typed shader parameters with dynamic dispatch. 2 3// TODO: This test has been disabled because it relies on 4// `ConstantBuffer<IInterface>` which we expect to change 5// implementation approaches for soon. 6 7//DISABLE_TEST(compute):COMPARE_COMPUTE:-dx11 -shaderobj 8//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -shaderobj 9//DISABLE_TEST(compute):COMPARE_COMPUTE:-cpu -xslang -disable-specialization -shaderobj 10//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda -xslang -disable-specialization -shaderobj 11 12[anyValueSize(8)] 13interface IInterface 14{ 15 int run(int input); 16} 17 18//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer 19RWStructuredBuffer<int> gOutputBuffer; 20 21//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb 22ConstantBuffer<IInterface> gCb; 23 24[numthreads(4, 1, 1)] 25void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 26{ 27 let tid = dispatchThreadID.x; 28 29 let inputVal : int = tid; 30 let outputVal = gCb.run(inputVal); 31 32 gOutputBuffer[tid] = outputVal; 33} 34 35// No type input for dynamic dispatch //TEST_INPUT: globalExistentialType MyImpl 36// Type must be marked `public` to ensure it is visible in the generated DLL. 37export struct MyImpl : IInterface 38{ 39 int val; 40 int run(int input) 41 { 42 return input + val; 43 } 44};