summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-13 18:58:05 -0700
committerGitHub <noreply@github.com>2022-09-13 18:58:05 -0700
commit05f9aaf6a4ef246dcf89b00000a8e59e90c47662 (patch)
treef4c94d339066c9700bf0d806acd2b6d2647f3256 /tests
parentf216b77752b9e4aea52882b2110ceb1cc64a2171 (diff)
Allow interface requirements to reference to the interface type itself. (#2398)
* Allow interface requirements to reference to the interface type itself. * add comment explaining the change. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/interface-type-self-ref.slang32
-rw-r--r--tests/bugs/interface-type-self-ref.slang.expected.txt5
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/interface-type-self-ref.slang b/tests/bugs/interface-type-self-ref.slang
new file mode 100644
index 000000000..e3b1fe7cc
--- /dev/null
+++ b/tests/bugs/interface-type-self-ref.slang
@@ -0,0 +1,32 @@
+//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<int> outputBuffer;
+
+interface IFoo
+{
+ int compute(out IFoo param);
+}
+
+struct Impl : IFoo
+{
+ int compute(out IFoo param)
+ {
+ param = this;
+ return 0;
+ }
+}
+
+int f(IFoo p)
+{
+ IFoo r;
+ return p.compute(r);
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
+{
+ int index = dispatchThreadID.x;
+ Impl impl;
+ outputBuffer[index] = f(impl);
+}
diff --git a/tests/bugs/interface-type-self-ref.slang.expected.txt b/tests/bugs/interface-type-self-ref.slang.expected.txt
new file mode 100644
index 000000000..b9efb5a97
--- /dev/null
+++ b/tests/bugs/interface-type-self-ref.slang.expected.txt
@@ -0,0 +1,5 @@
+type: int32_t
+0
+0
+0
+0