From 4e7694fc862ad69b4746373d58fc7f2071385ca2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 10 Jan 2022 15:32:34 -0500 Subject: Test for dynamicDispatch/resource internal error (#2071) * #include an absolute path didn't work - because paths were taken to always be relative. * Test for internal error with resource/dynamic dispatch. * Fix typo. Co-authored-by: Theresa Foley --- tests/current-bugs/resource-dynamic-dispatch.slang | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/current-bugs/resource-dynamic-dispatch.slang (limited to 'tests') diff --git a/tests/current-bugs/resource-dynamic-dispatch.slang b/tests/current-bugs/resource-dynamic-dispatch.slang new file mode 100644 index 000000000..0a987b1cf --- /dev/null +++ b/tests/current-bugs/resource-dynamic-dispatch.slang @@ -0,0 +1,67 @@ +//DISABLE_TEST:SIMPLE:-target dxil -entry computeMain -profile cs_6_2 + +/* Fails with: + +(0): internal error 99999: unimplemented feature in Slang compiler: unexpected IR opcode during code emit +*/ + +// Dynamic dispatch with a resource type +RWStructuredBuffer outputBuffer; + +interface IGetTexture +{ + Texture2D getTexture(); +}; + +struct SomeData : IGetTexture +{ + Texture2D getTexture() { return tex; } + Texture2D tex; +}; + +interface IInterface +{ + associatedtype Type; + IGetTexture getType(); +}; + +// Need public to make these conformances available +public struct A : IInterface +{ + typedef SomeData Type; + IGetTexture getType() { Type t = { gTexA }; return t; } +}; + +public struct B : IInterface +{ + typedef SomeData Type; + IGetTexture getType() { Type t = { gTexB }; return t; } +}; + +Texture2D gTexA, gTexB; + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + A a; + B b; + + IInterface intf; + + if (tid & 1) + { + intf = a; + } + else + { + intf = b; + } + + var getTex = intf.getType(); + let tex = getTex.getTexture(); + + outputBuffer[tid] = tex.Load(int3(tid, tid, 0)); +} \ No newline at end of file -- cgit v1.2.3