From 10c0ffa7de111bd2c0096015bba5ca2110d03bc1 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 11 May 2018 09:15:04 -0700 Subject: Add test for associated type from global generic parameter (#561) Resolves #357 The example shader from that issue has been added as a test case, and works with the top-of-tree Slang compiler (most likely due to the changes introduced with the IR-level type system). --- tests/bugs/gh-357.slang | 38 ++++++++++++++++++++++++++++++++++++ tests/bugs/gh-357.slang.expected.txt | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 tests/bugs/gh-357.slang create mode 100644 tests/bugs/gh-357.slang.expected.txt (limited to 'tests') diff --git a/tests/bugs/gh-357.slang b/tests/bugs/gh-357.slang new file mode 100644 index 000000000..be2ba95ed --- /dev/null +++ b/tests/bugs/gh-357.slang @@ -0,0 +1,38 @@ +//TEST(compute):COMPARE_COMPUTE: +//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; +} diff --git a/tests/bugs/gh-357.slang.expected.txt b/tests/bugs/gh-357.slang.expected.txt new file mode 100644 index 000000000..cc5e55ab6 --- /dev/null +++ b/tests/bugs/gh-357.slang.expected.txt @@ -0,0 +1,4 @@ +3F800000 +3F800000 +3F800000 +3F800000 -- cgit v1.2.3