summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-10-02 09:49:18 -0700
committerGitHub <noreply@github.com>2020-10-02 09:49:18 -0700
commitaadf6002783b88ea79c30a2f908270685b6c3d27 (patch)
tree890d60ea78a81b35fa9ad28873bbe25c1fc7f9a4 /tests
parent274c20a5eb133779a9d890ca79120815fb92b04e (diff)
Specialize exsitentials parameters in struct fields. (#1565)
* Specialize exsitentials parameters in struct fields. * Cleanup. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/interface-func-param-in-struct.slang43
-rw-r--r--tests/compute/interface-func-param-in-struct.slang.expected.txt4
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/compute/interface-func-param-in-struct.slang b/tests/compute/interface-func-param-in-struct.slang
new file mode 100644
index 000000000..550758f38
--- /dev/null
+++ b/tests/compute/interface-func-param-in-struct.slang
@@ -0,0 +1,43 @@
+// Tests specializing a function with existential-struct-typed param.
+
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu
+
+[anyValueSize(8)]
+interface IInterface
+{
+ uint eval();
+}
+
+struct Impl : IInterface
+{
+ uint val;
+ uint eval()
+ {
+ return val;
+ }
+};
+
+struct Params
+{
+ StructuredBuffer<IInterface> obj;
+};
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
+RWStructuredBuffer<uint> gOutputBuffer;
+
+void compute(uint tid, Params p)
+{
+ gOutputBuffer[tid] = p.obj[0].eval();
+}
+
+//TEST_INPUT: entryPointExistentialType Impl
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,
+//TEST_INPUT:ubuffer(data=[0 0 0 0 1 0], stride=4):name=params.obj
+ uniform Params params)
+{
+ uint tid = dispatchThreadID.x;
+ compute(tid, params);
+} \ No newline at end of file
diff --git a/tests/compute/interface-func-param-in-struct.slang.expected.txt b/tests/compute/interface-func-param-in-struct.slang.expected.txt
new file mode 100644
index 000000000..98fb6a686
--- /dev/null
+++ b/tests/compute/interface-func-param-in-struct.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+1
+1
+1