diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index ecc98138756..be9b07c5f7b 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -473,9 +473,6 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch) } #endif - if (!ctx->queries_disabled) - zink_resume_queries(ctx, 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)) zink_batch_bind_db(ctx); diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 125dbe8f062..d45bcedf9e8 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2747,6 +2747,10 @@ zink_batch_rp(struct zink_context *ctx) else clear_buffers = begin_rendering(ctx); 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) return; //dead swapchain or continued renderpass if (ctx->render_condition.query) @@ -2761,6 +2765,11 @@ zink_batch_no_rp(struct zink_context *ctx) return; if (ctx->render_condition.query) 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) zink_end_render_pass(ctx); else { diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index f82139482e7..b20c1a144d6 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -953,16 +953,13 @@ zink_begin_query(struct pipe_context *pctx, util_dynarray_clear(&query->starts); query->start_offset = 0; - /* A query must either begin and end inside the same subpass of a render pass - instance, or must both begin and end outside of a render pass instance - (i.e. contain entire render pass instances). - - 18.2. Query Operation - - * tilers prefer out-of-renderpass queries for perf reasons, so force all queries - * out of renderpasses - */ - zink_batch_no_rp(ctx); - begin_query(ctx, batch, query); + if (batch->in_rp) { + begin_query(ctx, batch, query); + } else { + /* never directly start queries out of renderpass, always defer */ + list_addtail(&query->active_list, &ctx->suspended_queries); + query->suspended = 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 */ threaded_context_unwrap_sync(pctx); - zink_batch_no_rp(ctx); if (list_is_linked(&query->stats_list)) list_delinit(&query->stats_list); @@ -1113,11 +1109,11 @@ suspend_query(struct zink_context *ctx, struct zink_query *query) } 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) { struct zink_query *query = (void*)entry->key; - if (query->suspended) + if (query->suspended || (rp_only && !query->started_in_rp)) continue; if (query->active && !is_time_query(query)) { /* 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 zink_suspend_queries(struct zink_context *ctx, struct zink_batch *batch) { - suspend_queries(ctx); + suspend_queries(ctx, false); } 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 zink_query_update_gs_states(struct zink_context *ctx) { diff --git a/src/gallium/drivers/zink/zink_query.h b/src/gallium/drivers/zink/zink_query.h index 717b6387495..c8a3c3353d1 100644 --- a/src/gallium/drivers/zink/zink_query.h +++ b/src/gallium/drivers/zink/zink_query.h @@ -38,6 +38,9 @@ zink_suspend_queries(struct zink_context *ctx, struct zink_batch *batch); void zink_resume_queries(struct zink_context *ctx, struct zink_batch *batch); +void +zink_query_renderpass_suspend(struct zink_context *ctx); + void zink_resume_cs_query(struct zink_context *ctx);