From 39df394ffed5cc45057499be5b2c3fa6de796844 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 31 Aug 2021 16:01:49 -0400 Subject: [PATCH] zink: split out stalling from fence-waiting function stall and flush+stall are not the same; in some cases, the driver must only stall and never flush, so ensure that this is possible to avoid infinite recursion fixes Metro Last Light: Redux benchmark mode Fixes: d8905446d65 ("zink: rework oom flushing") Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_context.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 5e74a63ff55..0972769015f 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -1899,6 +1899,14 @@ zink_update_descriptor_refs(struct zink_context *ctx, bool compute) } } +static void +stall(struct zink_context *ctx) +{ + sync_flush(ctx, zink_batch_state(ctx->last_fence)); + zink_vkfence_wait(zink_screen(ctx->base.screen), ctx->last_fence, PIPE_TIMEOUT_INFINITE); + zink_batch_reset_all(ctx); +} + static void flush_batch(struct zink_context *ctx, bool sync) { @@ -1924,7 +1932,7 @@ flush_batch(struct zink_context *ctx, bool sync) zink_select_launch_grid(ctx); if (ctx->oom_stall) - zink_fence_wait(&ctx->base); + stall(ctx); ctx->oom_flush = false; ctx->oom_stall = false; } @@ -2592,11 +2600,8 @@ zink_fence_wait(struct pipe_context *pctx) if (ctx->batch.has_work) pctx->flush(pctx, NULL, PIPE_FLUSH_HINT_FINISH); - if (ctx->last_fence) { - sync_flush(ctx, zink_batch_state(ctx->last_fence)); - zink_vkfence_wait(zink_screen(ctx->base.screen), ctx->last_fence, PIPE_TIMEOUT_INFINITE); - zink_batch_reset_all(ctx); - } + if (ctx->last_fence) + stall(ctx); } void