Mesa (master): zink: optimize renderpass hash table

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 14 17:28:07 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Jan 13 11:08:25 2021 -0500

zink: optimize renderpass hash table

only the existing render targets need to be used for table entries

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8487>

---

 src/gallium/drivers/zink/zink_context.c     | 10 ++++++++--
 src/gallium/drivers/zink/zink_render_pass.h |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 0faac2de45b..8d5d4e6415b 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -618,13 +618,17 @@ zink_set_tess_state(struct pipe_context *pctx,
 static uint32_t
 hash_render_pass_state(const void *key)
 {
-   return _mesa_hash_data(key, sizeof(struct zink_render_pass_state));
+   struct zink_render_pass_state* s = (struct zink_render_pass_state*)key;
+   return _mesa_hash_data(key, offsetof(struct zink_render_pass_state, rts) + sizeof(s->rts[0]) * s->num_rts);
 }
 
 static bool
 equals_render_pass_state(const void *a, const void *b)
 {
-   return memcmp(a, b, sizeof(struct zink_render_pass_state)) == 0;
+   const struct zink_render_pass_state *s_a = a, *s_b = b;
+   if (s_a->num_rts != s_b->num_rts)
+      return false;
+   return memcmp(a, b, offsetof(struct zink_render_pass_state, rts) + sizeof(s_a->rts[0]) * s_a->num_rts) == 0;
 }
 
 static struct zink_render_pass *
@@ -644,6 +648,7 @@ get_render_pass(struct zink_context *ctx)
          state.rts[i].format = VK_FORMAT_R8_UINT;
          state.rts[i].samples = MAX2(fb->samples, 1);
       }
+      state.num_rts++;
    }
    state.num_cbufs = fb->nr_cbufs;
 
@@ -651,6 +656,7 @@ get_render_pass(struct zink_context *ctx)
       struct zink_resource *zsbuf = zink_resource(fb->zsbuf->texture);
       state.rts[fb->nr_cbufs].format = zsbuf->format;
       state.rts[fb->nr_cbufs].samples = zsbuf->base.nr_samples > 0 ? zsbuf->base.nr_samples : VK_SAMPLE_COUNT_1_BIT;
+      state.num_rts++;
    }
    state.have_zsbuf = fb->zsbuf != NULL;
 
diff --git a/src/gallium/drivers/zink/zink_render_pass.h b/src/gallium/drivers/zink/zink_render_pass.h
index 2d33612b3ee..f8d5a992cab 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -40,6 +40,7 @@ struct zink_render_pass_state {
    uint8_t num_cbufs : 4; /* PIPE_MAX_COLOR_BUFS = 8 */
    uint8_t have_zsbuf : 1;
    struct zink_rt_attrib rts[PIPE_MAX_COLOR_BUFS + 1];
+   unsigned num_rts;
 };
 
 struct zink_render_pass {



More information about the mesa-commit mailing list