From 9ec6197a0b553e2d6037d04a4eca68998021ba33 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 27 Mar 2025 09:10:16 +0100 Subject: [PATCH] panfrost: allocate tile-buffer for dummy render-targets There's two limitations we have to cater to: 1. The HW needs at least one render-target. We can disable write-back for it, but it needs to allocate tile-buffer space for it. 2. The HW can't have "holes" in the render-targets. In both of those cases, we already set up dummy RGBA8 UNORM as the format, and disable write-back. But we forgot to take this into account when calculating the tile buffer allocation. This makes what we program the HW to do consistent, meaning we don't end up smashing the tile-buffer space. We might be able to do something better by adjusting how we program these buffers, but let's leave that for later. Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/panfrost/lib/pan_desc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index c4ccd0320e7..53f9a6459da 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -354,15 +354,23 @@ 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; + 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; const struct pan_image_view *rt = fb->rts[cb].view; + if (rt) + rt_size = pan_bytes_per_pixel_tib(rt->format) * rt->nr_samples; - if (!rt) - continue; - - sum += pan_bytes_per_pixel_tib(rt->format) * rt->nr_samples; + sum += rt_size; } return sum;