From a2a7c4d988b2b7126130d9dcbe4ec94e1ce8424b Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 2 Sep 2020 12:21:28 -0700 Subject: Allow unspecialized existential shader parameters (dynamic dispatch). (#1529) * Allow unspecialized existential shader parameters (dynamic dispatch). * Fixes. * Fixes * disable cuda test --- tests/compute/dynamic-dispatch-11.slang | 38 ++++++++++++++++++++++ .../compute/dynamic-dispatch-11.slang.expected.txt | 4 +++ 2 files changed, 42 insertions(+) create mode 100644 tests/compute/dynamic-dispatch-11.slang create mode 100644 tests/compute/dynamic-dispatch-11.slang.expected.txt (limited to 'tests/compute') diff --git a/tests/compute/dynamic-dispatch-11.slang b/tests/compute/dynamic-dispatch-11.slang new file mode 100644 index 000000000..18b416697 --- /dev/null +++ b/tests/compute/dynamic-dispatch-11.slang @@ -0,0 +1,38 @@ +// Test using interface typed shader parameters with dynamic dispatch. + +//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -disable-specialization +//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda -xslang -disable-specialization + +[anyValueSize(8)] +interface IInterface +{ + int run(int input); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer gOutputBuffer; + +//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb +ConstantBuffer gCb; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + let tid = dispatchThreadID.x; + + let inputVal : int = tid; + let outputVal = gCb.run(inputVal); + + gOutputBuffer[tid] = outputVal; +} + +// No type input for dynamic dispatch //TEST_INPUT: globalExistentialType MyImpl +// 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; + } +}; diff --git a/tests/compute/dynamic-dispatch-11.slang.expected.txt b/tests/compute/dynamic-dispatch-11.slang.expected.txt new file mode 100644 index 000000000..94ebaf900 --- /dev/null +++ b/tests/compute/dynamic-dispatch-11.slang.expected.txt @@ -0,0 +1,4 @@ +1 +2 +3 +4 -- cgit v1.2.3