From 082b42fbda231f54c366f44f3b263ba3a77d2cef Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 3 Feb 2022 17:15:38 -0500 Subject: [PATCH] zink: track internal conditional render state this allows no-oping redundant calls Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_context.h | 1 + src/gallium/drivers/zink/zink_query.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index 3b6d9c0bffe..97b1130e797 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -293,6 +293,7 @@ struct zink_context { struct { struct zink_query *query; bool inverted; + bool active; //this is the internal vk state } render_condition; struct pipe_resource *dummy_vertex_buffer; diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index eb3fc3d7f9c..d0f1e64abd1 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -882,7 +882,7 @@ zink_set_active_query_state(struct pipe_context *pctx, bool enable) void zink_start_conditional_render(struct zink_context *ctx) { - if (unlikely(!zink_screen(ctx->base.screen)->info.have_EXT_conditional_rendering)) + if (unlikely(!zink_screen(ctx->base.screen)->info.have_EXT_conditional_rendering) || ctx->render_condition.active) return; struct zink_batch *batch = &ctx->batch; VkConditionalRenderingFlagsEXT begin_flags = 0; @@ -894,6 +894,7 @@ zink_start_conditional_render(struct zink_context *ctx) begin_info.flags = begin_flags; VKCTX(CmdBeginConditionalRenderingEXT)(batch->state->cmdbuf, &begin_info); zink_batch_reference_resource_rw(batch, ctx->render_condition.query->predicate, false); + ctx->render_condition.active = true; } void @@ -901,9 +902,10 @@ zink_stop_conditional_render(struct zink_context *ctx) { struct zink_batch *batch = &ctx->batch; zink_clear_apply_conditionals(ctx); - if (unlikely(!zink_screen(ctx->base.screen)->info.have_EXT_conditional_rendering)) + if (unlikely(!zink_screen(ctx->base.screen)->info.have_EXT_conditional_rendering) || !ctx->render_condition.active) return; VKCTX(CmdEndConditionalRenderingEXT)(batch->state->cmdbuf); + ctx->render_condition.active = false; } bool @@ -935,8 +937,7 @@ zink_render_condition(struct pipe_context *pctx, /* force conditional clears if they exist */ if (ctx->clears_enabled && !ctx->batch.in_rp) zink_batch_rp(ctx); - if (ctx->batch.in_rp) - zink_stop_conditional_render(ctx); + zink_stop_conditional_render(ctx); ctx->render_condition_active = false; ctx->render_condition.query = NULL; return;