zink: track whether zsbuf is unused
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 21 Mar 2023 13:01:47 +0000 (09:01 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 22 Mar 2023 13:00:30 +0000 (13:00 +0000)
zink_is_zsbuf_used updates dynamically, so its return may not reflect
the actual state of the current renderpass

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22054>

src/gallium/drivers/zink/zink_clear.c
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_render_pass.c
src/gallium/drivers/zink/zink_types.h

index 35e6d9d..4c7bffb 100644 (file)
@@ -230,7 +230,7 @@ zink_clear(struct pipe_context *pctx,
    }
 
    if (batch->in_rp) {
-      if (buffers & PIPE_CLEAR_DEPTHSTENCIL && (!zink_is_zsbuf_used(ctx) || ctx->zsbuf_readonly)) {
+      if (buffers & PIPE_CLEAR_DEPTHSTENCIL && (ctx->zsbuf_unused || ctx->zsbuf_readonly)) {
          /* this will need a layout change */
          assert(!zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses);
          zink_batch_no_rp(ctx);
index 4203b48..1ff012e 100644 (file)
@@ -69,7 +69,7 @@ update_tc_info(struct zink_context *ctx)
       ctx->dynamic_fb.tc_info.data = info->data;
    } else {
       struct tc_renderpass_info info = ctx->dynamic_fb.tc_info;
-      bool zsbuf_used = zink_is_zsbuf_used(ctx);
+      bool zsbuf_used = !ctx->zsbuf_unused;
       bool zsbuf_write = zink_is_zsbuf_write(ctx);
       ctx->dynamic_fb.tc_info.data32[0] = 0;
       if (ctx->clears_enabled & PIPE_CLEAR_DEPTHSTENCIL)
@@ -2754,6 +2754,7 @@ begin_rendering(struct zink_context *ctx)
       ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].imageLayout = zink_resource(surf->base.texture)->layout;
       assert(ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].imageLayout != VK_IMAGE_LAYOUT_UNDEFINED);
    }
+   ctx->zsbuf_unused = !zsbuf_used;
    assert(ctx->fb_state.width >= ctx->dynamic_fb.info.renderArea.extent.width);
    assert(ctx->fb_state.height >= ctx->dynamic_fb.info.renderArea.extent.height);
    ctx->gfx_pipeline_state.dirty |= rp_changed;
index f101f42..921b5ba 100644 (file)
@@ -716,6 +716,7 @@ begin_render_pass(struct zink_context *ctx)
    infos.pAttachments = att;
    if (!prep_fb_attachments(ctx, att))
       return 0;
+   ctx->zsbuf_unused = !zink_is_zsbuf_used(ctx);
    /* this can be set if fbfetch is activated */
    ctx->rp_changed = false;
 #ifndef NDEBUG
index 563b084..37e93b3 100644 (file)
@@ -1715,6 +1715,7 @@ struct zink_context {
    bool rp_changed; //force renderpass restart
    bool rp_layout_changed; //renderpass changed, maybe restart
    bool rp_loadop_changed; //renderpass changed, don't restart
+   bool zsbuf_unused;
    bool zsbuf_readonly;
 
    struct zink_framebuffer *framebuffer;