zink: always start/stop/resume queries inside renderpasses

this avoids potentially splitting renderpasses by ensuring that
all (non-cs) query operations always occur inside renderpasses

zink_query_update_gs_states() now has to be called inside renderpass
to catch the active queries

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21534>
This commit is contained in:
Mike Blumenkrantz
2023-02-22 15:19:33 -05:00
committed by Marge Bot
parent cbbc7c98c4
commit 7c96e98975
4 changed files with 28 additions and 17 deletions
-3
View File
@@ -473,9 +473,6 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
} }
#endif #endif
if (!ctx->queries_disabled)
zink_resume_queries(ctx, batch);
/* descriptor buffers must always be bound at the start of a batch */ /* descriptor buffers must always be bound at the start of a batch */
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY)) if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY))
zink_batch_bind_db(ctx); zink_batch_bind_db(ctx);
+9
View File
@@ -2747,6 +2747,10 @@ zink_batch_rp(struct zink_context *ctx)
else else
clear_buffers = begin_rendering(ctx); clear_buffers = begin_rendering(ctx);
assert(!ctx->rp_changed); assert(!ctx->rp_changed);
if (!ctx->queries_disabled) {
zink_resume_queries(ctx, &ctx->batch);
zink_query_update_gs_states(ctx);
}
if (in_rp || !ctx->batch.in_rp) if (in_rp || !ctx->batch.in_rp)
return; //dead swapchain or continued renderpass return; //dead swapchain or continued renderpass
if (ctx->render_condition.query) if (ctx->render_condition.query)
@@ -2761,6 +2765,11 @@ zink_batch_no_rp(struct zink_context *ctx)
return; return;
if (ctx->render_condition.query) if (ctx->render_condition.query)
zink_stop_conditional_render(ctx); zink_stop_conditional_render(ctx);
/* suspend all queries that were started in a renderpass
* they can then be resumed upon beginning a new renderpass
*/
if (!ctx->queries_disabled)
zink_query_renderpass_suspend(ctx);
if (ctx->gfx_pipeline_state.render_pass) if (ctx->gfx_pipeline_state.render_pass)
zink_end_render_pass(ctx); zink_end_render_pass(ctx);
else { else {
+16 -14
View File
@@ -953,16 +953,13 @@ zink_begin_query(struct pipe_context *pctx,
util_dynarray_clear(&query->starts); util_dynarray_clear(&query->starts);
query->start_offset = 0; query->start_offset = 0;
/* A query must either begin and end inside the same subpass of a render pass if (batch->in_rp) {
instance, or must both begin and end outside of a render pass instance begin_query(ctx, batch, query);
(i.e. contain entire render pass instances). } else {
- 18.2. Query Operation /* never directly start queries out of renderpass, always defer */
list_addtail(&query->active_list, &ctx->suspended_queries);
* tilers prefer out-of-renderpass queries for perf reasons, so force all queries query->suspended = true;
* out of renderpasses }
*/
zink_batch_no_rp(ctx);
begin_query(ctx, batch, query);
return true; return true;
} }
@@ -1041,7 +1038,6 @@ zink_end_query(struct pipe_context *pctx,
/* FIXME: this can be called from a thread, but it needs to write to the cmdbuf */ /* FIXME: this can be called from a thread, but it needs to write to the cmdbuf */
threaded_context_unwrap_sync(pctx); threaded_context_unwrap_sync(pctx);
zink_batch_no_rp(ctx);
if (list_is_linked(&query->stats_list)) if (list_is_linked(&query->stats_list))
list_delinit(&query->stats_list); list_delinit(&query->stats_list);
@@ -1113,11 +1109,11 @@ suspend_query(struct zink_context *ctx, struct zink_query *query)
} }
static void static void
suspend_queries(struct zink_context *ctx) suspend_queries(struct zink_context *ctx, bool rp_only)
{ {
set_foreach(&ctx->batch.state->active_queries, entry) { set_foreach(&ctx->batch.state->active_queries, entry) {
struct zink_query *query = (void*)entry->key; struct zink_query *query = (void*)entry->key;
if (query->suspended) if (query->suspended || (rp_only && !query->started_in_rp))
continue; continue;
if (query->active && !is_time_query(query)) { if (query->active && !is_time_query(query)) {
/* the fence is going to steal the set off the batch, so we have to copy /* the fence is going to steal the set off the batch, so we have to copy
@@ -1133,7 +1129,7 @@ suspend_queries(struct zink_context *ctx)
void void
zink_suspend_queries(struct zink_context *ctx, struct zink_batch *batch) zink_suspend_queries(struct zink_context *ctx, struct zink_batch *batch)
{ {
suspend_queries(ctx); suspend_queries(ctx, false);
} }
void void
@@ -1162,6 +1158,12 @@ zink_resume_cs_query(struct zink_context *ctx)
} }
} }
void
zink_query_renderpass_suspend(struct zink_context *ctx)
{
suspend_queries(ctx, true);
}
void void
zink_query_update_gs_states(struct zink_context *ctx) zink_query_update_gs_states(struct zink_context *ctx)
{ {
+3
View File
@@ -38,6 +38,9 @@ zink_suspend_queries(struct zink_context *ctx, struct zink_batch *batch);
void void
zink_resume_queries(struct zink_context *ctx, struct zink_batch *batch); zink_resume_queries(struct zink_context *ctx, struct zink_batch *batch);
void
zink_query_renderpass_suspend(struct zink_context *ctx);
void void
zink_resume_cs_query(struct zink_context *ctx); zink_resume_cs_query(struct zink_context *ctx);