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: 3d38c9597f
("zink: hook up KHR_partial_update")
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30625>
This commit is contained in:

committed by
Marge Bot

parent
2260a4bbba
commit
a7f64c6203
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -1545,10 +1545,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;
|
||||
|
Reference in New Issue
Block a user