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

Author: Mike Blumenkrantz <[email protected]>
Date:   Thu Nov  5 10:27:08 2020 -0500

zink: store bufferview hash to bufferview struct

this lets us do a lot of things more precisely for bufferviews

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

---

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

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 5a4355e5405..aeaecd43944 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -558,6 +558,13 @@ sampler_aspect_from_format(enum pipe_format fmt)
      return VK_IMAGE_ASPECT_COLOR_BIT;
 }
 
+static uint32_t
+hash_bufferview(void *bvci)
+{
+   size_t offset = offsetof(VkBufferViewCreateInfo, flags);
+   return _mesa_hash_data((char*)bvci + offset, sizeof(VkBufferViewCreateInfo) 
- offset);
+}
+
 static struct zink_buffer_view *
 get_buffer_view(struct zink_context *ctx, struct zink_resource *res, enum 
pipe_format format, uint32_t offset, uint32_t range)
 {
@@ -571,6 +578,7 @@ get_buffer_view(struct zink_context *ctx, struct 
zink_resource *res, enum pipe_f
    bvci.offset = offset;
    bvci.range = range;
 
+   uint32_t hash = hash_bufferview(&bvci);
    VkBufferView view;
    if (vkCreateBufferView(screen->dev, &bvci, NULL, &view) != VK_SUCCESS)
       return NULL;
@@ -581,6 +589,7 @@ get_buffer_view(struct zink_context *ctx, struct 
zink_resource *res, enum pipe_f
    }
    pipe_reference_init(&buffer_view->reference, 1);
    buffer_view->buffer_view = view;
+   buffer_view->hash = hash;
    return buffer_view;
 }
 
diff --git a/src/gallium/drivers/zink/zink_context.h 
b/src/gallium/drivers/zink/zink_context.h
index 026dff75b48..80c6ba21f77 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -77,6 +77,7 @@ struct zink_sampler_state {
 struct zink_buffer_view {
    struct pipe_reference reference;
    VkBufferView buffer_view;
+   uint32_t hash;
 };
 
 struct zink_sampler_view {

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to