From c1a7d520f3ffe720dfb949ee651d7299167a2924 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Thu, 24 Feb 2022 17:16:37 -0800 Subject: [PATCH] anv: Disable aux if the explicit modifier lacks it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For dmabuf imports, configure the primary surface without support for compression if the modifier doesn't specify it. This helps to create VkImages with memory requirements that are compatible with the buffers apps provide. Suggested-by: Philip Langdale Cc: 22.0 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5940 Tested-by: Philip Langdale Reviewed-by: Tapani Pälli Part-of: --- src/intel/vulkan/anv_image.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index f33c3f753c9..63fdd445330 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1212,18 +1212,7 @@ add_all_surfaces_explicit_layout( if (result != VK_SUCCESS) return result; - if (!mod_has_aux) { - /* Even though the modifier does not support aux, try to create - * a driver-private aux to improve performance. - */ - result = add_aux_surface_if_supported(device, image, plane, - format_plane, - format_list_info, - ANV_OFFSET_IMPLICIT, 0, - isl_extra_usage_flags); - if (result != VK_SUCCESS) - return result; - } else { + if (mod_has_aux) { const VkSubresourceLayout *aux_layout = &drm_info->pPlaneLayouts[1]; result = add_aux_surface_if_supported(device, image, plane, format_plane, @@ -1445,6 +1434,18 @@ anv_image_init_from_create_info(struct anv_device *device, .vk_info = pCreateInfo, }; + /* For dmabuf imports, configure the primary surface without support for + * compression if the modifier doesn't specify it. This helps to create + * VkImages with memory requirements that are compatible with the buffers + * apps provide. + */ + const struct VkImageDrmFormatModifierExplicitCreateInfoEXT *mod_explicit_info = + vk_find_struct_const(pCreateInfo->pNext, + IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT); + if (mod_explicit_info && + !isl_drm_modifier_has_aux(mod_explicit_info->drmFormatModifier)) + create_info.isl_extra_usage_flags |= ISL_SURF_USAGE_DISABLE_AUX_BIT; + return anv_image_init(device, image, &create_info); }