anv: Enable HiZ for VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 5 Feb 2020 16:12:26 +0000 (10:12 -0600)
committerMarge Bot <eric+marge@anholt.net>
Thu, 5 Mar 2020 18:56:45 +0000 (18:56 +0000)
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3717>

src/intel/vulkan/anv_image.c

index fbb14cc996be5ae00a8c51ad817f09c12abfd3cb..39f61a994671fe646b683690069e6dbab010dbf1 100644 (file)
@@ -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: