panfrost: Disable AFBC tiled layout with driconf option

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 <loic.molinari@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35001>
This commit is contained in:
Loïc Molinari
2025-07-07 14:52:15 +02:00
committed by Marge Bot
parent 98c8c95755
commit 56db55c83d
4 changed files with 13 additions and 4 deletions
@@ -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. */
+4 -4
View File
@@ -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);
@@ -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,
@@ -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;