summaryrefslogtreecommitdiffstats
path: root/tests/compute/nested-generics2.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-13 13:17:02 -0800
committerGitHub <noreply@github.com>2018-01-13 13:17:02 -0800
commitd4dab2cd3a409411c2d7caed01fc02a0fd3e8450 (patch)
tree10c92df406a82e7a5eb24b56c17d9256a7183c44 /tests/compute/nested-generics2.slang
parentdf6eeb93c1718334779ae328db277cdf7a9d7b04 (diff)
parent4d2086f47e25aa4545df95ddfd260c8bc5aafdb2 (diff)
Merge pull request #364 from csyonghe/assoctype
Support nested generics
Diffstat (limited to 'tests/compute/nested-generics2.slang')
-rw-r--r--tests/compute/nested-generics2.slang43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/compute/nested-generics2.slang b/tests/compute/nested-generics2.slang
new file mode 100644
index 000000000..6a14c7678
--- /dev/null
+++ b/tests/compute/nested-generics2.slang
@@ -0,0 +1,43 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+// test specialization of nested generic functions
+
+RWStructuredBuffer<int> outputBuffer;
+
+interface IBRDF
+{
+ float getF();
+}
+
+interface ILight
+{
+ float illum<B:IBRDF>(B b);
+};
+
+struct B0 : IBRDF
+{
+ float getF() { return 1.0; }
+};
+
+struct L0 : ILight
+{
+ float illum<B:IBRDF>(B b) { return b.getF(); }
+};
+
+struct L1<L:ILight> : ILight
+{
+ L l;
+ float illum<BXX:IBRDF>(BXX bxx) { return l.illum<BXX>(bxx); }
+};
+
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ L1<L0> light;
+ B0 b0;
+ float outVal = light.illum<B0>(b0);
+ outputBuffer[tid] = int(outVal);
+} \ No newline at end of file