Module: Mesa Branch: main Commit: 5d94887f0885e66d112d287045d3efd6d46b4229 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d94887f0885e66d112d287045d3efd6d46b4229
Author: Mike Blumenkrantz <[email protected]> Date: Mon Mar 13 08:19:33 2023 -0400 zink: add and use a function for "safely" ending renderpasses these are all points at which a renderpass should be split, so make sure renderpass data isn't reset in any way here Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21800> --- src/gallium/drivers/zink/zink_context.c | 33 ++++++++++++++++++----------- src/gallium/drivers/zink/zink_context.h | 2 ++ src/gallium/drivers/zink/zink_render_pass.c | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 007c03e8b9c..56ede69c621 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2671,7 +2671,7 @@ begin_rendering(struct zink_context *ctx) bool rp_changed = ctx->gfx_pipeline_state.rp_state != rp_state; if (!rp_changed && ctx->batch.in_rp) return 0; - zink_batch_no_rp(ctx); + zink_batch_no_rp_safe(ctx); for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) { struct zink_surface *surf = zink_csurface(ctx->fb_state.cbufs[i]); VkImageView iv = zink_prep_fb_attachment(ctx, surf, i); @@ -2756,7 +2756,7 @@ zink_batch_rp(struct zink_context *ctx) /* this is a driver that doesn't need dummy surfaces but does need rasterization discard, so flush clears first */ ctx->queries_disabled = true; zink_batch_rp(ctx); - zink_batch_no_rp(ctx); + zink_batch_no_rp_safe(ctx); ctx->queries_disabled = false; } zink_resume_queries(ctx, &ctx->batch); @@ -2791,17 +2791,10 @@ zink_batch_rp(struct zink_context *ctx) } void -zink_batch_no_rp(struct zink_context *ctx) +zink_batch_no_rp_safe(struct zink_context *ctx) { if (!ctx->batch.in_rp) return; - if (zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses && !ctx->blitting) { - ctx->dynamic_fb.tc_info.data32[0] = 0; - ctx->dynamic_fb.tc_info.cbuf_load = BITFIELD_MASK(8); - ctx->dynamic_fb.tc_info.zsbuf_clear_partial = true; - ctx->dynamic_fb.tc_info.has_draw = true; - ctx->dynamic_fb.tc_info.has_query_ends = true; - } if (ctx->render_condition.query) zink_stop_conditional_render(ctx); /* suspend all queries that were started in a renderpass @@ -2818,6 +2811,21 @@ zink_batch_no_rp(struct zink_context *ctx) assert(!ctx->batch.in_rp); } +void +zink_batch_no_rp(struct zink_context *ctx) +{ + if (!ctx->batch.in_rp) + return; + if (zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses && !ctx->blitting) { + ctx->dynamic_fb.tc_info.data = 0; + ctx->dynamic_fb.tc_info.cbuf_load = BITFIELD_MASK(8); + ctx->dynamic_fb.tc_info.zsbuf_clear_partial = true; + ctx->dynamic_fb.tc_info.has_draw = true; + ctx->dynamic_fb.tc_info.has_query_ends = true; + } + zink_batch_no_rp_safe(ctx); +} + ALWAYS_INLINE static void update_res_sampler_layouts(struct zink_context *ctx, struct zink_resource *res) { @@ -3100,7 +3108,7 @@ flush_batch(struct zink_context *ctx, bool sync) zink_batch_rp(ctx); bool conditional_render_active = ctx->render_condition.active; zink_stop_conditional_render(ctx); - zink_batch_no_rp(ctx); + zink_batch_no_rp_safe(ctx); zink_end_batch(ctx, batch); ctx->deferred_fence = NULL; @@ -3405,7 +3413,7 @@ zink_set_framebuffer_state(struct pipe_context *pctx, ctx->gfx_pipeline_state.rast_samples = rast_samples; /* need to ensure we start a new rp on next draw */ - zink_batch_no_rp(ctx); + zink_batch_no_rp_safe(ctx); /* this is an ideal time to oom flush since it won't split a renderpass */ if (ctx->oom_flush) flush_batch(ctx, false); @@ -4372,6 +4380,7 @@ zink_flush_resource(struct pipe_context *pctx, struct zink_resource *res = zink_resource(pres); if (res->obj->dt) { if (zink_kopper_acquired(res->obj->dt, res->obj->dt_idx)) { + zink_batch_no_rp_safe(ctx); zink_screen(ctx->base.screen)->image_barrier(ctx, res, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, 0, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT); zink_batch_reference_resource_rw(&ctx->batch, res, true); } else { diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index f7f861a9cc6..25cd1d6fa28 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -130,6 +130,8 @@ zink_batch_rp(struct zink_context *ctx); void zink_batch_no_rp(struct zink_context *ctx); +void +zink_batch_no_rp_safe(struct zink_context *ctx); VkImageView zink_prep_fb_attachment(struct zink_context *ctx, struct zink_surface *surf, unsigned i); diff --git a/src/gallium/drivers/zink/zink_render_pass.c b/src/gallium/drivers/zink/zink_render_pass.c index 7a460f2c7fc..ed3abc34ba5 100644 --- a/src/gallium/drivers/zink/zink_render_pass.c +++ b/src/gallium/drivers/zink/zink_render_pass.c @@ -614,7 +614,7 @@ setup_framebuffer(struct zink_context *ctx) zink_init_framebuffer(screen, ctx->framebuffer, rp); ctx->fb_changed = false; ctx->gfx_pipeline_state.render_pass = rp; - zink_batch_no_rp(ctx); + zink_batch_no_rp_safe(ctx); } static bool
