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// Note: Not using `-shaderobj` because this test relies on 4// setting up a `ConstantBuffer<IInterface>`, which currently 5// doesn't work right on the shader object path for a bunch 6// of complicated reasons. 7 8//DISABLED_TEST(compute):COMPARE_COMPUTE:-dx11 9//DISABLED_TEST(compute):COMPARE_COMPUTE:-cpu 10//DISABLED_TEST(compute):COMPARE_COMPUTE:-vk 11//DISABLED_TEST(compute):COMPARE_COMPUTE:-cuda 12 13[anyValueSize(8)] 14interface IInterface 15{ 16 int run(int input); 17} 18 19//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer 20RWStructuredBuffer<int> gOutputBuffer; 21 22//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb 23ConstantBuffer<IInterface> gCb; 24 25//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb1 26ConstantBuffer<IInterface> gCb1; 27 28[numthreads(4, 1, 1)] 29void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 30{ 31 let tid = dispatchThreadID.x; 32 33 let inputVal : int = tid; 34 let outputVal = gCb.run(inputVal) + gCb1.run(inputVal); 35 36 gOutputBuffer[tid] = outputVal; 37} 38 39// Specialize gCb1, but not gCb2 40// TEST_INPUT: globalExistentialType MyImpl 41// TEST_INPUT: globalExistentialType __Dynamic 42// Type must be marked `public` to ensure it is visible in the generated DLL. 43export struct MyImpl : IInterface 44{ 45 int val; 46 int run(int input) 47 { 48 return input + val; 49 } 50};