From b3deec2001ea34e20e9a6af8ddf5cf3866cafac0 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:42:30 -0500 Subject: Eliminate empty struct on metal target (#6603) * Eliminate empty struct on metal target Close 6573. We previously disabled the type legalization for ParameterBlock on Metal, but Metal doesn't allow empty struct in the argument buffer which is mapped from ParameterBlock, so we will need legalizeEmptyTypes on Metal target. * update test * update function name --- tests/metal/empty-struct-remove.slang | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/metal/empty-struct-remove.slang (limited to 'tests') diff --git a/tests/metal/empty-struct-remove.slang b/tests/metal/empty-struct-remove.slang new file mode 100644 index 000000000..2d9ee436b --- /dev/null +++ b/tests/metal/empty-struct-remove.slang @@ -0,0 +1,33 @@ + +//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute -DMETAL +//TEST:SIMPLE(filecheck=METAL):-target metal -entry computeMain -stage compute -DMETAL + +// METAL-NOT: struct emptyStruct +struct emptyStruct +{ + void set(RWStructuredBuffer buffer, int value) {buffer[0] = value;} +} + + +struct MyStruct +{ + RWStructuredBuffer buffer; + int value; + void set() + { + e.set(buffer, value); + } + emptyStruct e; +} + +ParameterBlock param; + +// LIB: @computeMain +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain( + uint tid: SV_DispatchThreadID, +) +{ + param.set(); +} -- cgit v1.2.3