From c1bf22b56f25a531ac3bb8ccc35c2918f0e06f54 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 16 Dec 2025 12:12:47 +0100 Subject: [PATCH] panfrost: do not over-estimate format tib-size While the MAX2 thing here is correct for some formats, it's not correct for all; for instance R8_SNORM doesn't need 32-bits here. This should enable some higersample-counts on some 8 and 16-bit formats on some Mali GPUs. Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_screen.c | 4 +++- src/panfrost/lib/pan_props.h | 7 ------- src/panfrost/vulkan/panvk_physical_device.c | 5 ++++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 39c67fc8617..c5894a83124 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -145,7 +145,9 @@ get_max_msaa(struct panfrost_device *dev, enum pipe_format format) { unsigned max_tib_size = pan_query_tib_size(dev->model); unsigned max_cbuf_atts = pan_get_max_cbufs(dev->arch, max_tib_size); - unsigned format_size = util_format_get_blocksize(format); + + unsigned format_size = + pan_format_tib_size(format, dev->blendable_formats[format].internal); unsigned max_msaa = pan_get_max_msaa(dev->arch, max_tib_size, max_cbuf_atts, format_size); diff --git a/src/panfrost/lib/pan_props.h b/src/panfrost/lib/pan_props.h index 36e2871df19..51158bb3ee0 100644 --- a/src/panfrost/lib/pan_props.h +++ b/src/panfrost/lib/pan_props.h @@ -144,13 +144,6 @@ pan_get_max_msaa(unsigned arch, unsigned max_tib_size, unsigned max_cbuf_atts, assert(max_cbuf_atts > 0); assert(format_size > 0); - /* When using an internal format with less than 32-bit per pixels, we're - * currently using either AU (Additional precision, Unorm) or PU (Padded - * precision, Unorm), meaning that we need additional bits in the tilebuffer - * that's used by dithering. - */ - format_size = MAX2(format_size, 4); - const unsigned min_tile_size = 4 * 4; unsigned max_msaa = max_tib_size / (max_cbuf_atts * format_size * min_tile_size); diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index 90cfa20c4d2..99eddf724d2 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -834,7 +834,10 @@ get_image_format_sample_counts(struct panvk_physical_device *physical_device, unsigned max_cbuf_atts = pan_get_max_cbufs(arch, max_tib_size); assert(!vk_format_is_compressed(format)); - unsigned format_size = vk_format_get_blocksize(format); + + enum pipe_format pfmt = vk_format_to_pipe_format(format); + unsigned format_size = + pan_format_tib_size(pfmt, physical_device->formats.blendable[pfmt].internal); return panvk_get_sample_counts(arch, max_tib_size, max_cbuf_atts, format_size);