From 3321df74904dfe3a11a41179b66a4c3ce5b57022 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 4 Oct 2020 01:40:58 -0700 Subject: Handle partial existential parameter type specialization. (#1568) * Specialize exsitentials parameters in struct fields. * Cleanup. * Handle partial existential parameter type specialization. Co-authored-by: Yong He --- .../interface-param-partial-specialize.slang | 46 ++++++++++++++++++++++ ...ace-param-partial-specialize.slang.expected.txt | 4 ++ 2 files changed, 50 insertions(+) create mode 100644 tests/compute/interface-param-partial-specialize.slang create mode 100644 tests/compute/interface-param-partial-specialize.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/interface-param-partial-specialize.slang b/tests/compute/interface-param-partial-specialize.slang new file mode 100644 index 000000000..e856e04e8 --- /dev/null +++ b/tests/compute/interface-param-partial-specialize.slang @@ -0,0 +1,46 @@ +// Tests generating dynamic dispatch code for a function +// with existential-struct-typed param by specializing it +// with __Dynamic. This verifies that the handling of +// "partially" specializing an existential type is correct. + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu + +[anyValueSize(8)] +interface IInterface +{ + uint eval(); +} + +public struct Impl : IInterface +{ + uint val; + uint eval() + { + return val; + } +}; + +struct Params +{ + StructuredBuffer obj; +}; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer gOutputBuffer; + +void compute(uint tid, Params p) +{ + gOutputBuffer[tid] = p.obj[0].eval(); +} + +//TEST_INPUT: entryPointExistentialType __Dynamic + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID, +//TEST_INPUT:ubuffer(data=[rtti(Impl) witness(Impl, IInterface) 1 0], stride=4):name=params.obj + uniform Params params) +{ + uint tid = dispatchThreadID.x; + compute(tid, params); +} \ No newline at end of file diff --git a/tests/compute/interface-param-partial-specialize.slang.expected.txt b/tests/compute/interface-param-partial-specialize.slang.expected.txt new file mode 100644 index 000000000..98fb6a686 --- /dev/null +++ b/tests/compute/interface-param-partial-specialize.slang.expected.txt @@ -0,0 +1,4 @@ +1 +1 +1 +1 -- cgit v1.2.3