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

View File

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

View File

@@ -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 {

View File

@@ -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)
{

View File

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