summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-06 16:08:48 -0700
committerGitHub <noreply@github.com>2022-09-06 16:08:48 -0700
commit9f3e83cf0d664c87a618edf08d834829178030e6 (patch)
treef0545822e4f37f18ec847166e6a00912c10251a1 /tests/bugs
parent61ff1ba8459d70cbc887040c530b5ce1a125ec77 (diff)
Specialize and SSA in a loop + better diagnostics on dynamic dispatch failure (#2396)
* Report diagnostic when dynamic dispatch failed instead of crashing. * Specialize and SSA in a loop. Explicit specialization only interface. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/specialize-existential-in-generic.slang42
-rw-r--r--tests/bugs/specialize-existential-in-generic.slang.expected.txt4
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/bugs/specialize-existential-in-generic.slang b/tests/bugs/specialize-existential-in-generic.slang
new file mode 100644
index 000000000..31ef75512
--- /dev/null
+++ b/tests/bugs/specialize-existential-in-generic.slang
@@ -0,0 +1,42 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+
+[Specialize]
+interface IAssoc
+{
+ int getInner();
+}
+
+interface IFoo
+{
+ associatedtype Assoc : IAssoc;
+ Assoc getValue();
+}
+
+struct Impl : IFoo
+{
+ struct Assoc : IAssoc { int getInner() { return 1; } }
+ Assoc getValue() { Assoc r; return r; }
+}
+
+struct GenType<T : IFoo>
+{
+ T obj;
+ int doThing()
+ {
+ IAssoc soc = obj.getValue(); // "boxing" into an existential
+
+ // a specialized version of this function should call specialized method instead of going through dynamic dispatch.
+ return soc.getInner();
+ }
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
+RWStructuredBuffer<int> gOutputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
+{
+ int tid = dispatchThreadID.x;
+ GenType<Impl> val;
+ gOutputBuffer[tid] = val.doThing();
+} \ No newline at end of file
diff --git a/tests/bugs/specialize-existential-in-generic.slang.expected.txt b/tests/bugs/specialize-existential-in-generic.slang.expected.txt
new file mode 100644
index 000000000..ef529012e
--- /dev/null
+++ b/tests/bugs/specialize-existential-in-generic.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+1
+1
+1 \ No newline at end of file