Mesa (main): zink: make image_bind_count work for buffers

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


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

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

zink: make image_bind_count work for buffers

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  | 6 ++----
 src/gallium/drivers/zink/zink_resource.h | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 708aed3d346..22b0ea1fd92 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1189,11 +1189,9 @@ unbind_shader_image_counts(struct zink_context *ctx, struct zink_resource *res,
    update_res_bind_count(ctx, res, is_compute, true);
    if (writable)
       res->write_bind_count[is_compute]--;
-   if (res->obj->is_buffer)
-      return;
    res->image_bind_count[is_compute]--;
    /* if this was the last image bind, the sampler bind layouts must be updated */
-   if (!res->image_bind_count[is_compute] && res->bind_count[is_compute])
+   if (!res->obj->is_buffer && !res->image_bind_count[is_compute] && res->bind_count[is_compute])
       update_binds_for_samplerviews(ctx, res, is_compute);
 }
 
@@ -1272,6 +1270,7 @@ zink_set_shader_images(struct pipe_context *pctx,
          if (image_view->base.access & PIPE_IMAGE_ACCESS_READ) {
             access |= VK_ACCESS_SHADER_READ_BIT;
          }
+         res->image_bind_count[p_stage == PIPE_SHADER_COMPUTE]++;
          if (images[i].resource->target == PIPE_BUFFER) {
             image_view->buffer_view = get_buffer_view(ctx, res, images[i].format, images[i].u.buf.offset, images[i].u.buf.size);
             assert(image_view->buffer_view);
@@ -1289,7 +1288,6 @@ zink_set_shader_images(struct pipe_context *pctx,
             tmpl.u.tex.last_layer = images[i].u.tex.last_layer;
             image_view->surface = zink_surface(pctx->create_surface(pctx, &res->base.b, &tmpl));
             assert(image_view->surface);
-            res->image_bind_count[p_stage == PIPE_SHADER_COMPUTE]++;
             /* if this is the first image bind and there are sampler binds, the image's sampler layout
              * must be updated to GENERAL
              */
diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h
index bd447898e0f..4988bebd567 100644
--- a/src/gallium/drivers/zink/zink_resource.h
+++ b/src/gallium/drivers/zink/zink_resource.h
@@ -115,10 +115,10 @@ struct zink_resource {
          VkImageAspectFlags aspect;
          bool optimal_tiling;
          uint8_t fb_binds;
-         uint16_t image_bind_count[2]; //gfx, compute
       };
    };
    uint32_t sampler_binds[PIPE_SHADER_TYPES];
+   uint16_t image_bind_count[2]; //gfx, compute
    uint16_t write_bind_count[2]; //gfx, compute
    uint16_t bind_count[2]; //gfx, compute
 



More information about the mesa-commit mailing list