From 8daafcc2e4bf7b2dfb66d7a3b7ac60c86b2d926c Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 9 Jan 2018 10:50:44 -0800 Subject: bruteforce implementation of witness table resolution for associated (#358) --- tests/compute/assoctype-generic-arg.slang | 38 ++++++++++++++++++++++ .../assoctype-generic-arg.slang.expected.txt | 4 +++ tests/compute/assoctype-simple.slang | 6 ++-- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 tests/compute/assoctype-generic-arg.slang create mode 100644 tests/compute/assoctype-generic-arg.slang.expected.txt (limited to 'tests') 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 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 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.U test(T simple, T.U v0, T.U v1) { - return simple.add(v0, v1); + return simple.addt(v0, v1); } [numthreads(4, 1, 1)] -- cgit v1.2.3