pan/lib: clamp format size to 4

When using formats with less than 32-bits per pixel, we pad the
tile-buffer to a multiple of 32-bits so we can store additional bits
used by dithering.

Account for this when computing the max MSAA setting.

Fixes: 329568b5eb ("panfrost: add color-attachment and msaa helpers")
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35755>
(cherry picked from commit 6a83193771)
This commit is contained in:
Erik Faye-Lund 2025-06-26 10:48:51 +02:00 committed by Eric Engestrom
parent 302b94f315
commit 570ecdc9ac
2 changed files with 9 additions and 1 deletions

View file

@ -564,7 +564,7 @@
"description": "pan/lib: clamp format size to 4",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "329568b5ebdca3ed98b5197073e3cd1018939927",
"notes": null

View file

@ -195,6 +195,14 @@ 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 = arch >= 5 ? 4 * 4 : 16 * 16;
unsigned max_msaa = max_tib_size / (max_cbuf_atts * format_size *
min_tile_size);