From c9f2a74b5a5da4ccfd69ce83ba1d39e106565714 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Sat, 8 Aug 2020 19:11:33 -0500 Subject: [PATCH] anv/image: Respect VkImageFormatListCreateInfo for VkImageFormatProperties (v2) When filling VkImageFormatProperties, anv_get_image_format_properties() checks the requested VkImageUsageFlags and VkImageCreateFlags against the VkFormatFeatureFlags available to the queried VkFormat. However, we neglected to consider if any formats given in VkImageFormatListCreateInfo further restricted the available VkFormatFeatureFlags. The image view formats are more likely to introduce additional restrictions when DRM format modifiers are present. v2: - Do not drop anv_formats_ccs_e_compatible(). Reviewed-by: Lionel Landwerlin (v2) Reviewed-by: Jason Ekstrand (v2) --- src/intel/vulkan/anv_formats.c | 36 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index e70263f390a..31d6085fc49 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -908,6 +908,8 @@ anv_get_image_format_properties( const struct gen_device_info *devinfo = &physical_device->info; const struct anv_format *format = anv_get_format(info->format); const struct isl_drm_modifier_info *isl_mod_info = NULL; + const VkImageFormatListCreateInfo *format_list_info = + vk_find_struct_const(info->pNext, IMAGE_FORMAT_LIST_CREATE_INFO); if (format == NULL) goto unsupported; @@ -925,6 +927,24 @@ anv_get_image_format_properties( format_feature_flags = anv_get_image_format_features(devinfo, info->format, format, info->tiling, isl_mod_info); + + /* Remove the VkFormatFeatureFlags that are incompatible with any declared + * image view format. (Removals are more likely to occur when a DRM format + * modifier is present). + */ + if ((info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) && format_list_info) { + for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) { + VkFormat vk_view_format = format_list_info->pViewFormats[i]; + const struct anv_format *anv_view_format = anv_get_format(vk_view_format); + VkFormatFeatureFlags view_format_features = + anv_get_image_format_features(devinfo, vk_view_format, + anv_view_format, + info->tiling, + isl_mod_info); + format_feature_flags &= view_format_features; + } + } + if (!format_feature_flags) goto unsupported; @@ -1071,18 +1091,10 @@ anv_get_image_format_properties( if (format->n_planes > 1) goto unsupported; - if (isl_mod_info->aux_usage == ISL_AUX_USAGE_CCS_E) { - /* If we have a CCS modifier, ensure that the format supports CCS - * and, if VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is set, all of the - * formats in the format list are CCS compatible. - */ - const VkImageFormatListCreateInfoKHR *fmt_list = - vk_find_struct_const(info->pNext, - IMAGE_FORMAT_LIST_CREATE_INFO_KHR); - if (!anv_formats_ccs_e_compatible(devinfo, info->flags, - info->format, info->tiling, - fmt_list)) - goto unsupported; + if (isl_mod_info->aux_usage == ISL_AUX_USAGE_CCS_E && + !anv_formats_ccs_e_compatible(devinfo, info->flags, info->format, + info->tiling, format_list_info)) { + goto unsupported; } }