isl,iris: Move the extra_aux_surf logic into iris
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 23 Jun 2021 21:48:36 +0000 (16:48 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 24 Jun 2021 13:57:40 +0000 (13:57 +0000)
This gets rid of the awkward interface for isl_surf_get_ccs_surf where
we passed it two aux surfaces and it was supposed to fill out the second
one based on whether or not the first one already had stuff in it.
Instead, we now pass it three well-labled surfaces: surf,
hiz_or_mcs_surf, and ccs_surf which have obvious meanings.  This does
mean that iris has to carry a bit of logic and we have to flip
parameters around in all the callers.  But the resulting interface is
much cleaner.

Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11479>

src/gallium/drivers/crocus/crocus_resource.c
src/gallium/drivers/iris/iris_resource.c
src/intel/isl/isl.c
src/intel/isl/isl.h
src/intel/vulkan/anv_image.c
src/mesa/drivers/dri/i965/brw_mipmap_tree.c
src/mesa/drivers/dri/i965/brw_screen.c

index c2e96bc..d058e09 100644 (file)
@@ -465,8 +465,8 @@ crocus_resource_configure_aux(struct crocus_screen *screen,
    const bool has_ccs =
       ((devinfo->ver >= 7 && !res->mod_info && !(INTEL_DEBUG & DEBUG_NO_RBC)) ||
        (res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE)) &&
-      isl_surf_get_ccs_surf(&screen->isl_dev, &res->surf, &res->aux.surf,
-                            NULL, 0);
+      isl_surf_get_ccs_surf(&screen->isl_dev, &res->surf, NULL,
+                            &res->aux.surf, 0);
 
    /* Having more than one type of compression is impossible */
    assert(has_ccs + has_mcs + has_hiz <= 1);
index 35a0ece..5bdc7a2 100644 (file)
@@ -671,6 +671,31 @@ iris_resource_configure_main(const struct iris_screen *screen,
    return true;
 }
 
+static bool
+iris_get_ccs_surf(const struct isl_device *dev,
+                  const struct isl_surf *surf,
+                  struct isl_surf *aux_surf,
+                  struct isl_surf *extra_aux_surf,
+                  uint32_t row_pitch_B)
+{
+   assert(extra_aux_surf->size_B == 0);
+
+   struct isl_surf *ccs_surf;
+   const struct isl_surf *hiz_or_mcs_surf;
+   if (aux_surf->size_B > 0) {
+      assert(aux_surf->usage & (ISL_SURF_USAGE_HIZ_BIT |
+                                ISL_SURF_USAGE_MCS_BIT));
+      hiz_or_mcs_surf = aux_surf;
+      ccs_surf = extra_aux_surf;
+   } else {
+      hiz_or_mcs_surf = NULL;
+      ccs_surf = aux_surf;
+   }
+
+   return isl_surf_get_ccs_surf(dev, surf, hiz_or_mcs_surf,
+                                ccs_surf, row_pitch_B);
+}
+
 /**
  * Configure aux for the resource, but don't allocate it. For images which
  * might be shared with modifiers, we must allocate the image and aux data in
@@ -703,21 +728,12 @@ iris_resource_configure_aux(struct iris_screen *screen,
    const bool has_ccs =
       ((!res->mod_info && !(INTEL_DEBUG & DEBUG_NO_RBC)) ||
        (res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE)) &&
-      isl_surf_get_ccs_surf(&screen->isl_dev, &res->surf, &res->aux.surf,
-                            &res->aux.extra_aux.surf, 0);
+      iris_get_ccs_surf(&screen->isl_dev, &res->surf, &res->aux.surf,
+                        &res->aux.extra_aux.surf, 0);
 
    /* Having both HIZ and MCS is impossible. */
    assert(!has_mcs || !has_hiz);
 
-   /* Ensure aux surface creation for MCS_CCS and HIZ_CCS is correct. */
-   if (has_ccs && (has_mcs || has_hiz)) {
-      assert(res->aux.extra_aux.surf.size_B > 0 &&
-             res->aux.extra_aux.surf.usage & ISL_SURF_USAGE_CCS_BIT);
-      assert(res->aux.surf.size_B > 0 &&
-             res->aux.surf.usage &
-             (ISL_SURF_USAGE_HIZ_BIT | ISL_SURF_USAGE_MCS_BIT));
-   }
-
    if (res->mod_info && has_ccs) {
       /* Only allow a CCS modifier if the aux was created successfully. */
       res->aux.possible_usages |= 1 << res->mod_info->aux_usage;
index ed52b37..a837844 100644 (file)
@@ -2176,20 +2176,10 @@ isl_surf_supports_ccs(const struct isl_device *dev,
 bool
 isl_surf_get_ccs_surf(const struct isl_device *dev,
                       const struct isl_surf *surf,
-                      struct isl_surf *aux_surf,
-                      struct isl_surf *extra_aux_surf,
+                      const struct isl_surf *hiz_or_mcs_surf,
+                      struct isl_surf *ccs_surf,
                       uint32_t row_pitch_B)
 {
-   assert(aux_surf);
-   if (aux_surf->size_B > 0)
-      assert(extra_aux_surf);
-   assert(!(aux_surf->usage & ISL_SURF_USAGE_CCS_BIT));
-
-   const struct isl_surf *hiz_or_mcs_surf =
-      aux_surf->size_B > 0 ? aux_surf : NULL;
-   struct isl_surf *ccs_surf =
-      aux_surf->size_B > 0 ? extra_aux_surf : aux_surf;
-
    if (!isl_surf_supports_ccs(dev, surf, hiz_or_mcs_surf))
       return false;
 
index 4b18fbe..49a6c90 100644 (file)
@@ -2228,8 +2228,8 @@ isl_surf_get_mcs_surf(const struct isl_device *dev,
 bool
 isl_surf_get_ccs_surf(const struct isl_device *dev,
                       const struct isl_surf *surf,
-                      struct isl_surf *aux_surf,
-                      struct isl_surf *extra_aux_surf,
+                      const struct isl_surf *hiz_or_mcs_surf,
+                      struct isl_surf *ccs_surf,
                       uint32_t row_pitch_B /**< Ignored if 0 */);
 
 #define isl_surf_fill_state(dev, state, ...) \
index 9453f3f..c1e6e5c 100644 (file)
@@ -651,8 +651,9 @@ add_aux_surface_if_supported(struct anv_device *device,
 
       ok = isl_surf_get_ccs_surf(&device->isl_dev,
                                  &image->planes[plane].primary_surface.isl,
+                                 NULL,
                                  &image->planes[plane].aux_surface.isl,
-                                 NULL, stride);
+                                 stride);
       if (!ok)
          return VK_SUCCESS;
 
index 31949e4..9165efc 100644 (file)
@@ -728,8 +728,8 @@ create_ccs_buf_for_image(struct brw_context *brw,
    /* We shouldn't already have a CCS */
    assert(!mt->aux_buf);
 
-   if (!isl_surf_get_ccs_surf(&brw->isl_dev, &mt->surf, &temp_ccs_surf, NULL,
-                              image->aux_pitch))
+   if (!isl_surf_get_ccs_surf(&brw->isl_dev, &mt->surf, NULL,
+                              &temp_ccs_surf, image->aux_pitch))
       return false;
 
    assert(image->aux_offset < image->bo->size);
@@ -1576,7 +1576,7 @@ brw_miptree_alloc_aux(struct brw_context *brw, struct brw_mipmap_tree *mt)
       initial_state = ISL_AUX_STATE_PASS_THROUGH;
       memset_value = 0;
       aux_surf_ok =
-         isl_surf_get_ccs_surf(&brw->isl_dev, &mt->surf, &aux_surf, NULL, 0);
+         isl_surf_get_ccs_surf(&brw->isl_dev, &mt->surf, NULL, &aux_surf, 0);
       break;
 
    default:
index 32f220c..5681111 100644 (file)
@@ -792,7 +792,7 @@ brw_create_image_common(__DRIscreen *dri_screen,
 
    struct isl_surf aux_surf = {0,};
    if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E) {
-      ok = isl_surf_get_ccs_surf(&screen->isl_dev, &surf, &aux_surf, NULL, 0);
+      ok = isl_surf_get_ccs_surf(&screen->isl_dev, &surf, NULL, &aux_surf, 0);
       if (!ok) {
          free(image);
          return NULL;
@@ -1233,7 +1233,7 @@ brw_create_image_from_fds_common(__DRIscreen *dri_screen,
       }
 
       struct isl_surf aux_surf = {0,};
-      ok = isl_surf_get_ccs_surf(&screen->isl_dev, &surf, &aux_surf, NULL,
+      ok = isl_surf_get_ccs_surf(&screen->isl_dev, &surf, NULL, &aux_surf,
                                  image->aux_pitch);
       if (!ok) {
          brw_bo_unreference(image->bo);