Mesa (main): zink: create an array view for all cube samplerviews

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 7 14:47:38 UTC 2022


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Mar 21 14:52:31 2022 -0400

zink: create an array view for all cube samplerviews

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

---

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

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index f6e4640a9da..1061f13fde5 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -734,6 +734,13 @@ clamp_zs_swizzle(enum pipe_swizzle swizzle)
    return swizzle;
 }
 
+ALWAYS_INLINE static bool
+viewtype_is_cube(const VkImageViewCreateInfo *ivci)
+{
+   return ivci->viewType == VK_IMAGE_VIEW_TYPE_CUBE ||
+          ivci->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
+}
+
 static struct pipe_sampler_view *
 zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
                          const struct pipe_sampler_view *state)
@@ -806,6 +813,10 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
       assert(ivci.format);
 
       sampler_view->image_view = (struct zink_surface*)zink_get_surface(ctx, pres, &templ, &ivci);
+      if (viewtype_is_cube(&sampler_view->image_view->ivci)) {
+         ivci.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
+         sampler_view->cube_array = (struct zink_surface*)zink_get_surface(ctx, pres, &templ, &ivci);
+      }
       err = !sampler_view->image_view;
    } else {
       VkBufferViewCreateInfo bvci = create_bvci(ctx, res, state->format, state->u.buf.offset, state->u.buf.size);
@@ -848,6 +859,7 @@ zink_sampler_view_destroy(struct pipe_context *pctx,
       zink_buffer_view_reference(zink_screen(pctx->screen), &view->buffer_view, NULL);
    else {
       zink_surface_reference(zink_screen(pctx->screen), &view->image_view, NULL);
+      zink_surface_reference(zink_screen(pctx->screen), &view->cube_array, NULL);
    }
    pipe_resource_reference(&pview->texture, NULL);
    FREE_CL(view);
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index db67a2c017e..7efc144acf4 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -99,6 +99,7 @@ struct zink_sampler_view {
       struct zink_surface *image_view;
       struct zink_buffer_view *buffer_view;
    };
+   struct zink_surface *cube_array;
 };
 
 struct zink_image_view {



More information about the mesa-commit mailing list