From 03050997b90b6c07bfdc5ca9c0c08cd278b1b1dd Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 14 Sep 2020 12:26:54 -0700 Subject: Support shader parameters that are an array of existential type. (#1542) * Support shader parameters that are an array of existential type. * Rename to getFirstNonExistentialValueCategory Co-authored-by: Yong He --- tests/compute/array-existential-parameter.slang | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/compute/array-existential-parameter.slang (limited to 'tests/compute/array-existential-parameter.slang') diff --git a/tests/compute/array-existential-parameter.slang b/tests/compute/array-existential-parameter.slang new file mode 100644 index 000000000..f640ba752 --- /dev/null +++ b/tests/compute/array-existential-parameter.slang @@ -0,0 +1,48 @@ +// Test using existential shader parameter that is an interface array. + +//TEST(compute):COMPARE_COMPUTE:-cpu +//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda + +[anyValueSize(8)] +interface IInterface +{ + int run(int input); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer gOutputBuffer; + +struct Params +{ + IInterface values[2]; +}; + +//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb +ConstantBuffer gCb; + +//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb2 +ConstantBuffer gCb2; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + let tid = dispatchThreadID.x; + + let inputVal : int = tid; + let outputVal = gCb.values[0].run(inputVal) + gCb2.values[0].run(inputVal); + + gOutputBuffer[tid] = outputVal; +} + +//TEST_INPUT: globalExistentialType MyImpl +//TEST_INPUT: globalExistentialType __Dynamic + +// Type must be marked `public` to ensure it is visible in the generated DLL. +public struct MyImpl : IInterface +{ + int val; + int run(int input) + { + return input + val; + } +}; -- cgit v1.2.3