summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-06-15 09:05:49 -0700
committerGitHub <noreply@github.com>2020-06-15 09:05:49 -0700
commit7e7425de730d7b3f4590c71111e22e5103b53200 (patch)
tree9cdaee6b9deb0a94e40526b698ae13a1dc88da36 /tests
parent04a81ab634ce058168f7e1554274bbeb34f3a3c5 (diff)
parent90444f8366255f274993ce4699738d9ab7cf4ee1 (diff)
Merge branch 'master' into glsl-loop
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/dynamic-generics-simple.slang36
-rw-r--r--tests/compute/dynamic-generics-simple.slang.expected.txt4
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/compute/dynamic-generics-simple.slang b/tests/compute/dynamic-generics-simple.slang
new file mode 100644
index 000000000..bb009204e
--- /dev/null
+++ b/tests/compute/dynamic-generics-simple.slang
@@ -0,0 +1,36 @@
+//TEST_IGNORE_FILE
+//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -allow-dynamic-code -xslang -dump-ir
+
+// Test basic dynamic dispatch code gen
+
+interface IInterface
+{
+ static int Compute(int inVal);
+};
+
+int GenericCompute<T:IInterface>(int inVal)
+{
+ return T.Compute(inVal);
+}
+
+struct Impl : IInterface
+{
+ static int Compute(int inVal) { return inVal * inVal; }
+};
+
+int test(int inVal)
+{
+ return GenericCompute<Impl>(inVal);
+}
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = outputBuffer[tid];
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/dynamic-generics-simple.slang.expected.txt b/tests/compute/dynamic-generics-simple.slang.expected.txt
new file mode 100644
index 000000000..bf72fb434
--- /dev/null
+++ b/tests/compute/dynamic-generics-simple.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+4
+9 \ No newline at end of file