anv: Replace aux_surface.isl.size_B checks with aux_usage checks
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 21 Jan 2020 23:21:47 +0000 (17:21 -0600)
committerMarge Bot <eric+marge@anholt.net>
Fri, 24 Jan 2020 21:07:26 +0000 (21:07 +0000)
Now that aux_usage has a unified meaning, aux_usage == NONE if and only
if aux_surface.isl.size_B > 0.  In most of these cases, the question
we're asking is "does have compression?" and not "have we allocated an
aux surface for compression?".

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

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

index e11d165932884131d180aff5e11c73c936160d3e..4be8f5aee6c4fb1e8605df7528d3c99777deba38 100644 (file)
@@ -251,7 +251,7 @@ add_aux_state_tracking_buffer(struct anv_image *image,
                               const struct anv_device *device)
 {
    assert(image && device);
-   assert(image->planes[plane].aux_surface.isl.size_B > 0 &&
+   assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_NONE &&
           image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
 
    /* Compressed images must be tiled and therefore everything should be 4K
@@ -532,7 +532,7 @@ make_surface(struct anv_device *dev,
             image->planes[plane].surface.isl.size_B)) <=
           (image->planes[plane].offset + image->planes[plane].size));
 
-   if (image->planes[plane].aux_surface.isl.size_B) {
+   if (image->planes[plane].aux_usage != ISL_AUX_USAGE_NONE) {
       /* assert(image->planes[plane].fast_clear_state_offset == */
       /*        (image->planes[plane].aux_surface.offset + image->planes[plane].aux_surface.isl.size_B)); */
       assert(image->planes[plane].fast_clear_state_offset <
@@ -1121,7 +1121,7 @@ anv_layout_to_aux_state(const struct gen_device_info * const devinfo,
    uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
 
    /* If we don't have an aux buffer then aux state makes no sense */
-   assert(image->planes[plane].aux_surface.isl.size_B > 0);
+   assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_NONE);
 
    /* All images that use an auxiliary surface are required to be tiled. */
    assert(image->planes[plane].surface.isl.tiling != ISL_TILING_LINEAR);
@@ -1309,7 +1309,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
    /* If there is no auxiliary surface allocated, we must use the one and only
     * main buffer.
     */
-   if (image->planes[plane].aux_surface.isl.size_B == 0)
+   if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
       return ISL_AUX_USAGE_NONE;
 
    enum isl_aux_state aux_state =
@@ -1381,7 +1381,7 @@ anv_layout_to_fast_clear_type(const struct gen_device_info * const devinfo,
    uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
 
    /* If there is no auxiliary surface allocated, there are no fast-clears */
-   if (image->planes[plane].aux_surface.isl.size_B == 0)
+   if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
       return ANV_FAST_CLEAR_NONE;
 
    /* We don't support MSAA fast-clears on Ivybridge or Bay Trail because they
index 3c79a5d43e516a64ddec9a9f19dc178f501cf6a0..2795cbda48f77ff7ebd12b63f636d7a9a00d8dac 100644 (file)
@@ -3487,15 +3487,13 @@ anv_image_aux_levels(const struct anv_image * const 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 0;
 
    /* The Gen12 CCS aux surface is represented with only one level. */
-   const uint8_t aux_logical_levels =
-      image->planes[plane].aux_surface.isl.tiling == ISL_TILING_GEN12_CCS ?
-      image->planes[plane].surface.isl.levels :
-      image->planes[plane].aux_surface.isl.levels;
-
-   return image->planes[plane].aux_surface.isl.size_B > 0 ?
-          aux_logical_levels : 0;
+   return image->planes[plane].aux_surface.isl.tiling == ISL_TILING_GEN12_CCS ?
+          image->planes[plane].surface.isl.levels :
+          image->planes[plane].aux_surface.isl.levels;
 }
 
 /* Returns the number of auxiliary buffer layers attached to an image. */
index 7d02961a1416f716361800876a5f327a92390765..556976575052f0e652d01e6bbb97756a40e74780 100644 (file)
@@ -4827,7 +4827,7 @@ cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
 
       if (GEN_GEN < 10 &&
           (att_state->pending_load_aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) &&
-          image->planes[0].aux_surface.isl.size_B > 0 &&
+          image->planes[0].aux_usage != ISL_AUX_USAGE_NONE &&
           iview->planes[0].isl.base_level == 0 &&
           iview->planes[0].isl.base_array_layer == 0) {
          if (att_state->aux_usage != ISL_AUX_USAGE_NONE) {