From 73b52f6075eb8a4f674e5d66d2a6192ca71f26d3 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 21 Jul 2022 22:52:27 -0700 Subject: Allow dynamic dispatch to handle nested interface-typed fields. (#2336) --- tests/bugs/nested-existential-dyndispatch.slang | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/bugs/nested-existential-dyndispatch.slang (limited to 'tests/bugs/nested-existential-dyndispatch.slang') diff --git a/tests/bugs/nested-existential-dyndispatch.slang b/tests/bugs/nested-existential-dyndispatch.slang new file mode 100644 index 000000000..b6689b54d --- /dev/null +++ b/tests/bugs/nested-existential-dyndispatch.slang @@ -0,0 +1,56 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +interface IFoo +{ + float sample(); +} + +//TEST_INPUT: type_conformance Bar:IBar = 0 +[anyValueSize(64)] +interface IBar +{ + float sample(); +} + +//TEST_INPUT: type_conformance Foo:IFoo = 0 +struct Foo : IFoo +{ + float3 albedo; + float sample() + { + return albedo.x; + } +} + +struct Bar : IBar +{ + IFoo foo; + float sample() + { + return foo.sample(); + } +} + +struct AnyVal +{ + uint data[16]; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + int index = dispatchThreadID.x; + + Foo f; + f.albedo = float3(1.0); + Bar bar; + bar.foo = f; + + AnyVal data = reinterpret(bar); + IBar dynBar = createDynamicObject(0, data); + + outputBuffer[index] = dynBar.sample(); +} -- cgit v1.2.3