zink: rework flush_frontbuffer to always flush

previously this would no-op unacquired swapchains and then try to
execute a copy from the last-presented swapchain image to the current
image to avoid presenting garbage data

instead, just present garbage like the app requested

fixes #7165

Tested-By: Matti Hamalainen <ccr@tnsp.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18730>
This commit is contained in:
Mike Blumenkrantz
2022-09-21 09:07:35 -04:00
committed by Marge Bot
parent 758c559bc4
commit babf9474c4

View File

@@ -1496,12 +1496,21 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen,
struct zink_resource *res = zink_resource(pres);
struct zink_context *ctx = zink_context(pctx);
/* if the surface has never been acquired, there's nothing to present,
* so this is a no-op */
if (!zink_is_swapchain(res) || (!zink_kopper_acquired(res->obj->dt, res->obj->dt_idx) && res->obj->last_dt_idx == UINT32_MAX))
/* if the surface is no longer a swapchain, this is a no-op */
if (!zink_is_swapchain(res))
return;
ctx = zink_tc_context_unwrap(pctx);
if (!zink_kopper_acquired(res->obj->dt, res->obj->dt_idx)) {
/* swapbuffers to an undefined surface: acquire and present garbage */
zink_kopper_acquire(ctx, res, UINT64_MAX);
ctx->needs_present = res;
/* set batch usage to submit acquire semaphore */
zink_batch_resource_usage_set(&ctx->batch, res, true, false);
}
/* handle any outstanding acquire submits (not just from above) */
if (ctx->batch.swapchain || ctx->needs_present) {
ctx->batch.has_work = true;
pctx->flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME);
@@ -1511,15 +1520,9 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen,
}
}
if (zink_kopper_acquired(res->obj->dt, res->obj->dt_idx))
zink_kopper_present_queue(screen, res);
else {
assert(res->obj->last_dt_idx != UINT32_MAX);
if (!zink_kopper_last_present_eq(res->obj->dt, res->obj->last_dt_idx)) {
zink_kopper_acquire_readback(ctx, res);
zink_kopper_present_readback(ctx, res);
}
}
/* always verify that this was acquired */
assert(zink_kopper_acquired(res->obj->dt, res->obj->dt_idx));
zink_kopper_present_queue(screen, res);
}
bool