From b965adc60f2db863980a104953437e40684449f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Tue, 10 Feb 2026 13:04:57 +0100 Subject: [PATCH] pan/crc: Restrict CRC buffer creation to 1st RT mipmap level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restrict the creation of a CRC buffer for an image to the 1st mipmap level. At emit_fbd() time, Transation Elimination is only enabled if CRC is enabled for the selected RT and if its first configured level is 0. This was previously enforced at the Gallium driver level but it needs to be done at the lib level to later support PanVK too. Signed-off-by: Loïc Molinari --- src/gallium/drivers/panfrost/pan_resource.c | 2 +- src/panfrost/lib/pan_image.h | 3 ++- src/panfrost/lib/pan_layout.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index d924c3c6cdd..bc1ca6be1ac 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -830,7 +830,7 @@ panfrost_should_checksum(const struct panfrost_device *dev, return pres->base.bind & PIPE_BIND_RENDER_TARGET && panfrost_is_2d(pres) && bytes_per_pixel <= bytes_per_pixel_max && - pres->base.last_level == 0 && !(dev->debug & PAN_DBG_NO_CRC); + !(dev->debug & PAN_DBG_NO_CRC); } static bool diff --git a/src/panfrost/lib/pan_image.h b/src/panfrost/lib/pan_image.h index 1f9a0db2ec1..e2a1a2a3500 100644 --- a/src/panfrost/lib/pan_image.h +++ b/src/panfrost/lib/pan_image.h @@ -146,7 +146,8 @@ pan_image_view_has_crc(const struct pan_image_view *iview) if (!p.image) return false; - return p.image->props.crc; + /* Only mip level 0 gets a CRC buffer allocated. */ + return p.image->props.crc && iview->first_level == 0; } static inline struct pan_image_plane_ref diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c index 67a47e65e06..b0114493623 100644 --- a/src/panfrost/lib/pan_layout.c +++ b/src/panfrost/lib/pan_layout.c @@ -125,8 +125,8 @@ pan_image_layout_init( layout_constraints.offset_B += slayout->size_B; - /* Add a checksum region if necessary */ - if (props->crc) { + /* Add a CRC buffer at level 0 if necessary */ + if (l == 0 && props->crc) { init_slice_crc_info(arch, slayout, mip_extent_px.width, mip_extent_px.height, layout_constraints.offset_B); layout_constraints.offset_B += slayout->crc.size_B;