diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2024-08-12 13:10:00 -0400 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2024-08-14 11:52:50 +0200 |
commit | f6b2fe8455d6592309a6d8280fd3b09592055c5b (patch) | |
tree | 857856631cb02918354e1b26cb25535cfa92261e /src | |
parent | db297c6534e0d44bcbcbffdd7af4dbafa98639a8 (diff) |
zink: fix partial update handling
* the damage region was not being used correctly (this is a normal rect)
* use_damage was never unset at frame boundary
* original renderArea was never re-set
Fixes: 3d38c9597ff ("zink: hook up KHR_partial_update")
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30625>
(cherry picked from commit a7f64c62037eb33e97e0d4a0f9a27345baa8bcc3)
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/zink/zink_context.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/zink/zink_kopper.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/zink/zink_screen.c | 23 |
3 files changed, 28 insertions, 5 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 132b9fb7120..fc3ff90d76e 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2924,8 +2924,14 @@ begin_rendering(struct zink_context *ctx, bool check_msaa_expand) if (has_swapchain) { ASSERTED struct zink_resource *res = zink_resource(ctx->fb_state.cbufs[0]->texture); zink_render_fixup_swapchain(ctx); - if (res->use_damage) + if (res->use_damage) { ctx->dynamic_fb.info.renderArea = res->damage; + } else { + ctx->dynamic_fb.info.renderArea.offset.x = 0; + ctx->dynamic_fb.info.renderArea.offset.y = 0; + ctx->dynamic_fb.info.renderArea.extent.width = ctx->fb_state.width; + ctx->dynamic_fb.info.renderArea.extent.height = ctx->fb_state.height; + } /* clamp for late swapchain resize */ if (res->base.b.width0 < ctx->dynamic_fb.info.renderArea.extent.width) ctx->dynamic_fb.info.renderArea.extent.width = res->base.b.width0; diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index a564f38033d..7475bdd1bf8 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -887,6 +887,8 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res, kopper_present(cpi, screen, -1); } res->obj->indefinite_acquire = false; + res->use_damage = false; + memset(&res->damage, 0, sizeof(res->damage)); cdt->swapchain->images[res->obj->dt_idx].acquired = NULL; res->obj->dt_idx = UINT32_MAX; } diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 7ad8cc1ba2c..75e4997d4be 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1542,10 +1542,25 @@ zink_set_damage_region(struct pipe_screen *pscreen, struct pipe_resource *pres, for (unsigned i = 0; i < nrects; i++) { int y = pres->height0 - rects[i].y - rects[i].height; - res->damage.extent.width = MAX2(res->damage.extent.width, rects[i].x + rects[i].width); - res->damage.extent.height = MAX2(res->damage.extent.height, y + rects[i].height); - res->damage.offset.x = MIN2(res->damage.offset.x, rects[i].x); - res->damage.offset.y = MIN2(res->damage.offset.y, y); + /* convert back to coord-based rects to use coordinate calcs */ + struct u_rect currect = { + .x0 = res->damage.offset.x, + .y0 = res->damage.offset.y, + .x1 = res->damage.offset.x + res->damage.extent.width, + .y1 = res->damage.offset.y + res->damage.extent.height, + }; + struct u_rect newrect = { + .x0 = rects[i].x, + .y0 = y, + .x1 = rects[i].x + rects[i].width, + .y1 = y + rects[i].height, + }; + struct u_rect u; + u_rect_union(&u, &currect, &newrect); + res->damage.extent.width = u.y1 - u.y0; + res->damage.extent.height = u.x1 - u.x0; + res->damage.offset.x = u.x0; + res->damage.offset.y = u.y0; } res->use_damage = nrects > 0; |