mesa/src/panfrost/genxml
Faith Ekstrand eb2a1063c1 pan/genxml: Make sections more typesafe
Right now, we have this concept of sections where one packet can be
broken up into multiple sub-packets.  Currently, we handle ths by every
packet's `_packed` struct is just an array of `uint32_t` and we do
pointer math and cast to get at the subset of the `uint32_t` array
belonging to the given section.  This works okay if we're operating on
`void *` but it blows up on strict aliasing rules if we're ever trying
to pack sections into a `struct foo_packed` on the stack.

To work around this, make it so that anything with sections emits
something like this:

    struct foo_packed {
       union {
          uint32_t packed[N];
          struct {
             struct foo_sec1_packed sec1;
             struct foo_sec2_packed sec2;
          };
       };
    };

This is entirely safe because C allows unions and structs to overlap as
long as the members that have the same base type end up on top of each
other.  Since everything is a `uint32_t` internally, this is safe
according to the C pointer rules.  And now that everything is a
substruct, everything is nicely named and we can easily get to sections
without pointer magic.

Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39759>
2026-02-23 21:00:15 +00:00
..
test pan/cs: Don't leak builder resources 2025-12-16 11:02:15 +01:00
common.xml pan/genxml: Add lisence blocks to the XML files 2026-01-20 20:49:33 +00:00
cs_builder.h panfrost: SPDX everything 2026-01-20 20:49:33 +00:00
decode.c pan/genxml: add interleaved 64k clump ordering and block format 2026-01-29 16:33:43 +00:00
decode.h panfrost: SPDX everything 2026-01-20 20:49:33 +00:00
decode_common.c pan/genxml: make pandecode comparisons return -1,1 2026-02-10 13:53:51 +00:00
decode_csf.c panfrost: SPDX everything 2026-01-20 20:49:33 +00:00
decode_jm.c pan/decode/jm: IDVS decode improvements 2026-01-30 15:37:38 +00:00
gen_macros.h panfrost: SPDX everything 2026-01-20 20:49:33 +00:00
gen_pack.py pan/genxml: Make sections more typesafe 2026-02-23 21:00:15 +00:00
meson.build panfrost/meson: drop invalid C-only -Wno-override-init from C++ args 2025-07-04 13:03:46 +00:00
pan_pack_helpers.h pan/genxml: Make sections more typesafe 2026-02-23 21:00:15 +00:00
v4.xml pan/genxml: Add lisence blocks to the XML files 2026-01-20 20:49:33 +00:00
v5.xml pan/genxml: Add lisence blocks to the XML files 2026-01-20 20:49:33 +00:00
v6.xml panfrost: Update clean_pixel_write_enable flag name for v6+ 2026-02-04 10:49:37 +01:00
v7.xml panfrost: Update clean_pixel_write_enable flag name for v6+ 2026-02-04 10:49:37 +01:00
v9.xml panfrost: Update clean_pixel_write_enable flag name for v6+ 2026-02-04 10:49:37 +01:00
v10.xml panfrost: Update clean_pixel_write_enable flag name for v6+ 2026-02-04 10:49:37 +01:00
v12.xml panfrost: Update clean_pixel_write_enable flag name for v6+ 2026-02-04 10:49:37 +01:00
v13.xml pan/genxml/v13: Add HSR operation enums 2026-02-16 12:25:14 +00:00