Mesa (main): zink: track number of fb attachment binds on resources

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 4 15:19:43 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Mar  9 13:28:54 2021 -0500

zink: track number of fb attachment binds on resources

this will be useful for applying layouts

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11130>

---

 src/gallium/drivers/zink/zink_context.c  | 12 ++++++++++++
 src/gallium/drivers/zink/zink_resource.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 3a30737b7ee..4df38c98c4e 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1827,6 +1827,8 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
          zink_fb_clears_apply(ctx, surf->texture);
          ctx->rp_changed = true;
       }
+      if (surf)
+         zink_resource(surf->texture)->fb_binds--;
    }
    if (ctx->fb_state.zsbuf) {
       struct pipe_surface *surf = ctx->fb_state.zsbuf;
@@ -1834,6 +1836,7 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
          zink_fb_clears_apply(ctx, ctx->fb_state.zsbuf->texture);
          ctx->rp_changed = true;
       }
+      zink_resource(surf->texture)->fb_binds--;
    }
    /* renderpass changes if the number or types of attachments change */
    ctx->rp_changed |= ctx->fb_state.nr_cbufs != state->nr_cbufs;
@@ -1843,6 +1846,15 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
    unsigned h = ctx->fb_state.height;
 
    util_copy_framebuffer_state(&ctx->fb_state, state);
+   for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
+      struct pipe_surface *surf = ctx->fb_state.cbufs[i];
+      if (surf)
+         zink_resource(surf->texture)->fb_binds++;
+   }
+   if (ctx->fb_state.zsbuf) {
+      struct pipe_surface *surf = ctx->fb_state.zsbuf;
+      zink_resource(surf->texture)->fb_binds++;
+   }
    if (ctx->fb_state.width != w || ctx->fb_state.height != h)
       ctx->scissor_changed = true;
    rebind_fb_state(ctx, NULL, true);
diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h
index 821f616c807..8a277a3a10f 100644
--- a/src/gallium/drivers/zink/zink_resource.h
+++ b/src/gallium/drivers/zink/zink_resource.h
@@ -105,6 +105,7 @@ struct zink_resource {
          VkImageAspectFlags aspect;
          bool optimal_tiling;
          uint32_t sampler_binds[PIPE_SHADER_TYPES];
+         uint8_t fb_binds;
          uint16_t image_bind_count[2]; //gfx, compute
       };
    };



More information about the mesa-commit mailing list