From 695577e5b016104b1db55dca7985212bb5889d97 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Wed, 6 Mar 2024 16:51:11 -0500 Subject: [PATCH] intel/isl: Add and use isl_drm_modifier_needs_display_layout Intel modifiers supporting compression are specified to be compatible with the display engine, even if they won't actually be used for scanout. Attempting to capture a wider scope of modifiers resulted in test errors. I chose to narrow the scope instead of digging into them. Reviewed-by: Lionel Landwerlin Reviewed-by: Jianxun Zhang Part-of: --- src/gallium/drivers/iris/iris_resource.c | 3 +++ src/intel/isl/isl.h | 9 +++++++++ src/intel/vulkan/anv_image.c | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 023938a403f..aafe34676e6 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -760,6 +760,9 @@ iris_resource_configure_main(const struct iris_screen *screen, if (templ->bind & PIPE_BIND_SCANOUT) usage |= ISL_SURF_USAGE_DISPLAY_BIT; + else if (isl_drm_modifier_needs_display_layout(modifier)) + usage |= ISL_SURF_USAGE_DISPLAY_BIT; + if (templ->target == PIPE_TEXTURE_CUBE || templ->target == PIPE_TEXTURE_CUBE_ARRAY) { usage |= ISL_SURF_USAGE_CUBE_BIT; diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index 4de5ca3e453..42988d54cc8 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -2420,6 +2420,15 @@ isl_drm_modifier_has_aux(uint64_t modifier) isl_drm_modifier_get_info(modifier)->supports_media_compression; } +static inline bool +isl_drm_modifier_needs_display_layout(uint64_t modifier) +{ + /* Modifiers supporting compression are specified to be compatible with the + * display engine, even if they won't actually be used for scanout. + */ + return isl_drm_modifier_has_aux(modifier); +} + static inline bool isl_drm_modifier_plane_is_clear_color(uint64_t modifier, uint32_t plane) { diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 11f5662c3f4..42289b46c32 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1554,6 +1554,8 @@ anv_image_init(struct anv_device *device, struct anv_image *image, image->vk.stencil_usage = anv_image_create_usage(pCreateInfo, image->vk.stencil_usage); + isl_surf_usage_flags_t isl_extra_usage_flags = + create_info->isl_extra_usage_flags; if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { assert(!image->vk.wsi_legacy_scanout); mod_explicit_info = @@ -1573,6 +1575,9 @@ anv_image_init(struct anv_device *device, struct anv_image *image, assert(isl_mod_info); assert(image->vk.drm_format_mod == DRM_FORMAT_MOD_INVALID); image->vk.drm_format_mod = isl_mod_info->modifier; + + if (isl_drm_modifier_needs_display_layout(image->vk.drm_format_mod)) + isl_extra_usage_flags |= ISL_SURF_USAGE_DISPLAY_BIT; } for (int i = 0; i < ANV_IMAGE_MEMORY_BINDING_END; ++i) { @@ -1604,7 +1609,6 @@ anv_image_init(struct anv_device *device, struct anv_image *image, image->disjoint = image->n_planes > 1 && (pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT); - isl_surf_usage_flags_t isl_extra_usage_flags = create_info->isl_extra_usage_flags; if (anv_is_format_emulated(device->physical, pCreateInfo->format)) { assert(image->n_planes == 1 && vk_format_is_compressed(image->vk.format));