summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-09 10:50:44 -0800
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-01-09 10:50:44 -0800
commit8daafcc2e4bf7b2dfb66d7a3b7ac60c86b2d926c (patch)
treeb7fac301e3c4d1b006af70584feeb45af191aab6 /tests
parent3d435f7321c3f9241d33a0f7521573f21b548186 (diff)
bruteforce implementation of witness table resolution for associated (#358)
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/assoctype-generic-arg.slang38
-rw-r--r--tests/compute/assoctype-generic-arg.slang.expected.txt4
-rw-r--r--tests/compute/assoctype-simple.slang6
3 files changed, 45 insertions, 3 deletions
diff --git a/tests/compute/assoctype-generic-arg.slang b/tests/compute/assoctype-generic-arg.slang
new file mode 100644
index 000000000..78c54ec37
--- /dev/null
+++ b/tests/compute/assoctype-generic-arg.slang
@@ -0,0 +1,38 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+//TEST_INPUT:type AssocImpl
+
+
+RWStructuredBuffer<float> outputBuffer;
+
+interface IBase
+{
+ float getVal();
+};
+
+interface IAssoc
+{
+ associatedtype TBase : IBase;
+};
+
+struct BaseImpl : IBase
+{
+ float getVal() { return 1.0; }
+};
+
+struct AssocImpl : IAssoc
+{
+ typedef BaseImpl TBase;
+};
+
+__generic_param T : IAssoc;
+
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ T.TBase base;
+ float rs = base.getVal();
+ outputBuffer[tid] = rs;
+} \ No newline at end of file
diff --git a/tests/compute/assoctype-generic-arg.slang.expected.txt b/tests/compute/assoctype-generic-arg.slang.expected.txt
new file mode 100644
index 000000000..e143b7f20
--- /dev/null
+++ b/tests/compute/assoctype-generic-arg.slang.expected.txt
@@ -0,0 +1,4 @@
+3F800000
+3F800000
+3F800000
+3F800000 \ No newline at end of file
diff --git a/tests/compute/assoctype-simple.slang b/tests/compute/assoctype-simple.slang
index 0f160c9c0..b14529064 100644
--- a/tests/compute/assoctype-simple.slang
+++ b/tests/compute/assoctype-simple.slang
@@ -8,13 +8,13 @@ RWStructuredBuffer<float> outputBuffer;
interface ISimple
{
associatedtype U;
- U add(U v0, U v1);
+ U addt(U v0, U v1);
}
struct Simple : ISimple
{
typedef float U;
- U add(U v0, float v1)
+ U addt(U v0, float v1)
{
return v0 + v1;
}
@@ -23,7 +23,7 @@ struct Simple : ISimple
__generic<T:ISimple>
T.U test(T simple, T.U v0, T.U v1)
{
- return simple.add(v0, v1);
+ return simple.addt(v0, v1);
}
[numthreads(4, 1, 1)]