From 83b641a038704d7fe834d13dad39b0a9f841baca Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 5 Feb 2020 10:12:26 -0600 Subject: [PATCH] anv: Enable HiZ for VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL Reviewed-by: Nanley Chery Part-of: --- src/intel/vulkan/anv_image.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index fbb14cc996b..39f61a99467 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1123,22 +1123,33 @@ anv_layout_to_aux_state(const struct gen_device_info * const devinfo, case VK_IMAGE_LAYOUT_PREINITIALIZED: return ISL_AUX_STATE_AUX_INVALID; - /* Transfer layouts */ + /* General layout */ case VK_IMAGE_LAYOUT_GENERAL: - case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) { - /* This buffer could be a depth buffer used in a transfer operation. - * BLORP currently doesn't use HiZ for transfer operations so we must - * use the main buffer for this layout. TODO: Enable HiZ in BLORP. - */ - assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_HIZ); - return ISL_AUX_STATE_AUX_INVALID; + if (image->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) { + /* This buffer could be used as both a depth and input attachment + * at the same time in which case compression could cause issues. + */ + return ISL_AUX_STATE_AUX_INVALID; + } else if (anv_can_sample_with_hiz(devinfo, image)) { + return ISL_AUX_STATE_COMPRESSED_CLEAR; + } else { + return ISL_AUX_STATE_AUX_INVALID; + } } else if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_D) { return ISL_AUX_STATE_PASS_THROUGH; } else { return ISL_AUX_STATE_COMPRESSED_CLEAR; } + /* Transfer layouts */ + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_D) { + return ISL_AUX_STATE_PASS_THROUGH; + } else { + return ISL_AUX_STATE_COMPRESSED_CLEAR; + } + /* Sampling layouts */ case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL_KHR: case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: -- 2.30.2