diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/assoctype-func-param.slang | 53 | ||||
| -rw-r--r-- | tests/compute/assoctype-func-param.slang.expected.txt | 4 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/compute/assoctype-func-param.slang b/tests/compute/assoctype-func-param.slang new file mode 100644 index 000000000..63acfb23a --- /dev/null +++ b/tests/compute/assoctype-func-param.slang @@ -0,0 +1,53 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +// Test type checking of associatedtype and typedef + +RWStructuredBuffer<float> outputBuffer; + +interface IBase +{ + associatedtype SubTypeT; + associatedtype RetT; + RetT getVal(SubTypeT t); + SubTypeT setVal(RetT v); +} + +struct SubType<T> +{ + T x; +}; + +struct GenStruct<T> : IBase +{ + typedef T RetT; + typedef SubType<RetT> SubTypeT; + SubTypeT setVal(T val) + { + SubTypeT rs; + rs.x = val; + return rs; + } + T getVal(SubTypeT v) + { + return v.x; + } +}; + +U.RetT test<U:IBase>(U.RetT val) +{ + U obj; + U.SubTypeT sb = obj.setVal(val); + return obj.getVal(sb); +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + float inVal = float(tid); + /* wrong error message for the following line */ + float outVal = test<GenStruct<float> >(inVal); + outputBuffer[tid] = outVal.x; +}
\ No newline at end of file diff --git a/tests/compute/assoctype-func-param.slang.expected.txt b/tests/compute/assoctype-func-param.slang.expected.txt new file mode 100644 index 000000000..98798bd61 --- /dev/null +++ b/tests/compute/assoctype-func-param.slang.expected.txt @@ -0,0 +1,4 @@ +0 +3F800000 +40000000 +40400000
\ No newline at end of file |
