zink: track internal conditional render state

this allows no-oping redundant calls

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15018>
This commit is contained in:
Mike Blumenkrantz 2022-02-03 17:15:38 -05:00
parent db48dcb4f3
commit 082b42fbda
2 changed files with 6 additions and 4 deletions

View File

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

View File

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