From 7f091478ec89550483b3cd30b4eb30ffa5e12a62 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 13 Apr 2023 10:32:38 -0700 Subject: Add inherit interface test. (#2800) Fixes #2573. Co-authored-by: Yong He --- tests/bugs/inherit-interface.slang | 38 +++++++++++++++++++++++++ tests/bugs/inherit-interface.slang.expected.txt | 5 ++++ 2 files changed, 43 insertions(+) create mode 100644 tests/bugs/inherit-interface.slang create mode 100644 tests/bugs/inherit-interface.slang.expected.txt diff --git a/tests/bugs/inherit-interface.slang b/tests/bugs/inherit-interface.slang new file mode 100644 index 000000000..3b348d12e --- /dev/null +++ b/tests/bugs/inherit-interface.slang @@ -0,0 +1,38 @@ +//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 IA +{ + int doThing(int a); +}; + +interface IB : IA +{ + int anotherThing(int a); +}; + +struct Struct : IB +{ + int doThing(int a) { return a + 1; } + int anotherThing(int a) { return a * a; } +}; + +int doThing(B b, int c) +{ + return b.doThing(c) + b.anotherThing(c); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + Struct s; + int v = doThing(s, int(tid)); + + float inVal = float(tid + v); + + outputBuffer[tid] = inVal; +} \ No newline at end of file diff --git a/tests/bugs/inherit-interface.slang.expected.txt b/tests/bugs/inherit-interface.slang.expected.txt new file mode 100644 index 000000000..fe70e7eb6 --- /dev/null +++ b/tests/bugs/inherit-interface.slang.expected.txt @@ -0,0 +1,5 @@ +type: float +1.000000 +4.000000 +9.000000 +16.000000 -- cgit v1.2.3