anv: Handle explicit surface layout of DG2_RC_CCS
authorNanley Chery <nanley.g.chery@intel.com>
Thu, 4 May 2023 21:10:18 +0000 (14:10 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 20 Jul 2023 20:53:26 +0000 (20:53 +0000)
We're going to enable the DG2 modifier. Account for the reduced plane
count that exists with it.

Also add an assert to make it clearer that the aux in use is CCS.
Otherwise, it may not be obvious because of the generic compression
names being used here.

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

src/intel/vulkan/anv_image.c

index a35e4e2..4d341e4 100644 (file)
@@ -1198,10 +1198,10 @@ add_all_surfaces_explicit_layout(
 
    /* We support a restricted set of images with modifiers.
     *
-    * With aux usage,
+    * With aux usage on platforms without flat-CCS,
     * - Format plane count must be 1.
     * - Memory plane count must be 2.
-    * Without aux usage,
+    * Otherwise,
     * - Each format plane must map to a distint memory plane.
     *
     * For the other cases, currently there is no way to properly map memory
@@ -1213,7 +1213,7 @@ add_all_surfaces_explicit_layout(
    else
       assert(!(image->vk.aspects & ~VK_IMAGE_ASPECT_PLANES_BITS_ANV));
 
-   if (mod_has_aux)
+   if (mod_has_aux && !devinfo->has_flat_ccs)
       assert(image->n_planes == 1 && mod_plane_count == 2);
    else
       assert(image->n_planes == mod_plane_count);
@@ -1253,7 +1253,15 @@ add_all_surfaces_explicit_layout(
          return result;
 
       if (mod_has_aux) {
-         const VkSubresourceLayout *aux_layout = &drm_info->pPlaneLayouts[1];
+         assert(!isl_drm_modifier_get_info(
+                  drm_info->drmFormatModifier)->supports_clear_color);
+
+         const VkSubresourceLayout flat_ccs_layout = {
+            .offset = ANV_OFFSET_IMPLICIT,
+         };
+         const VkSubresourceLayout *aux_layout = devinfo->has_flat_ccs ?
+            &flat_ccs_layout : &drm_info->pPlaneLayouts[1];
+
          result = add_aux_surface_if_supported(device, image, plane,
                                                format_plane,
                                                format_list_info,
@@ -1262,6 +1270,8 @@ add_all_surfaces_explicit_layout(
                                                isl_extra_usage_flags);
          if (result != VK_SUCCESS)
             return result;
+
+         assert(isl_aux_usage_has_ccs(image->planes[plane].aux_usage));
       }
    }