From 2e3ce614b9e4c307f233aac5deaf2b623a0f0fab Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 3 May 2023 10:39:55 -0400 Subject: [PATCH] zink: sync queries at the end of cmdbufs with tc, query results can be fetched async, and it's impossible to sync tc in this scenario. to avoid needing to sync when a sync is not possible, sync ahead of time in all cases Fixes: 7c96e989755 ("zink: always start/stop/resume queries inside renderpasses") Part-of: --- src/gallium/drivers/zink/zink_batch.c | 5 +++++ src/gallium/drivers/zink/zink_query.c | 11 ++++++++++- src/gallium/drivers/zink/zink_query.h | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 440a585..a8e279b 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -684,6 +684,11 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch) if (screen->device_lost) return; + if (ctx->tc) { + set_foreach(&bs->active_queries, entry) + zink_query_sync(ctx, (void*)entry->key); + } + if (screen->threaded_submit) { util_queue_add_job(&screen->flush_queue, bs, &bs->flush_completed, submit_queue, post_submit, 0); diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index 59bc575..be30126 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -1106,8 +1106,10 @@ zink_get_query_result(struct pipe_context *pctx, return result->b; } - if (query->needs_update) + if (query->needs_update) { + assert(!ctx->tc || !threaded_query(q)->flushed); update_qbo(ctx, query); + } if (zink_batch_usage_is_unflushed(query->batch_uses)) { if (!threaded_query(q)->flushed) @@ -1252,6 +1254,13 @@ zink_set_active_query_state(struct pipe_context *pctx, bool enable) } void +zink_query_sync(struct zink_context *ctx, struct zink_query *query) +{ + if (query->needs_update) + update_qbo(ctx, query); +} + +void zink_start_conditional_render(struct zink_context *ctx) { if (unlikely(!zink_screen(ctx->base.screen)->info.have_EXT_conditional_rendering) || ctx->render_condition.active) diff --git a/src/gallium/drivers/zink/zink_query.h b/src/gallium/drivers/zink/zink_query.h index 19229a8..ca34660 100644 --- a/src/gallium/drivers/zink/zink_query.h +++ b/src/gallium/drivers/zink/zink_query.h @@ -46,6 +46,8 @@ zink_resume_cs_query(struct zink_context *ctx); void zink_prune_query(struct zink_batch_state *bs, struct zink_query *query); +void +zink_query_sync(struct zink_context *ctx, struct zink_query *query); void zink_query_update_gs_states(struct zink_context *ctx); -- 2.7.4