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: 7c96e98975 ("zink: always start/stop/resume queries inside renderpasses")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22827>
(cherry picked from commit 2e3ce614b9)
This commit is contained in:
Mike Blumenkrantz 2023-05-03 10:39:55 -04:00 committed by Eric Engestrom
parent b21db0bb8d
commit 1aaef5b067
4 changed files with 18 additions and 2 deletions

View file

@ -787,7 +787,7 @@
"description": "zink: sync queries at the end of cmdbufs",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "7c96e989755029a21b78f9e9aaa00c7a3d267172"
},

View 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);

View file

@ -1102,8 +1102,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)
@ -1247,6 +1249,13 @@ zink_set_active_query_state(struct pipe_context *pctx, bool enable)
zink_resume_queries(ctx, batch);
}
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)
{

View file

@ -46,6 +46,8 @@ zink_resume_cs_query(struct zink_context *ctx);
void
zink_prune_query(struct zink_screen *screen, 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);