From dbd3f9b6add05d8f553135770e45dd7d9c6e3c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Wed, 11 Feb 2026 08:31:39 +0100 Subject: [PATCH] pan/crc: Check CRC requirements in dedicated function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Loïc Molinari --- src/gallium/drivers/panfrost/pan_fb_preload.c | 2 +- src/panfrost/lib/pan_desc.c | 31 ++++++++++++------- src/panfrost/lib/pan_desc.h | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_fb_preload.c b/src/gallium/drivers/panfrost/pan_fb_preload.c index e534a69c8d1..46bf5388d9f 100644 --- a/src/gallium/drivers/panfrost/pan_fb_preload.c +++ b/src/gallium/drivers/panfrost/pan_fb_preload.c @@ -1197,7 +1197,7 @@ pan_preload_emit_pre_frame_dcd(struct pan_fb_preload_cache *cache, * write even clean tiles to make sure CRC data is updated. */ if (crc_rt >= 0) { bool *valid = fb->rts[crc_rt].crc_valid; - bool full = pan_fb_is_fully_covered(fb); + bool full = pan_fb_info_is_fully_covered(fb); if (full && !(*valid)) always_write = true; diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index ea2a65c3395..1d97609f012 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -93,17 +93,26 @@ pan_warn_on_afbc_reverse_issue_order(const struct pan_attachment_info *att, #endif static bool -renderblock_fits_in_single_pass(const struct pan_image_view *view, - unsigned tile_size) +pan_fb_color_attachment_should_crc(const struct pan_fb_color_attachment *rt, + unsigned tile_size) { - const struct pan_image_plane_ref pref = pan_image_view_get_first_plane(view); - uint64_t mod = pref.image->props.modifier; + uint64_t mod; + struct pan_image_block_size renderblk_sz; + + if (!rt->view || rt->discard || !pan_image_view_has_crc(rt->view)) + return false; + + mod = pan_image_view_get_first_plane(rt->view).image->props.modifier; if (!drm_is_afbc(mod)) return true; - struct pan_image_block_size renderblk_sz = pan_afbc_renderblock_size(mod); - return tile_size >= renderblk_sz.width * renderblk_sz.height; + /* AFBC render block size must fit in a single pass. */ + renderblk_sz = pan_afbc_renderblock_size(mod); + if (tile_size < renderblk_sz.width * renderblk_sz.height) + return false; + + return true; } int @@ -129,10 +138,8 @@ GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size) #endif for (unsigned i = 0; i < fb->rt_count; i++) { - /* Skip unusable RT. */ - if (!fb->rts[i].view || fb->rts[i].discard || - !pan_image_view_has_crc(fb->rts[i].view) || - !renderblock_fits_in_single_pass(fb->rts[i].view, tile_size)) + /* Skip unusable RTs. */ + if (!pan_fb_color_attachment_should_crc(&fb->rts[i], tile_size)) continue; /* Select the first RT with a valid CRC buffer. */ @@ -149,7 +156,7 @@ GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size) /* The selected RT must be fully covered for now in order to correctly * initialize the CRC buffer. */ if (best_rt != -1 && !*fb->rts[best_rt].crc_valid && - !pan_fb_is_fully_covered(fb)) + !pan_fb_info_is_fully_covered(fb)) best_rt = -1; return best_rt; @@ -1252,7 +1259,7 @@ GENX(pan_emit_fbd)(const struct pan_fb_info *fb, unsigned layer_idx, if (crc_rt >= 0) { bool *valid = fb->rts[crc_rt].crc_valid; - bool full = pan_fb_is_fully_covered(fb); + bool full = pan_fb_info_is_fully_covered(fb); /* If the CRC was valid it stays valid, if it wasn't, we must ensure * the render operation covers the full frame, and clean tiles are diff --git a/src/panfrost/lib/pan_desc.h b/src/panfrost/lib/pan_desc.h index a85ffbcc013..fddcfbae78a 100644 --- a/src/panfrost/lib/pan_desc.h +++ b/src/panfrost/lib/pan_desc.h @@ -163,7 +163,7 @@ struct pan_clean_tile { }; static inline bool -pan_fb_is_fully_covered(const struct pan_fb_info *fb) +pan_fb_info_is_fully_covered(const struct pan_fb_info *fb) { return !fb->draw_extent.minx && !fb->draw_extent.miny &&