summaryrefslogtreecommitdiffstats
path: root/tests/compute/array-existential-parameter.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-09-14 12:26:54 -0700
committerGitHub <noreply@github.com>2020-09-14 12:26:54 -0700
commit03050997b90b6c07bfdc5ca9c0c08cd278b1b1dd (patch)
tree9cbfece387e960bedc3df3236eaaf0236c7bff0b /tests/compute/array-existential-parameter.slang
parent2e3688af574738650c2753680ce9f417fb22e5e7 (diff)
Support shader parameters that are an array of existential type. (#1542)
* Support shader parameters that are an array of existential type. * Rename to getFirstNonExistentialValueCategory Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/compute/array-existential-parameter.slang')
-rw-r--r--tests/compute/array-existential-parameter.slang48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/compute/array-existential-parameter.slang b/tests/compute/array-existential-parameter.slang
new file mode 100644
index 000000000..f640ba752
--- /dev/null
+++ b/tests/compute/array-existential-parameter.slang
@@ -0,0 +1,48 @@
+// Test using existential shader parameter that is an interface array.
+
+//TEST(compute):COMPARE_COMPUTE:-cpu
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda
+
+[anyValueSize(8)]
+interface IInterface
+{
+ int run(int input);
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
+RWStructuredBuffer<int> gOutputBuffer;
+
+struct Params
+{
+ IInterface values[2];
+};
+
+//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb
+ConstantBuffer<Params> gCb;
+
+//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb2
+ConstantBuffer<Params> gCb2;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ let tid = dispatchThreadID.x;
+
+ let inputVal : int = tid;
+ let outputVal = gCb.values[0].run(inputVal) + gCb2.values[0].run(inputVal);
+
+ gOutputBuffer[tid] = outputVal;
+}
+
+//TEST_INPUT: globalExistentialType MyImpl
+//TEST_INPUT: globalExistentialType __Dynamic
+
+// Type must be marked `public` to ensure it is visible in the generated DLL.
+public struct MyImpl : IInterface
+{
+ int val;
+ int run(int input)
+ {
+ return input + val;
+ }
+};