diff --git a/.pick_status.json b/.pick_status.json index e0a637506bd..fcb5027d256 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -614,7 +614,7 @@ "description": "anv: Fix the fast clear type for FCV writes", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "cd8e120b97d3d0ee69fd632fb7017b10fac13e77", "notes": null diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 743bcc59291..7a7c2afb564 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -3728,11 +3728,16 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo, const VkImageLayout layout, const VkQueueFlagBits queue_flags) { - if (INTEL_DEBUG(DEBUG_NO_FAST_CLEAR)) - return ANV_FAST_CLEAR_NONE; - const uint32_t plane = anv_image_aspect_to_plane(image, aspect); + /* Even without fast-clearing, some aux-usages may still end up with + * fast-cleared blocks. + */ + if (INTEL_DEBUG(DEBUG_NO_FAST_CLEAR)) { + return image->planes[plane].aux_usage == ISL_AUX_USAGE_FCV_CCS_E ? + ANV_FAST_CLEAR_DEFAULT_VALUE : ANV_FAST_CLEAR_NONE; + } + /* If there is no auxiliary surface allocated, there are no fast-clears */ if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) return ANV_FAST_CLEAR_NONE; diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 1702047d2a8..829334693dc 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -706,19 +706,20 @@ set_image_compressed_bit(struct anv_cmd_buffer *cmd_buffer, mi_imm(compressed ? UINT32_MAX : 0)); } - /* FCV_CCS_E images are automatically fast cleared to default value at - * render time. In order to account for this, anv should set the the - * appropriate fast clear state for level0/layer0. - * - * At the moment, tracking the fast clear state for higher levels/layers is - * neither supported, nor do we enter a situation where it is a concern. - */ - if (image->planes[plane].aux_usage == ISL_AUX_USAGE_FCV_CCS_E && - base_layer == 0 && level == 0) { + if (compressed && + image->planes[plane].aux_usage == ISL_AUX_USAGE_FCV_CCS_E) { + /* FCV_CCS_E images may be automatically fast cleared at render time. + * If the write is compressed, the fast-clear type won't be dependent on + * the layout. So, just pick one we know supports compression. + */ + VkImageLayout layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + enum anv_fast_clear_type render_fast_clear = + anv_layout_to_fast_clear_type(device->info, image, aspect, layout, + cmd_buffer->queue_family->queueFlags); + assert(render_fast_clear != ANV_FAST_CLEAR_NONE); struct anv_address fc_type_addr = anv_image_get_fast_clear_type_addr(device, image, aspect); - mi_store(&b, mi_mem32(fc_type_addr), - mi_imm(ANV_FAST_CLEAR_DEFAULT_VALUE)); + mi_store(&b, mi_mem32(fc_type_addr), mi_imm(render_fast_clear)); } } @@ -1284,8 +1285,11 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer, /* Ensure the raw and converted clear colors are in sync. */ const uint32_t zero_pixel[4] = {}; set_image_clear_color(cmd_buffer, image, aspect, zero_pixel); - } - if (base_level == 0 && base_layer == 0) { + } else if (base_level == 0 && base_layer == 0) { + /* Set the initial clear type to NONE to avoid redundant resolves. + * Don't apply this optimization to FCV images as they may have other + * levels/layers with fast-cleared blocks. + */ set_image_fast_clear_state(cmd_buffer, image, aspect, ANV_FAST_CLEAR_NONE); }