From 4bf983fb26ee5cdb6d9bdc3121d6e297a9fc210f Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 16 Jun 2025 13:33:22 +0200 Subject: [PATCH] pan/afbc: Add the pan_afbc_{super,render}block_size_el() helpers Those are just pan_afbc_{render,super}block_size_el() but with the size returned in number of elements instead of pixels. This is only relevant for YUV-formats whose block extent is bigger than one pixel. Signed-off-by: Boris Brezillon Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Eric R. Smith Tested-by: Eric R. Smith Part-of: --- src/panfrost/lib/pan_afbc.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/panfrost/lib/pan_afbc.h b/src/panfrost/lib/pan_afbc.h index 11fc5bcd5e3..97fbda9ef8f 100644 --- a/src/panfrost/lib/pan_afbc.h +++ b/src/panfrost/lib/pan_afbc.h @@ -127,6 +127,22 @@ pan_afbc_superblock_size(uint64_t modifier) } } +/* Same as pan_afbc_superblock_size_el() but counted in block elements + * instead of pixels. For anything non-YUV this is the same. */ +static inline struct pan_image_block_size +pan_afbc_superblock_size_el(enum pipe_format format, uint64_t modifier) +{ + struct pan_image_block_size sb_size_px = pan_afbc_superblock_size(modifier); + + assert(sb_size_px.width % util_format_get_blockwidth(format) == 0); + assert(sb_size_px.height % util_format_get_blockheight(format) == 0); + + return (struct pan_image_block_size){ + .width = sb_size_px.width / util_format_get_blockwidth(format), + .height = sb_size_px.height / util_format_get_blockheight(format), + }; +} + /* * Given an AFBC modifier, return the render size. */ @@ -142,6 +158,23 @@ pan_afbc_renderblock_size(uint64_t modifier) return blk_size; } + +/* Same as pan_afbc_renderblock_size() but counted in block elements + * instead of pixels. For anything non-YUV this is the same. */ +static inline struct pan_image_block_size +pan_afbc_renderblock_size_el(enum pipe_format format, uint64_t modifier) +{ + struct pan_image_block_size rb_size_px = pan_afbc_renderblock_size(modifier); + + assert(rb_size_px.width % util_format_get_blockwidth(format) == 0); + assert(rb_size_px.height % util_format_get_blockheight(format) == 0); + + return (struct pan_image_block_size){ + .width = rb_size_px.width / util_format_get_blockwidth(format), + .height = rb_size_px.height / util_format_get_blockheight(format), + }; +} + /* * Given an AFBC modifier, return the width of the superblock. */