yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
11111e573
master
1// Tests specializing a function with existential-struct-typed param. 2 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj 4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj 5 6[anyValueSize(8)] 7interface IInterface 8{ 9 uint eval(); 10} 11 12export struct Impl : IInterface 13{ 14 uint val; 15 uint eval() 16 { 17 return val; 18 } 19}; 20 21struct Params 22{ 23 StructuredBuffer<IInterface> obj; 24}; 25 26//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer 27RWStructuredBuffer<uint> gOutputBuffer; 28 29void compute(uint tid, Params p) 30{ 31 gOutputBuffer[tid] = p.obj[0].eval(); 32} 33 34[numthreads(4, 1, 1)] 35void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID, 36//TEST_INPUT:set params.obj = new StructuredBuffer<IInterface>{new Impl{1}} 37 uniform Params params) 38{ 39 uint tid = dispatchThreadID.x; 40 compute(tid, params); 41}