From 5a928f7563af8ed18617210b95208ea63c157e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Thu, 21 Sep 2023 11:19:23 -0400 Subject: [PATCH] panfrost: Add env variable for max AFBC packing ratio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `PAN_MAX_AFBC_PACKING_RATIO` variable. If the ratio (size of the packed resource) / (size of the sparse resource) * 100 is above that value, we don't care about packing it. Signed-off-by: Louis-Francis Ratté-Boulianne Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 6 +++--- src/gallium/drivers/panfrost/pan_screen.c | 4 ++++ src/gallium/drivers/panfrost/pan_screen.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 47448499f4d..ad19ad767b7 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1527,13 +1527,13 @@ panfrost_pack_afbc(struct panfrost_context *ctx, unsigned new_size = ALIGN_POT(total_size, 4096); // FIXME unsigned old_size = prsrc->image.data.bo->size; + unsigned ratio = 100 * new_size / old_size; - if (new_size == old_size) + if (ratio > screen->max_afbc_packing_ratio) return; if (dev->debug & PAN_DBG_PERF) { - printf("%i%%: %i KB -> %i KB\n", 100 * new_size / old_size, - old_size / 1024, new_size / 1024); + printf("%i%%: %i KB -> %i KB\n", ratio, old_size / 1024, new_size / 1024); } struct panfrost_bo *dst = diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index d4605df94bc..2b12dfa8a69 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -54,6 +54,8 @@ #include "pan_context.h" +#define DEFAULT_MAX_AFBC_PACKING_RATIO 90 + /* clang-format off */ static const struct debug_named_value panfrost_debug_options[] = { {"perf", PAN_DBG_PERF, "Enable performance warnings"}, @@ -840,6 +842,8 @@ panfrost_create_screen(int fd, const struct pipe_screen_config *config, /* Debug must be set first for pandecode to work correctly */ dev->debug = debug_get_flags_option("PAN_MESA_DEBUG", panfrost_debug_options, 0); + screen->max_afbc_packing_ratio = debug_get_num_option( + "PAN_MAX_AFBC_PACKING_RATIO", DEFAULT_MAX_AFBC_PACKING_RATIO); panfrost_open_device(screen, fd, dev); if (dev->debug & PAN_DBG_NO_AFBC) diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index 9c378d6a4a3..9ae94e619e5 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -124,6 +124,7 @@ struct panfrost_screen { struct panfrost_vtable vtbl; struct disk_cache *disk_cache; + unsigned max_afbc_packing_ratio; }; static inline struct panfrost_screen *