zink: handle expired deferred fences more reasonably

now that there's some tracking for the last-finished batch id, this can
be used to detect when an application holds onto a sync object for way too long,
to the point that the sync object has expired so far into the past that we
no longer have any record of it existing

fixes things like unigine superposition

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9963>
This commit is contained in:
Mike Blumenkrantz
2021-03-16 15:21:16 -04:00
committed by Marge Bot
parent a4e34f40a3
commit 2d38fb7e61

View File

@@ -168,12 +168,17 @@ zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct
pctx = threaded_context_unwrap_sync(pctx); pctx = threaded_context_unwrap_sync(pctx);
struct zink_context *ctx = zink_context(pctx); struct zink_context *ctx = zink_context(pctx);
if (pctx && mfence->deferred_ctx == pctx && mfence->deferred_id == ctx->curr_batch) { if (pctx && mfence->deferred_ctx == pctx) {
zink_context(pctx)->batch.has_work = true; if (mfence->deferred_id == ctx->curr_batch) {
/* this must be the current batch */ zink_context(pctx)->batch.has_work = true;
pctx->flush(pctx, NULL, !timeout_ns ? PIPE_FLUSH_ASYNC : 0); /* this must be the current batch */
if (!timeout_ns) pctx->flush(pctx, NULL, !timeout_ns ? PIPE_FLUSH_ASYNC : 0);
return false; if (!timeout_ns)
return false;
}
/* this batch is known to have finished */
if (mfence->deferred_id <= screen->last_finished)
return true;
} }
/* need to ensure the tc mfence has been flushed before we wait */ /* need to ensure the tc mfence has been flushed before we wait */