panfrost: do not over-estimate memory needed for dummy-rt

This matches better what we do in pan_emit_fbd, where we don't increase
the cbuf_offset variable for unused render-targets. This way we simply
make sure we *at least* can fit a dummy-RT (as per the HW spec), but
since we don't write to it we also don't need to give it dedicated
memory beyond that.

This also seemingly fixes a subtle bug where we don't deal with PLS if
there's no active render-targets.

Fixes: 9ec6197a0b ("panfrost: allocate tile-buffer for dummy render-targets")
Fixes: c15a43cce0 ("pan/lib: prepare for pixel local storage support")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
(cherry picked from commit 762fe6e9dc)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39003>
This commit is contained in:
Erik Faye-Lund 2025-12-16 11:08:21 +01:00 committed by Dylan Baker
parent 8f15e54119
commit 7e327e5e31
2 changed files with 10 additions and 13 deletions

View file

@ -54,7 +54,7 @@
"description": "panfrost: do not over-estimate memory needed for dummy-rt",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "9ec6197a0b553e2d6037d04a4eca68998021ba33",
"notes": null

View file

@ -470,23 +470,20 @@ pan_bytes_per_pixel_tib(enum pipe_format format)
static unsigned
pan_cbuf_bytes_per_pixel(const struct pan_fb_info *fb)
{
/* dummy/non-existent render-targets use RGBA8 UNORM, e.g 4 bytes */
const unsigned dummy_rt_size = 4 * fb->nr_samples;
bool need_dummy = false;
unsigned sum = 0;
if (!fb->rt_count) {
/* The HW needs at least one render-target */
return dummy_rt_size;
}
for (int cb = 0; cb < fb->rt_count; ++cb) {
unsigned rt_size = dummy_rt_size;
for (int cb = 0; cb < MAX2(fb->rt_count, 1); ++cb) {
const struct pan_image_view *rt = fb->rts[cb].view;
if (rt)
rt_size = pan_bytes_per_pixel_tib(rt->format) * rt->nr_samples;
sum += pan_bytes_per_pixel_tib(rt->format) * rt->nr_samples;
else
need_dummy = true;
}
sum += rt_size;
if (need_dummy) {
/* dummy/non-existent render-targets use RGBA8 UNORM, e.g 4 bytes */
sum = MAX2(sum, 4 * fb->nr_samples);
}
return sum;