summaryrefslogtreecommitdiff
path: root/tests/compute/globalTypeParamArrayShared.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-21 10:48:31 -0800
committerGitHub <noreply@github.com>2018-01-21 10:48:31 -0800
commit4044a1d3a0605198465a7eb6e0e3c1f8b1a3c298 (patch)
tree62927d4d2722b36c8e7eb4060e741b9032686835 /tests/compute/globalTypeParamArrayShared.slang
parent2079b941bc5849b6ab33774fb90cefe9c2d624cb (diff)
parentf681a1505c98995683a7fbae7ce208dc5e444b9b (diff)
Merge pull request #372 from csyonghe/master
Allow type expression as type argument, fix global param enum order
Diffstat (limited to 'tests/compute/globalTypeParamArrayShared.slang')
-rw-r--r--tests/compute/globalTypeParamArrayShared.slang32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/compute/globalTypeParamArrayShared.slang b/tests/compute/globalTypeParamArrayShared.slang
new file mode 100644
index 000000000..ee3caa372
--- /dev/null
+++ b/tests/compute/globalTypeParamArrayShared.slang
@@ -0,0 +1,32 @@
+//TEST_IGNORE_FILE:
+interface IBase
+{
+ float compute<T>(T g);
+}
+struct Base:IBase
+{
+ float b;
+ float compute<T>(T g) { return b; }
+};
+
+struct Pair<T1:IBase, T2:IBase> : IBase
+{
+ T1 head;
+ T2 tail;
+ float compute<T>(T g)
+ {
+ return head.compute(g) + tail.compute(g);
+ }
+};
+
+struct Arr<T:IBase, let N:int> : IBase
+{
+ T base[N]; // = 1.0
+ float compute<T>(T g)
+ {
+ float sum = 0.0;
+ for (int i = 0; i < N; i++)
+ sum += base[i].compute(g);
+ return sum;
+ }
+};