From 3048d5da46112a2c6c312922ed3f024e14b8a79f Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 25 Jan 2019 08:08:01 -0800 Subject: Fixup handling of empty structs in function return types and parameters. (#796) * Fixup handling of empty structs in function return types and parameters. * Bug fix in legalizeFunc() * More comprehensive empty struct test * Fix `legalizeFieldExtract` for empty struct field. * Add empty struct handling for construct inst --- tests/compute/empty-struct2.slang | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/compute/empty-struct2.slang (limited to 'tests/compute/empty-struct2.slang') diff --git a/tests/compute/empty-struct2.slang b/tests/compute/empty-struct2.slang new file mode 100644 index 000000000..17cbb6ab4 --- /dev/null +++ b/tests/compute/empty-struct2.slang @@ -0,0 +1,52 @@ +//TEST(smoke,compute):COMPARE_COMPUTE: +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +// This is a basic test for Slang compute shader. + +RWStructuredBuffer outputBuffer; + +interface IInterface +{ + associatedtype T; + T getT(); + [mutating] + void setT(T val); +} +interface IEmptyS +{ + float emptyFunc(); +}; +struct EmptyS : IEmptyS +{ + float emptyFunc() {return 0.0;} +}; + +struct Empty : IInterface +{ + typedef TT T; + TT value; + float a; + TT getT() + { + return value; + } + [mutating] + void setT(TT val) + { + value = val; + a = value.emptyFunc(); + } +} + +void test(Obj obj) +{ + Obj.T v = obj.getT(); + obj.setT(v); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + Empty obj; + test(obj); + outputBuffer[dispatchThreadID.x] = dispatchThreadID.x; +} \ No newline at end of file -- cgit v1.2.3