anv: Rework the meaning of anv_image::planes[]::aux_usage
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 21 Jan 2020 23:13:30 +0000 (17:13 -0600)
committerMarge Bot <eric+marge@anholt.net>
Fri, 24 Jan 2020 21:07:26 +0000 (21:07 +0000)
Previously, we set aux_usage=ISL_AUX_USAGE_NONE when we really meant
CCS_D.  This sort-of made sense before we had anv_layout_to_aux_usage
but now that we have that helper.  However, in our more modern aux
tracking model, all aux usage goes through anv_layout_to_* and we're
better off making the meaning of anv_image::planes[]::aux_usage be
AUX_USAGE_NONE if and only if there is no compression.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3556>

src/intel/vulkan/anv_blorp.c
src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c

index f2554e04df9762a7b9a501e43a1e1d36d3ceffea..232d02fdddc7386af1bad5c80326758386e4ea6e 100644 (file)
@@ -1441,17 +1441,6 @@ void anv_CmdResolveImage(
    }
 }
 
-static enum isl_aux_usage
-fast_clear_aux_usage(const struct anv_image *image,
-                     VkImageAspectFlagBits aspect)
-{
-   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
-   if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
-      return ISL_AUX_USAGE_CCS_D;
-   else
-      return image->planes[plane].aux_usage;
-}
-
 void
 anv_image_copy_to_shadow(struct anv_cmd_buffer *cmd_buffer,
                          const struct anv_image *image,
@@ -1836,7 +1825,7 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,
    struct blorp_surf surf;
    get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
                                 0, ANV_IMAGE_LAYOUT_EXPLICIT_AUX,
-                                fast_clear_aux_usage(image, aspect),
+                                image->planes[plane].aux_usage,
                                 &surf);
 
    /* Blorp will store the clear color for us if we provide the clear color
index 7c7b385df28bc2b69a173927da9d9ee8724f567f..e11d165932884131d180aff5e11c73c936160d3e 100644 (file)
@@ -438,8 +438,8 @@ make_surface(struct anv_device *dev,
                                     &image->planes[plane].surface.isl,
                                     &image->planes[plane].aux_surface.isl);
          assert(ok);
-         add_surface(image, &image->planes[plane].aux_surface, plane);
          image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ;
+         add_surface(image, &image->planes[plane].aux_surface, plane);
       }
    } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && image->samples == 1) {
       /* TODO: Disallow compression with :
@@ -499,6 +499,8 @@ make_surface(struct anv_device *dev,
                              "Gen12+. Not allocating a CCS buffer.");
                image->planes[plane].aux_surface.isl.size_B = 0;
                return VK_SUCCESS;
+            } else {
+               image->planes[plane].aux_usage = ISL_AUX_USAGE_CCS_D;
             }
 
             add_surface(image, &image->planes[plane].aux_surface, plane);
@@ -512,9 +514,9 @@ make_surface(struct anv_device *dev,
                                  &image->planes[plane].surface.isl,
                                  &image->planes[plane].aux_surface.isl);
       if (ok) {
+         image->planes[plane].aux_usage = ISL_AUX_USAGE_MCS;
          add_surface(image, &image->planes[plane].aux_surface, plane);
          add_aux_state_tracking_buffer(image, plane, dev);
-         image->planes[plane].aux_usage = ISL_AUX_USAGE_MCS;
       }
    }
 
@@ -1153,10 +1155,9 @@ anv_layout_to_aux_state(const struct gen_device_info * const devinfo,
           */
          assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_HIZ);
          return ISL_AUX_STATE_AUX_INVALID;
-      } else if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) {
+      } else if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_D) {
          return ISL_AUX_STATE_PASS_THROUGH;
       } else {
-         assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_CCS_D);
          return ISL_AUX_STATE_COMPRESSED_CLEAR;
       }
 
@@ -1173,7 +1174,7 @@ anv_layout_to_aux_state(const struct gen_device_info * const devinfo,
             return ISL_AUX_STATE_COMPRESSED_CLEAR;
          else
             return ISL_AUX_STATE_RESOLVED;
-      } else if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) {
+      } 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;
@@ -1213,11 +1214,9 @@ anv_layout_to_aux_state(const struct gen_device_info * const devinfo,
       assert(aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
       /* fall-through */
    case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR:
-      if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) {
-         assert(image->samples == 1);
+      if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_D) {
          return ISL_AUX_STATE_PARTIAL_CLEAR;
       } else {
-         assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_CCS_D);
          return ISL_AUX_STATE_COMPRESSED_CLEAR;
       }
 
@@ -1322,7 +1321,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
 
    case ISL_AUX_STATE_PARTIAL_CLEAR:
       assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
-      assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE);
+      assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_D);
       assert(image->samples == 1);
       return ISL_AUX_USAGE_CCS_D;
 
index 55b06ef6db991be48125008959c02db8be3db0d4..3c79a5d43e516a64ddec9a9f19dc178f501cf6a0 100644 (file)
@@ -3438,11 +3438,9 @@ struct anv_image {
       struct anv_surface shadow_surface;
 
       /**
-       * For color images, this is the aux usage for this image when not used
-       * as a color attachment.
-       *
-       * For depth/stencil images, this is set to ISL_AUX_USAGE_HIZ if the
-       * image has a HiZ buffer.
+       * The base aux usage for this image.  For color images, this can be
+       * either CCS_E or CCS_D depending on whether or not we can reliably
+       * leave CCS on all the time.
        */
       enum isl_aux_usage aux_usage;
 
index 6fabe9134a3d758e5e9b02cfe85fc1205867cca3..7d02961a1416f716361800876a5f327a92390765 100644 (file)
@@ -815,7 +815,7 @@ anv_cmd_predicated_ccs_resolve(struct anv_cmd_buffer *cmd_buffer,
     * to do a partial resolve on a CCS_D surface.
     */
    if (resolve_op == ISL_AUX_OP_PARTIAL_RESOLVE &&
-       image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
+       image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_D)
       resolve_op = ISL_AUX_OP_FULL_RESOLVE;
 
    anv_image_ccs_op(cmd_buffer, image, format, aspect, level,