From 2de6beaa12f9b855d31c3c11a8a6cea51a14d6b1 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 6 Aug 2021 16:20:45 -0400 Subject: [PATCH] zink: add better handling for CUBE_COMPATIBLE bit this check was illegal because the usage bits weren't yet populated, so add another check after usage bits are determined to figure out if CUBE_COMPATIBLE can be applied additionally, checking sample counts was never needed since the spec prohibits CUBE_COMPATIBLE use with multisampling zink DEBUG: ERR: 'Validation Error: [ VUID-vkGetPhysicalDeviceImageFormatProperties-usage-requiredbitmask ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x991b3105 | vkGetPhysicalDeviceImageFormatProperties: value of usage must not be 0. The Vulkan spec states: usage must not be 0 (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceImageFormatProperties-usage-requiredbitmask)' Fixes: 71494c4874c ("zink: only mark resources as cube-compatible if supported") Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_resource.c | 31 +++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 64516a2900d..7ed7b2b46ed 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -343,8 +343,6 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo *ici, const struct pipe case PIPE_TEXTURE_CUBE: case PIPE_TEXTURE_CUBE_ARRAY: - ici->flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; - FALLTHROUGH; case PIPE_TEXTURE_2D: case PIPE_TEXTURE_2D_ARRAY: case PIPE_TEXTURE_RECT: @@ -380,21 +378,15 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo *ici, const struct pipe ici->sharingMode = VK_SHARING_MODE_EXCLUSIVE; ici->initialLayout = dmabuf ? VK_IMAGE_LAYOUT_PREINITIALIZED : VK_IMAGE_LAYOUT_UNDEFINED; - if (templ->target == PIPE_TEXTURE_CUBE || - templ->target == PIPE_TEXTURE_CUBE_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, - ici->usage, ici->flags | - VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, - &props) == VK_SUCCESS) { - if (props.sampleCounts & ici->samples) - ici->flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; - } - } + /* sampleCounts will be set to VK_SAMPLE_COUNT_1_BIT if at least one of the following conditions is true: + * - flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT + * + * 44.1.1. Supported Sample Counts + */ + bool want_cube = ici->samples == 1 && + (templ->target == PIPE_TEXTURE_CUBE || + templ->target == PIPE_TEXTURE_CUBE_ARRAY || + (templ->target == PIPE_TEXTURE_2D_ARRAY && ici->extent.width == ici->extent.height && ici->arrayLayers >= 6)); if (templ->target == PIPE_TEXTURE_CUBE) ici->arrayLayers *= 6; @@ -437,6 +429,11 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo *ici, const struct pipe if (ici->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) tried[ici->tiling] = true; } + if (want_cube) { + ici->flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; + if (get_image_usage(screen, ici, templ, bind, modifiers_count, modifiers, &mod) != ici->usage) + ici->flags &= ~VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; + } *success = true; return mod;