summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-04-13 10:32:38 -0700
committerGitHub <noreply@github.com>2023-04-13 10:32:38 -0700
commit7f091478ec89550483b3cd30b4eb30ffa5e12a62 (patch)
treee71a04175a77bb35c866b9d1736a8eae247a95ac
parent813892cd023e216f6f6560eb47566522d3a82609 (diff)
Add inherit interface test. (#2800)
Fixes #2573. Co-authored-by: Yong He <yhe@nvidia.com>
-rw-r--r--tests/bugs/inherit-interface.slang38
-rw-r--r--tests/bugs/inherit-interface.slang.expected.txt5
2 files changed, 43 insertions, 0 deletions
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<float> 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 : IB>(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