From 449df3808f68c51e8b1effe84845e493df18d30a Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Fri, 5 Feb 2021 12:07:08 -0800 Subject: [PATCH] anv/image: Fix interpretation of 'disjoint' The calculation of the subsurfaces' memory requirements assumed that the image was disjoint if the image was created with VK_IMAGE_CREATE_DISJOINT_BIT. But the Vulkan spec also requires that the VkFormat be multi-planar. Reviewed-by: Jason Ekstrand Part-of: --- src/intel/vulkan/anv_image.c | 9 ++++++++- src/intel/vulkan/anv_private.h | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 1dac94ed915..08e6a972435 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -804,11 +804,18 @@ anv_image_create(VkDevice _device, image->usage = anv_image_create_usage(pCreateInfo, pCreateInfo->usage); image->create_flags = pCreateInfo->flags; image->tiling = pCreateInfo->tiling; - image->disjoint = pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT; image->needs_set_tiling = wsi_info && wsi_info->scanout; image->drm_format_mod = isl_mod_info ? isl_mod_info->modifier : DRM_FORMAT_MOD_INVALID; + /* The Vulkan 1.2.165 glossary says: + * + * A disjoint image consists of multiple disjoint planes, and is created + * with the VK_IMAGE_CREATE_DISJOINT_BIT bit set. + */ + image->disjoint = image->format->n_planes > 1 && + (pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT); + if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) { image->stencil_usage = pCreateInfo->usage; const VkImageStencilUsageCreateInfoEXT *stencil_usage_info = diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 17ec27689be..38ce4329c00 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3759,8 +3759,9 @@ struct anv_image { VkDeviceSize size; uint32_t alignment; - /* Whether the image is made of several underlying buffer objects rather a - * single one with different offsets. + /** + * Image has multi-planar format and was created with + * VK_IMAGE_CREATE_DISJOINT_BIT. */ bool disjoint;