Module: Mesa
Branch: main
Commit: edab34f68dd918d8f6df0db67c7e453522633668
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=edab34f68dd918d8f6df0db67c7e453522633668

Author: Mike Blumenkrantz <[email protected]>
Date:   Thu Jul 14 18:02:39 2022 -0400

zink: allow no-op renderpass updates in zink_batch_rp()

in some cases it becomes desirable to "maybe" stop and start the current
renderpass, such as when updates MAY result in layout changes for attachments

for such cases, avoid splitting the renderpass unless it actually needs to
be split

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17640>

---

 src/gallium/drivers/zink/zink_context.c     | 16 +++++++++++-----
 src/gallium/drivers/zink/zink_render_pass.c |  3 +++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index aae88c6b1f0..9a5cb80d612 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2288,7 +2288,11 @@ begin_rendering(struct zink_context *ctx)
    ctx->rp_changed = false;
    /* update pipeline info id for compatibility VUs */
    unsigned rp_state = find_rp_state(ctx);
-   ctx->gfx_pipeline_state.dirty |= ctx->gfx_pipeline_state.rp_state != 
rp_state;
+   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);
+   ctx->gfx_pipeline_state.dirty |= rp_changed;
    ctx->gfx_pipeline_state.rp_state = rp_state;
 
    VKCTX(CmdBeginRendering)(ctx->batch.state->cmdbuf, &ctx->dynamic_fb.info);
@@ -2300,9 +2304,11 @@ begin_rendering(struct zink_context *ctx)
 void
 zink_batch_rp(struct zink_context *ctx)
 {
-   if (ctx->batch.in_rp)
+   assert(!(ctx->batch.in_rp && ctx->rp_changed));
+   if (ctx->batch.in_rp && !ctx->rp_layout_changed)
       return;
-   if (!ctx->batch.in_rp && ctx->void_clears) {
+   bool in_rp = ctx->batch.in_rp;
+   if (!in_rp && ctx->void_clears) {
       union pipe_color_union color;
       color.f[0] = color.f[1] = color.f[2] = 0;
       color.f[3] = 1.0;
@@ -2318,8 +2324,8 @@ zink_batch_rp(struct zink_context *ctx)
       clear_buffers = zink_begin_render_pass(ctx);
    else
       clear_buffers = begin_rendering(ctx);
-   if (!ctx->batch.in_rp)
-      return; //dead swapchain
+   if (in_rp || !ctx->batch.in_rp)
+      return; //dead swapchain or continued renderpass
    if (ctx->render_condition.query)
       zink_start_conditional_render(ctx);
    zink_clear_framebuffer(ctx, clear_buffers);
diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index f796f7354db..6a695503ce1 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -529,6 +529,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);
 }
 
 static bool
@@ -673,6 +674,8 @@ unsigned
 zink_begin_render_pass(struct zink_context *ctx)
 {
    setup_framebuffer(ctx);
+   if (ctx->batch.in_rp)
+      return 0;
    /* TODO: need replicate EXT */
    if (ctx->framebuffer->rp->state.msaa_expand_mask) {
       uint32_t rp_state = ctx->gfx_pipeline_state.rp_state;

Reply via email to