summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-04-03 15:54:16 -0700
committerGitHub <noreply@github.com>2023-04-03 15:54:16 -0700
commitb68516e2c2e39af79dda2ec7871fe4d821ef67c4 (patch)
treeec61ca320368f8128cd531a9272e8e49d5353247 /tests
parent7a346b2982c69ef97ebc4b308c77a1f1c88c548f (diff)
Emit simpler vector element access code. (#2770)
* Emit simpler vector element access code * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/type-legalize-bug-1.slang56
-rw-r--r--tests/bugs/type-legalize-bug-1.slang.expected.txt4
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/bugs/type-legalize-bug-1.slang b/tests/bugs/type-legalize-bug-1.slang
new file mode 100644
index 000000000..83e28a509
--- /dev/null
+++ b/tests/bugs/type-legalize-bug-1.slang
@@ -0,0 +1,56 @@
+//TEST(compute):COMPARE_COMPUTE: -shaderobj
+
+//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):out,name outputBuffer
+//TEST_INPUT:type_conformance A:IFoo=0
+//TEST_INPUT:type_conformance B:IFoo=1
+
+RWStructuredBuffer<int> outputBuffer : register(u0);
+interface IFoo
+{
+ associatedtype T : IFoo;
+ T getT();
+ void doSomething();
+}
+
+A createA() { return {}; }
+B createB() { return {}; }
+ParameterBlock<B> gB;
+void user()
+{
+ IFoo a = createDynamicObject<IFoo>(0, 0);
+ IFoo b = createDynamicObject<IFoo>(1, 0);
+ test(a.getT(), b);
+ test(a, gB.getT());
+}
+B test<T:IFoo>(T a, IFoo b)
+{
+ a.doSomething();
+ b.doSomething();
+ return {};
+}
+struct B :IFoo
+{
+ A a;
+ typealias T = A;
+ T getT() { return {};}
+ void doSomething()
+ {
+ outputBuffer[0] = 1;
+ }
+}
+struct A : IFoo
+{
+ typealias T = B;
+ T getT() { return {};}
+ void doSomething()
+ {
+ outputBuffer[0] = 1;
+ }
+}
+
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ user();
+} \ No newline at end of file
diff --git a/tests/bugs/type-legalize-bug-1.slang.expected.txt b/tests/bugs/type-legalize-bug-1.slang.expected.txt
new file mode 100644
index 000000000..89999d47a
--- /dev/null
+++ b/tests/bugs/type-legalize-bug-1.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+9
+9
+9