From 334b368fc923af750a31f21028ab647ca04e837d Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Mon, 25 Mar 2024 16:23:54 -0400 Subject: [PATCH] anv: Allow more fast clear colors for layouts Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9983 Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_image.c | 52 +++++++++--------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index a959c65bf02..9481d3962a8 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -3403,7 +3403,7 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo, anv_layout_to_aux_state(devinfo, image, aspect, layout, queue_flags); const VkImageUsageFlags layout_usage = - vk_image_layout_to_usage_flags(layout, aspect); + vk_image_layout_to_usage_flags(layout, aspect) & image->vk.usage; switch (aux_state) { case ISL_AUX_STATE_CLEAR: @@ -3411,50 +3411,22 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo, case ISL_AUX_STATE_PARTIAL_CLEAR: case ISL_AUX_STATE_COMPRESSED_CLEAR: - if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) { - return ANV_FAST_CLEAR_DEFAULT_VALUE; - } else if (layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL || - layout == VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL) { - /* The image might not support non zero fast clears when mutable. */ - if (!image->planes[plane].can_non_zero_fast_clear) - return ANV_FAST_CLEAR_DEFAULT_VALUE; - /* When we're in a render pass we have the clear color data from the - * VkRenderPassBeginInfo and we can use arbitrary clear colors. They - * must get partially resolved before we leave the render pass. - */ - return ANV_FAST_CLEAR_ANY; - } else if (layout_usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | - VK_IMAGE_USAGE_TRANSFER_DST_BIT)) { - /* Fast clear with non zero color is not supported during transfer - * operations since transfer may do format reinterpretation. - */ + if (!image->planes[plane].can_non_zero_fast_clear) return ANV_FAST_CLEAR_DEFAULT_VALUE; - } else if (image->planes[plane].aux_usage == ISL_AUX_USAGE_MCS || - image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E || - image->planes[plane].aux_usage == ISL_AUX_USAGE_FCV_CCS_E) { - if (devinfo->ver >= 11) { - /* The image might not support non zero fast clears when mutable. */ - if (!image->planes[plane].can_non_zero_fast_clear) - return ANV_FAST_CLEAR_DEFAULT_VALUE; - /* On ICL and later, the sampler hardware uses a copy of the clear - * value that is encoded as a pixel value. Therefore, we can use - * any clear color we like for sampling. - */ - return ANV_FAST_CLEAR_ANY; - } else { - /* If the image has MCS or CCS_E enabled all the time then we can - * use fast-clear as long as the clear color is the default value - * of zero since this is the default value we program into every - * surface state used for texturing. - */ - return ANV_FAST_CLEAR_DEFAULT_VALUE; - } - } else { - return ANV_FAST_CLEAR_NONE; + /* On gfx9, we only load clear colors for attachments and for BLORP + * surfaces. Outside of those surfaces, we can only support the default + * clear value of zero. + */ + if (devinfo->ver == 9 && + (layout_usage & (VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))) { + return ANV_FAST_CLEAR_DEFAULT_VALUE; } + return ANV_FAST_CLEAR_ANY; + case ISL_AUX_STATE_COMPRESSED_NO_CLEAR: case ISL_AUX_STATE_RESOLVED: case ISL_AUX_STATE_PASS_THROUGH: