From 28c842e4b71a10175fa2292b2c3661f08f8add67 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Sat, 29 May 2021 09:51:29 +0200 Subject: [PATCH] zink: limit images we mark as cube-compatible The Vulkan spec says the following: > If imageType is VK_IMAGE_TYPE_2D and flags contains > VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, extent.width and extent.height > must be equal and arrayLayers must be greater than or equal to 6 This makes a lot of sense, as these are also requirements for being able to create cubemaps from them in the first place. Let's thread a bit more careful, and only set this bit in these cases. This matters in the new case of setting this flag on 2D array textures. In the other cases, this should already be the case. I haven't seen this trigger any issues, I just realized this while reading the Vulkan-spec. Fixes: 1887ff2ebb7 ("zink: mark 2d-arrays as cube-compatible") Reviewed-by: Hoe Hao Cheng Part-of: --- src/gallium/drivers/zink/zink_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 1e811f6703d..9bb38273dbf 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -388,7 +388,9 @@ create_ici(struct zink_screen *screen, const struct pipe_resource *templ, unsign if (templ->target == PIPE_TEXTURE_CUBE || templ->target == PIPE_TEXTURE_CUBE_ARRAY || - templ->target == PIPE_TEXTURE_2D_ARRAY) { + (templ->target == PIPE_TEXTURE_2D_ARRAY && + ici.extent.width == ici.extent.height && + ici.arrayLayers >= 6)) { VkImageFormatProperties props; if (vkGetPhysicalDeviceImageFormatProperties(screen->pdev, ici.format, ici.imageType, ici.tiling,