Module: Mesa Branch: main Commit: a26d62df6b1b7ba8d1dc1e8bbb87b42c67fb24c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a26d62df6b1b7ba8d1dc1e8bbb87b42c67fb24c5
Author: Jianxun Zhang <jianxun.zh...@intel.com> Date: Mon Sep 25 13:50:15 2023 -0700 intel/vulkan: Allow modifiers supporting fast clear Signed-off-by: Jianxun Zhang <jianxun.zh...@intel.com> Reviewed-by: Nanley Chery <nanley.g.ch...@intel.com> Acked-by: Rohan Garg <rohan.g...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25651> --- src/intel/vulkan/anv_image.c | 48 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 0e3dba26189..7f892aeb3d3 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1305,38 +1305,36 @@ add_all_surfaces_explicit_layout( isl_drm_modifier_has_aux(drm_info->drmFormatModifier); VkResult result; - /* About valid usage in the Vulkan spec: - * - * Unlike vanilla vkCreateImage, which produces undefined behavior on user - * error, here the spec requires the implementation to return - * VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT if the app provides - * a bad plane layout. However, the spec does require - * drmFormatModifierPlaneCount to be valid. - * - * Most validation of plane layout occurs in add_surface(). - */ - - /* We support a restricted set of images with modifiers. - * - * With aux usage on platforms without flat-CCS, - * - Format plane count must be 1. - * - Memory plane count must be 2. - * Otherwise, - * - Each format plane must map to a distint memory plane. - * - * For the other cases, currently there is no way to properly map memory - * planes to format planes and aux planes due to the lack of defined ABI - * for external multi-planar images. + /* Currently there is no way to properly map memory planes to format planes + * and aux planes due to the lack of defined ABI for external multi-planar + * images. */ if (image->n_planes == 1) assert(image->vk.aspects == VK_IMAGE_ASPECT_COLOR_BIT); else assert(!(image->vk.aspects & ~VK_IMAGE_ASPECT_PLANES_BITS_ANV)); - if (mod_has_aux && !devinfo->has_flat_ccs) - assert(image->n_planes == 1 && mod_plane_count == 2); - else + if (mod_has_aux) { + assert(image->n_planes == 1); + + /* About valid usage in the Vulkan spec: + * + * Unlike vanilla vkCreateImage, which produces undefined behavior on user + * error, here the spec requires the implementation to return + * VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT if the app provides + * a bad plane layout. However, the spec does require + * drmFormatModifierPlaneCount to be valid. + * + * Most validation of plane layout occurs in add_surface(). + */ + uint32_t n_mod_planes = + isl_drm_modifier_get_plane_count(devinfo, + drm_info->drmFormatModifier, + image->n_planes); + assert(n_mod_planes == mod_plane_count); + } else { assert(image->n_planes == mod_plane_count); + } /* Reject special values in the app-provided plane layouts. */ for (uint32_t i = 0; i < mod_plane_count; ++i) {