From 0a6b8685aa394c280711cc2ea2148e6e1b3d1310 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 16 Feb 2021 22:20:08 -0500 Subject: [PATCH] zink: fix surface creation for cube slices if first==last layer, this should be a 2D slice of the cube else if this isn't all the layers, this should be an array of slices fixes a bunch of spec@arb_shader_image_size@builtin cases Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_surface.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index d5d0a3c6dbc..08dc360ee0e 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -107,10 +107,16 @@ zink_create_surface(struct pipe_context *pctx, ivci.subresourceRange.levelCount = 1; ivci.subresourceRange.baseArrayLayer = templ->u.tex.first_layer; ivci.subresourceRange.layerCount = 1 + templ->u.tex.last_layer - templ->u.tex.first_layer; - - if (pres->target == PIPE_TEXTURE_CUBE || - pres->target == PIPE_TEXTURE_CUBE_ARRAY) - ivci.subresourceRange.layerCount *= 6; + if (ivci.viewType == VK_IMAGE_VIEW_TYPE_CUBE || ivci.viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) { + if (templ->u.tex.first_layer == templ->u.tex.last_layer) + ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; + else if (ivci.viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && + templ->u.tex.first_layer % 6 == 0 && + ivci.subresourceRange.layerCount % 6 == 0) + ivci.viewType = VK_IMAGE_VIEW_TYPE_CUBE; + else if (templ->u.tex.first_layer || ivci.subresourceRange.layerCount != res->base.array_size) + ivci.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; + } if (vkCreateImageView(screen->dev, &ivci, NULL, &surface->image_view) != VK_SUCCESS) {