zink: sync queries at the end of cmdbufs
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 3 May 2023 14:39:55 +0000 (10:39 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 3 May 2023 20:08:07 +0000 (20:08 +0000)
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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22827>

src/gallium/drivers/zink/zink_batch.c
src/gallium/drivers/zink/zink_query.c
src/gallium/drivers/zink/zink_query.h

index 440a585..a8e279b 100644 (file)
@@ -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);
index 59bc575..be30126 100644 (file)
@@ -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)
index 19229a8..ca34660 100644 (file)
@@ -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);