diff options
Diffstat (limited to 'tests/compute/interface-assoc-type-param.slang')
| -rw-r--r-- | tests/compute/interface-assoc-type-param.slang | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/compute/interface-assoc-type-param.slang b/tests/compute/interface-assoc-type-param.slang new file mode 100644 index 000000000..d43a43fc9 --- /dev/null +++ b/tests/compute/interface-assoc-type-param.slang @@ -0,0 +1,60 @@ +// Tests using associated types through an existential-struct-typed param. + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu + +[anyValueSize(8)] +interface IInterface +{ + associatedtype TEval:IEval; + TEval getEval(); +} + +[anyValueSize(8)] +interface IEval +{ + uint eval(); +} + +struct Impl : IInterface +{ + uint val; + struct TEval : IEval + { + uint val; + uint eval() + { + return val; + } + }; + TEval getEval() + { + TEval rs; + rs.val = val; + return rs; + } +}; + +struct Params +{ + StructuredBuffer<IInterface> obj; +}; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer<uint> gOutputBuffer; + +void compute(uint tid, Params p) +{ + gOutputBuffer[tid] = p.obj[0].getEval().eval(); +} + +//TEST_INPUT: entryPointExistentialType Impl + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID, +//TEST_INPUT:ubuffer(data=[0 0 0 0 1 0], stride=4):name=params.obj + uniform Params params) +{ + uint tid = dispatchThreadID.x; + compute(tid, params); +}
\ No newline at end of file |
