Mesa (master): zink: unify shader image unbind codepath

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 5 12:48:34 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Jan 29 10:07:06 2021 -0500

zink: unify shader image unbind codepath

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8780>

---

 src/gallium/drivers/zink/zink_context.c | 41 ++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 2a97f130f85..1029b6a5fa6 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -618,6 +618,22 @@ zink_set_shader_buffers(struct pipe_context *pctx,
    }
 }
 
+static void
+unbind_shader_image(struct zink_context *ctx, enum pipe_shader_type stage, unsigned slot)
+{
+   struct zink_image_view *image_view = &ctx->image_views[stage][slot];
+   if (!image_view->base.resource)
+      return;
+
+   if (image_view->base.resource->target == PIPE_BUFFER)
+      vkDestroyBufferView(zink_screen(ctx->base.screen)->dev, image_view->buffer_view, NULL);
+   else
+      pipe_surface_reference((struct pipe_surface**)&image_view->surface, NULL);
+   pipe_resource_reference(&image_view->base.resource, NULL);
+   image_view->base.resource = NULL;
+   image_view->surface = NULL;
+}
+
 static void
 zink_set_shader_images(struct pipe_context *pctx,
                        enum pipe_shader_type p_stage,
@@ -645,29 +661,12 @@ zink_set_shader_images(struct pipe_context *pctx,
             image_view->surface = zink_surface(pctx->create_surface(pctx, &res->base, &tmpl));
             assert(image_view->surface);
          }
-      } else if (image_view->base.resource) {
-         if (image_view->base.resource->target == PIPE_BUFFER)
-            vkDestroyBufferView(zink_screen(pctx->screen)->dev, image_view->buffer_view, NULL);
-         else
-            pipe_surface_reference((struct pipe_surface**)&image_view->surface, NULL);
-         pipe_resource_reference(&image_view->base.resource, NULL);
-         image_view->base.resource = NULL;
-         image_view->surface = NULL;
-      }
+      } else if (image_view->base.resource)
+         unbind_shader_image(ctx, p_stage, start_slot + i);
    }
 
-   for (unsigned i = 0; i < unbind_num_trailing_slots; i++) {
-      struct zink_image_view *image_view = &ctx->image_views[p_stage][start_slot + count + i];
-      if (image_view->base.resource) {
-         if (image_view->base.resource->target == PIPE_BUFFER)
-            vkDestroyBufferView(zink_screen(pctx->screen)->dev, image_view->buffer_view, NULL);
-         else
-            pipe_surface_reference((struct pipe_surface**)&image_view->surface, NULL);
-         pipe_resource_reference(&image_view->base.resource, NULL);
-         image_view->base.resource = NULL;
-         image_view->surface = NULL;
-      }
-   }
+   for (unsigned i = 0; i < unbind_num_trailing_slots; i++)
+      unbind_shader_image(ctx, p_stage, start_slot + count + i);
 }
 
 static void



More information about the mesa-commit mailing list