summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/assoctype-complex.slang50
-rw-r--r--tests/compute/assoctype-complex.slang.expected.txt4
-rw-r--r--tests/compute/assoctype-simple.slang35
-rw-r--r--tests/compute/assoctype-simple.slang.expected.txt4
-rw-r--r--tests/compute/explicit-this-expr.slang2
-rw-r--r--tests/compute/generics-constructor.slang17
-rw-r--r--tests/compute/generics-constructor.slang.expected.txt4
-rw-r--r--tests/compute/implicit-this-expr.slang2
8 files changed, 116 insertions, 2 deletions
diff --git a/tests/compute/assoctype-complex.slang b/tests/compute/assoctype-complex.slang
new file mode 100644
index 000000000..fa7fc3b0f
--- /dev/null
+++ b/tests/compute/assoctype-complex.slang
@@ -0,0 +1,50 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+RWStructuredBuffer<int> outputBuffer;
+interface IBase
+{
+ associatedtype V;
+ V sub(V a0, V a1);
+}
+interface ISimple
+{
+ associatedtype U : IBase;
+ U.V add(U v0, U v1);
+}
+
+struct Val : IBase
+{
+ typedef int V;
+ int base;
+ V sub(V a0, V a1)
+ {
+ return a0 - a1 + base;
+ }
+};
+
+struct Simple : ISimple
+{
+ typedef Val U;
+ Val.V add(U v0, U v1)
+ {
+ return v0.sub(4, v1.sub(1,2));
+ }
+};
+
+__generic<T:ISimple>
+T.U.V test(T simple, T.U v0, T.U v1)
+{
+ return simple.add(v0, v1);
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ Simple s;
+ Val v0, v1;
+ v0.base = 1;
+ v1.base = 2;
+ int outVal = test<Simple>(s, v0, v1); // == 4.0
+ outputBuffer[dispatchThreadID.x] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/assoctype-complex.slang.expected.txt b/tests/compute/assoctype-complex.slang.expected.txt
new file mode 100644
index 000000000..e43ad329a
--- /dev/null
+++ b/tests/compute/assoctype-complex.slang.expected.txt
@@ -0,0 +1,4 @@
+4
+4
+4
+4 \ No newline at end of file
diff --git a/tests/compute/assoctype-simple.slang b/tests/compute/assoctype-simple.slang
new file mode 100644
index 000000000..0f160c9c0
--- /dev/null
+++ b/tests/compute/assoctype-simple.slang
@@ -0,0 +1,35 @@
+//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+// Confirm that generics syntax can be used in user
+// code and generates valid output.
+
+RWStructuredBuffer<float> outputBuffer;
+
+interface ISimple
+{
+ associatedtype U;
+ U add(U v0, U v1);
+}
+
+struct Simple : ISimple
+{
+ typedef float U;
+ U add(U v0, float v1)
+ {
+ return v0 + v1;
+ }
+};
+
+__generic<T:ISimple>
+T.U test(T simple, T.U v0, T.U v1)
+{
+ return simple.add(v0, v1);
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ Simple s;
+ float outVal = test<Simple>(s, 2.0, 1.0); // == 3.0
+ outputBuffer[dispatchThreadID.x] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/assoctype-simple.slang.expected.txt b/tests/compute/assoctype-simple.slang.expected.txt
new file mode 100644
index 000000000..e54af3bc8
--- /dev/null
+++ b/tests/compute/assoctype-simple.slang.expected.txt
@@ -0,0 +1,4 @@
+40400000
+40400000
+40400000
+40400000
diff --git a/tests/compute/explicit-this-expr.slang b/tests/compute/explicit-this-expr.slang
index 7bd8dff99..59ce64ed5 100644
--- a/tests/compute/explicit-this-expr.slang
+++ b/tests/compute/explicit-this-expr.slang
@@ -1,4 +1,4 @@
-//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
// Access fields of a `struct` type from within a "method" by
diff --git a/tests/compute/generics-constructor.slang b/tests/compute/generics-constructor.slang
new file mode 100644
index 000000000..47dc0272a
--- /dev/null
+++ b/tests/compute/generics-constructor.slang
@@ -0,0 +1,17 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+RWStructuredBuffer<float> outputBuffer;
+
+__generic<T:__BuiltinFloatingPointType>
+T test(T v0, T v1)
+{
+ return T(3.0);
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ float outVal = test<float>(1.0, 2.0);
+ outputBuffer[dispatchThreadID.x] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/generics-constructor.slang.expected.txt b/tests/compute/generics-constructor.slang.expected.txt
new file mode 100644
index 000000000..e54af3bc8
--- /dev/null
+++ b/tests/compute/generics-constructor.slang.expected.txt
@@ -0,0 +1,4 @@
+40400000
+40400000
+40400000
+40400000
diff --git a/tests/compute/implicit-this-expr.slang b/tests/compute/implicit-this-expr.slang
index 339c5fb6a..32cbd88fc 100644
--- a/tests/compute/implicit-this-expr.slang
+++ b/tests/compute/implicit-this-expr.slang
@@ -1,4 +1,4 @@
-//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
// Access fields of a `struct` type from within a "method" by