pan/genxml: Add pan_pack_nodefaults()

The new packing macro will not default initialize fields, which is
useful for structures used as override flags or in pan_merge().

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11506
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31041>
This commit is contained in:
Lars-Ivar Hesselberg Simonsen 2024-09-10 16:14:03 +02:00 committed by Marge Bot
parent 03c470d2ab
commit 5fd523fafb
2 changed files with 8 additions and 0 deletions

View file

@ -68,6 +68,7 @@ ForEachMacros: [
'pan_foreach_predecessor',
'pan_foreach_successor',
'pan_pack',
'pan_pack_nodefaults',
'pan_section_pack',
'panvk_cs_reg_upd_ctx',
]

View file

@ -125,6 +125,13 @@ __gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
({ PREFIX2(T, pack)((uint32_t *) (dst), &name); \\
_loop_terminate = NULL; }))
#define pan_pack_nodefaults(dst, T, name) \\
for (struct PREFIX1(T) name = { 0 }, \\
*_loop_terminate = &name; \\
__builtin_expect(_loop_terminate != NULL, 1); \\
({ PREFIX2(T, pack)((uint32_t *) (dst), &name); \\
_loop_terminate = NULL; }))
#define pan_unpack(src, T, name) \\
struct PREFIX1(T) name; \\
PREFIX2(T, unpack)((uint8_t *)(src), &name)