panfrost: Add env variable for max AFBC packing ratio

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 <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
This commit is contained in:
Louis-Francis Ratté-Boulianne 2023-09-21 11:19:23 -04:00 committed by Marge Bot
parent 888d7c8ee6
commit 5a928f7563
3 changed files with 8 additions and 3 deletions

View file

@ -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 =

View file

@ -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)

View file

@ -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 *