Mesa (main): zink: add a per-stage bind mask for ssbos

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 7 01:42:34 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue May 11 10:12:39 2021 -0400

zink: add a per-stage bind mask for ssbos

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

---

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

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 3aeacb50b4c..0602d3e13bb 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1083,13 +1083,14 @@ zink_set_constant_buffer(struct pipe_context *pctx,
 }
 
 ALWAYS_INLINE static void
-unbind_ssbo(struct zink_context *ctx, struct zink_resource *res, bool is_compute, bool writable)
+unbind_ssbo(struct zink_context *ctx, struct zink_resource *res, enum pipe_shader_type pstage, unsigned slot, bool writable)
 {
    if (!res)
       return;
-   update_res_bind_count(ctx, res, is_compute, true);
+   res->ssbo_bind_mask[pstage] &= ~BITFIELD_BIT(slot);
+   update_res_bind_count(ctx, res, pstage == PIPE_SHADER_COMPUTE, true);
    if (writable)
-      res->write_bind_count[is_compute]--;
+      res->write_bind_count[pstage == PIPE_SHADER_COMPUTE]--;
 }
 
 static void
@@ -1115,9 +1116,10 @@ zink_set_shader_buffers(struct pipe_context *pctx,
       if (buffers && buffers[i].buffer) {
          struct zink_resource *new_res = zink_resource(buffers[i].buffer);
          if (new_res != res) {
-            unbind_ssbo(ctx, res, p_stage == PIPE_SHADER_COMPUTE, was_writable);
+            unbind_ssbo(ctx, res, p_stage, i, was_writable);
             new_res->bind_history |= BITFIELD_BIT(ZINK_DESCRIPTOR_TYPE_SSBO);
             new_res->bind_stages |= 1 << p_stage;
+            new_res->ssbo_bind_mask[p_stage] |= BITFIELD_BIT(i);
             update_res_bind_count(ctx, new_res, p_stage == PIPE_SHADER_COMPUTE, false);
          }
          VkAccessFlags access = VK_ACCESS_SHADER_READ_BIT;
@@ -1138,7 +1140,7 @@ zink_set_shader_buffers(struct pipe_context *pctx,
       } else {
          update = !!res;
          if (res)
-            unbind_ssbo(ctx, res, p_stage == PIPE_SHADER_COMPUTE, was_writable);
+            unbind_ssbo(ctx, res, p_stage, i, was_writable);
          pipe_resource_reference(&ssbo->buffer, NULL);
          ssbo->buffer_offset = 0;
          ssbo->buffer_size = 0;
diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h
index c5724d5e00e..d92258d8164 100644
--- a/src/gallium/drivers/zink/zink_resource.h
+++ b/src/gallium/drivers/zink/zink_resource.h
@@ -107,6 +107,7 @@ struct zink_resource {
          uint16_t vbo_bind_count;
          uint8_t ubo_bind_count[2];
          uint32_t ubo_bind_mask[PIPE_SHADER_TYPES];
+         uint32_t ssbo_bind_mask[PIPE_SHADER_TYPES];
       };
       struct {
          VkFormat format;



More information about the mesa-commit mailing list