zink: make image_bind_count work for buffers
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 11 May 2021 14:34:40 +0000 (10:34 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 7 Jul 2021 00:40:32 +0000 (20:40 -0400)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11747>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_resource.h

index 708aed3..22b0ea1 100644 (file)
@@ -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
              */
index bd44789..4988beb 100644 (file)
@@ -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