panfrost: Clamp the render area to the damage region

The render area clamping was lost during the transition to the FB
helpers. Restore the original logic so we can benefit from
EGL_KHR_partial_update on v4, and on v5 when only one damage
rectangle is passed.

Fixes: ff3eada7eb ("panfrost: Use the generic preload and FB helpers in the gallium driver")
Reported-by: Sjoerd Simons <sjoerd.simons@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Sjoerd Simons <sjoerd.simons@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27215>
This commit is contained in:
Boris Brezillon 2024-01-23 16:13:05 +01:00 committed by Marge Bot
parent 69d39dba42
commit f6f7715c58

View file

@ -493,6 +493,19 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch,
fb->rts[i].discard = !reserve && !(batch->resolve & mask);
/* Clamp the rendering area to the damage extent. The
* KHR_partial_update spec states that trying to render outside of
* the damage region is "undefined behavior", so we should be safe.
*/
if (!fb->rts[i].discard) {
fb->extent.minx = MAX2(fb->extent.minx, prsrc->damage.extent.minx);
fb->extent.miny = MAX2(fb->extent.miny, prsrc->damage.extent.miny);
fb->extent.maxx = MIN2(fb->extent.maxx, prsrc->damage.extent.maxx - 1);
fb->extent.maxy = MIN2(fb->extent.maxy, prsrc->damage.extent.maxy - 1);
assert(fb->extent.minx <= fb->extent.maxx);
assert(fb->extent.miny <= fb->extent.maxy);
}
rts[i].format = surf->format;
rts[i].dim = MALI_TEXTURE_DIMENSION_2D;
rts[i].last_level = rts[i].first_level = surf->u.tex.level;