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 *