From 7e327e5e31627ecb8747b0c9ecbdef5665d81132 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 16 Dec 2025 11:08:21 +0100 Subject: [PATCH] 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: 9ec6197a0b5 ("panfrost: allocate tile-buffer for dummy render-targets") Fixes: c15a43cce00 ("pan/lib: prepare for pixel local storage support") Reviewed-by: Boris Brezillon (cherry picked from commit 762fe6e9dce1b28186dd8df7d3d1aad03ba26508) Part-of: --- .pick_status.json | 2 +- src/panfrost/lib/pan_desc.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f80e0abc536..127050e4057 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index 4215d11d8b0..f2a31cfcfae 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -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;