From 146f41e608c4b35a5f68f0f49aa08d7949cf0d4c Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Wed, 5 Aug 2020 10:23:05 -0700 Subject: [PATCH] anv/image: Refactor iteration over modifiers Refactor in get_wsi_format_modifier_properties_list(). Instead of iterating over a function-local hard-coded list, iterate over all modifiers in isl_drm.c. This will improve agreement in behavior between VkDrmFormatModifierPropertiesListEXT VkPhysicalDeviceImageDrmFormatModifierInfoEXT. The future disagreement this patch attempts to prevent is the combination of: a. VkDrmFormatModifierPropertiesListEXT neglects to return a valid modifier because its hard-coded list of modifiers drifts out-of-sync with hard-coded lists elsewhere in the code. (Already today, the list in get_wsi_format_modifier_properties_list() does not match the list in isl_drm.c; though, this has produced no bug yet). b. vkGetPhysicalDeviceImageFormatProperties2 accepts, via VkPhysicalDeviceImageDrmFormatModifierInfoEXT, the modifier overlooked in (a), because it does not use the same hard-coded list in get_wsi_format_modifier_properties_list(). (Recall that the spec requires vkGetPhysicalDeviceImageFormatProperties2 to correctly accept/reject any int that the app provides, even when the int is an invalid modifier). c. The Bug. The driver told the app in (b) that it can legally create an image with format+modifier, but the app cannot query the VkFormatFeatureFlags of the format+modifier due to (a). Reviewed-by: Lionel Landwerlin Reviewed-by: Jason Ekstrand --- src/intel/vulkan/anv_formats.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index ac810c8a69d..13db615475b 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -833,20 +833,7 @@ get_wsi_format_modifier_properties_list(const struct anv_physical_device *physic vk_format == VK_FORMAT_B8G8R8A8_SRGB || vk_format == VK_FORMAT_B8G8R8A8_UNORM); - uint64_t modifiers[] = { - DRM_FORMAT_MOD_LINEAR, - I915_FORMAT_MOD_X_TILED, - I915_FORMAT_MOD_Y_TILED, - I915_FORMAT_MOD_Y_TILED_CCS, - }; - - for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) { - const struct isl_drm_modifier_info *isl_mod_info = - isl_drm_modifier_get_info(modifiers[i]); - - if (!isl_mod_info) - continue; - + isl_drm_modifier_info_for_each(isl_mod_info) { VkFormatFeatureFlags features = anv_get_image_format_features(devinfo, vk_format, anv_format, VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,