From 5330d09931bafb8682965f8fe71d1d0ab3a6befd Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 16 Dec 2025 12:03:40 +0100 Subject: [PATCH] panfrost: factor out meat of pan_bytes_per_pixel_tib to helper We're going to have to do this from non arch-specific code, so let's factor the meat out into a helper so we don't need to repeat the logic. Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/pan_desc.c | 12 +----------- src/panfrost/lib/pan_format.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index 01c02ac6e60..3bdb4b71425 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -455,17 +455,7 @@ pan_bytes_per_pixel_tib(enum pipe_format format) { const struct pan_blendable_format *bf = GENX(pan_blendable_format_from_pipe_format)(format); - - if (bf->internal) { - /* Blendable formats are always 32-bits in the tile buffer, - * extra bits are used as padding or to dither */ - return 4; - } else { - /* Non-blendable formats are raw, rounded up to the nearest - * power-of-two size */ - unsigned bytes = util_format_get_blocksize(format); - return util_next_power_of_two(bytes); - } + return pan_format_tib_size(format, bf->internal); } static unsigned diff --git a/src/panfrost/lib/pan_format.h b/src/panfrost/lib/pan_format.h index fd19ebe8ac7..8fc6e40983f 100644 --- a/src/panfrost/lib/pan_format.h +++ b/src/panfrost/lib/pan_format.h @@ -129,6 +129,21 @@ pan_format_get_plane_blocksize(enum pipe_format format, unsigned plane_idx) } } +static inline unsigned +pan_format_tib_size(enum pipe_format format, bool internal) +{ + if (internal) { + /* Blendable formats are always 32-bits in the tile buffer, + * extra bits are used as padding or to dither */ + return 4; + } else { + /* Non-blendable formats are raw, rounded up to the nearest + * power-of-two size */ + unsigned bytes = util_format_get_blocksize(format); + return util_next_power_of_two(bytes); + } +} + typedef uint32_t mali_pixel_format; /* pan bind flags */