mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-19 15:48:19 +02:00
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>
|
||
|---|---|---|
| .. | ||
| test | ||
| common.xml | ||
| cs_builder.h | ||
| decode.c | ||
| decode.h | ||
| decode_common.c | ||
| decode_csf.c | ||
| decode_jm.c | ||
| gen_macros.h | ||
| gen_pack.py | ||
| meson.build | ||
| pan_pack_helpers.h | ||
| v4.xml | ||
| v5.xml | ||
| v6.xml | ||
| v7.xml | ||
| v9.xml | ||
| v10.xml | ||
| v12.xml | ||
| v13.xml | ||