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 {