From 888f63cf1baf34bc95e847a30a041dc7798edddb Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 2 Dec 2024 09:13:04 +0200 Subject: [PATCH] anv/iris: leave 4k alignments for clear colors with modifiers Signed-off-by: Lionel Landwerlin Fixes: 17f97a69c1 ("iris: Reduce clear color state alignment to 64B") Fixes: 063715ed45 ("anv: Reduce clear color state alignment to 64B") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12195 Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13057 Reviewed-by: Sagar Ghuge Reviewed-by: Nanley Chery Part-of: --- src/gallium/drivers/iris/iris_resource.c | 7 ++++++- src/intel/vulkan/anv_image.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index a0a239e6f3f..e3e22ecee05 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1157,7 +1157,12 @@ iris_resource_create_for_image(struct pipe_screen *pscreen, /* Allocate space for the indirect clear color. */ if (iris_get_aux_clear_color_state_size(screen, res) > 0) { - res->aux.clear_color_offset = align64(bo_size, 64); + /* Kernel expects a 4k alignment, otherwise the display rejects the + * surface. + */ + const uint64_t clear_color_alignment = + (res->mod_info && res->mod_info->supports_clear_color) ? 4096 : 64; + res->aux.clear_color_offset = align64(bo_size, clear_color_alignment); bo_size = res->aux.clear_color_offset + iris_get_aux_clear_color_state_size(screen, res); } diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 0bf549945bc..ed033be3b11 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -674,6 +674,9 @@ add_aux_state_tracking_buffer(struct anv_device *device, enum anv_image_memory_binding binding = ANV_IMAGE_MEMORY_BINDING_PLANE_0 + plane; + const struct isl_drm_modifier_info *mod_info = + isl_drm_modifier_get_info(image->vk.drm_format_mod); + /* If an auxiliary surface is used for an externally-shareable image, * we have to hide this from the memory of the image since other * processes with access to the memory may not be aware of it or of @@ -683,14 +686,19 @@ add_aux_state_tracking_buffer(struct anv_device *device, * But when the image is created with a drm modifier that supports * clear color, it will be exported along with main surface. */ - if (anv_image_is_externally_shared(image) - && !isl_drm_modifier_get_info(image->vk.drm_format_mod)->supports_clear_color) { + if (anv_image_is_externally_shared(image) && + !mod_info->supports_clear_color) binding = ANV_IMAGE_MEMORY_BINDING_PRIVATE; - } - /* The indirect clear color BO requires 64B-alignment on gfx11+. */ + /* The indirect clear color BO requires 64B-alignment on gfx11+. If we're + * using a modifier with clear color, then some kernels might require a 4k + * alignment. + */ + const uint32_t clear_color_alignment = + (mod_info && mod_info->supports_clear_color) ? 4096 : 64; + return image_binding_grow(device, image, binding, - state_offset, state_size, 64, + state_offset, state_size, clear_color_alignment, &image->planes[plane].fast_clear_memory_range); } @@ -1163,7 +1171,7 @@ check_memory_bindings(const struct anv_device *device, } /* The indirect clear color BO requires 64B-alignment on gfx11+. */ - assert(plane->fast_clear_memory_range.alignment == 64); + assert(plane->fast_clear_memory_range.alignment % 64 == 0); check_memory_range(accum_ranges, .test_range = &plane->fast_clear_memory_range, .expect_binding = binding);