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>
(cherry picked from commit f6f7715c58)
This commit is contained in:
Boris Brezillon 2024-01-23 16:13:05 +01:00 committed by Eric Engestrom
parent 73dcdc7a4e
commit d2094c1e1b
2 changed files with 14 additions and 1 deletions

View file

@ -54,7 +54,7 @@
"description": "panfrost: Clamp the render area to the damage region",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "ff3eada7eb4e4df0abe93ee76b77101f9d24e72c",
"notes": null

View file

@ -491,6 +491,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;