From 56db55c83d9162a2c8309b0018013227d62160b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Mon, 7 Jul 2025 14:52:15 +0200 Subject: [PATCH] panfrost: Disable AFBC tiled layout with driconf option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preventing the use of the AFBC tiled layout could be useful to further optimise memory usage when using AFBC packing. This commit introduces a new option to disable it through a driconf option. This is exposed as a new AFBC pan_afbc_tiled option (not tied to pan_force_afbc_packing) because it would otherwise imply a useless performance hit for the tiled to untiled conversion at packing time: there's no need to detile if the resource is created untiled in the first place. This could also be useful to compare the performance of the AFBC tiled and untiled layouts. Signed-off-by: Loïc Molinari Reviewed-by: Eric R. Smith Reviewed-by: Mary Guillemard Part-of: --- src/gallium/drivers/panfrost/driinfo_panfrost.h | 3 +++ src/gallium/drivers/panfrost/pan_resource.c | 8 ++++---- src/gallium/drivers/panfrost/pan_screen.c | 2 ++ src/gallium/drivers/panfrost/pan_screen.h | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/panfrost/driinfo_panfrost.h b/src/gallium/drivers/panfrost/driinfo_panfrost.h index 58723993916..1c61a0ce0f2 100644 --- a/src/gallium/drivers/panfrost/driinfo_panfrost.h +++ b/src/gallium/drivers/panfrost/driinfo_panfrost.h @@ -1,5 +1,8 @@ /* panfrost specific driconf options */ DRI_CONF_SECTION_PERFORMANCE + /* AFBC options. */ + DRI_CONF_OPT_B(pan_afbc_tiled, true, "Use AFBC tiled layout whenever " + "possible") DRI_CONF_OPT_B(pan_force_afbc_packing, false, "Use AFBC-P for textures") /* 2M chunks. */ diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 1562850269c..e641d3baabd 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -614,11 +614,11 @@ panfrost_should_afbc(struct panfrost_device *dev, * images that are at least 128x128. */ static bool -panfrost_should_tile_afbc(const struct panfrost_device *dev, +panfrost_should_tile_afbc(const struct panfrost_screen *screen, const struct panfrost_resource *pres) { - return pan_afbc_can_tile(dev->arch) && pres->base.width0 >= 128 && - pres->base.height0 >= 128 && !(dev->debug & PAN_DBG_FORCE_PACK); + return screen->afbc_tiled && pan_afbc_can_tile(screen->dev.arch) && + pres->base.width0 >= 128 && pres->base.height0 >= 128; } bool @@ -753,7 +753,7 @@ panfrost_best_modifier(struct pipe_screen *pscreen, if (pan_afbc_can_ytr(pres->base.format)) afbc |= AFBC_FORMAT_MOD_YTR; - if (panfrost_should_tile_afbc(dev, pres)) + if (panfrost_should_tile_afbc(screen, pres)) afbc |= AFBC_FORMAT_MOD_TILED | AFBC_FORMAT_MOD_SC; return DRM_FORMAT_MOD_ARM_AFBC(afbc); diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 97636764378..d57ea195eba 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -997,6 +997,8 @@ panfrost_create_screen(int fd, const struct pipe_screen_config *config, snprintf(screen->renderer_string, sizeof(screen->renderer_string), "%s (Panfrost)", dev->model->name); + screen->afbc_tiled = driQueryOptionb(config->options, "pan_afbc_tiled"); + screen->force_afbc_packing = dev->debug & PAN_DBG_FORCE_PACK; if (!screen->force_afbc_packing) screen->force_afbc_packing = driQueryOptionb(config->options, diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index ebad8a6ce35..4e39208b233 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -123,6 +123,10 @@ struct panfrost_screen { char renderer_string[100]; struct panfrost_vtable vtbl; struct disk_cache *disk_cache; + + /* Use AFBC tiled layout whenever possible */ + bool afbc_tiled; + unsigned max_afbc_packing_ratio; bool force_afbc_packing; bool allow_128bit_rts_v4;