Mesa (main): isl,iris: Move the extra_aux_surf logic into iris

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 24 14:21:03 UTC 2021


Module: Mesa
Branch: main
Commit: 94a52bc85cd1f75eae66c9b1c03272b1a68ff5fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=94a52bc85cd1f75eae66c9b1c03272b1a68ff5fd

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Jun 23 16:48:36 2021 -0500

isl,iris: Move the extra_aux_surf logic into iris

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 at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11479>

---

 src/gallium/drivers/crocus/crocus_resource.c |  4 +--
 src/gallium/drivers/iris/iris_resource.c     | 38 ++++++++++++++++++++--------
 src/intel/isl/isl.c                          | 14 ++--------
 src/intel/isl/isl.h                          |  4 +--
 src/intel/vulkan/anv_image.c                 |  3 ++-
 src/mesa/drivers/dri/i965/brw_mipmap_tree.c  |  6 ++---
 src/mesa/drivers/dri/i965/brw_screen.c       |  4 +--
 7 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c
index c2e96bc1ebb..d058e0928e4 100644
--- a/src/gallium/drivers/crocus/crocus_resource.c
+++ b/src/gallium/drivers/crocus/crocus_resource.c
@@ -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);
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 35a0ecef538..5bdc7a2b62c 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -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;
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index ed52b37747b..a8378444f8b 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -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;
 
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 4b18fbefc89..49a6c90744b 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -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, ...) \
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 9453f3f2141..c1e6e5c8763 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -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;
 
diff --git a/src/mesa/drivers/dri/i965/brw_mipmap_tree.c b/src/mesa/drivers/dri/i965/brw_mipmap_tree.c
index 31949e41a2a..9165efc55e7 100644
--- a/src/mesa/drivers/dri/i965/brw_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/brw_mipmap_tree.c
@@ -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:
diff --git a/src/mesa/drivers/dri/i965/brw_screen.c b/src/mesa/drivers/dri/i965/brw_screen.c
index 32f220c0611..56811110567 100644
--- a/src/mesa/drivers/dri/i965/brw_screen.c
+++ b/src/mesa/drivers/dri/i965/brw_screen.c
@@ -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);



More information about the mesa-commit mailing list