iris: Refactor the assignment to possible_usages
authorNanley Chery <nanley.g.chery@intel.com>
Tue, 20 Jul 2021 18:46:51 +0000 (11:46 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 21 Oct 2021 20:21:26 +0000 (20:21 +0000)
* Make the outer if-ladder dependent on the has_* variables.
* Make the possible_usages assignments happen at the same nesting level.
* Move the combined HIZ/MCS assert closer to relevant if-else blocks.

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

src/gallium/drivers/iris/iris_resource.c

index 35dc31c..8610a55 100644 (file)
@@ -743,18 +743,17 @@ iris_resource_configure_aux(struct iris_screen *screen,
       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);
-
-   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;
-   } else if (has_mcs) {
+   if (has_mcs) {
       assert(!res->mod_info);
-      res->aux.possible_usages |=
-         1 << (has_ccs ? ISL_AUX_USAGE_MCS_CCS : ISL_AUX_USAGE_MCS);
+      assert(!has_hiz);
+      if (has_ccs) {
+         res->aux.possible_usages |= 1 << ISL_AUX_USAGE_MCS_CCS;
+      } else {
+         res->aux.possible_usages |= 1 << ISL_AUX_USAGE_MCS;
+      }
    } else if (has_hiz) {
       assert(!res->mod_info);
+      assert(!has_mcs);
       if (!has_ccs) {
          res->aux.possible_usages |= 1 << ISL_AUX_USAGE_HIZ;
       } else if (res->surf.samples == 1 &&
@@ -767,10 +766,12 @@ iris_resource_configure_aux(struct iris_screen *screen,
       } else {
          res->aux.possible_usages |= 1 << ISL_AUX_USAGE_HIZ_CCS;
       }
-   } else if (has_ccs && isl_surf_usage_is_stencil(res->surf.usage)) {
-      res->aux.possible_usages |= 1 << ISL_AUX_USAGE_STC_CCS;
    } else if (has_ccs) {
-      if (want_ccs_e_for_format(devinfo, res->surf.format)) {
+      if (res->mod_info) {
+         res->aux.possible_usages |= 1 << res->mod_info->aux_usage;
+      } else if (isl_surf_usage_is_stencil(res->surf.usage)) {
+         res->aux.possible_usages |= 1 << ISL_AUX_USAGE_STC_CCS;
+      } else if (want_ccs_e_for_format(devinfo, res->surf.format)) {
          res->aux.possible_usages |= devinfo->ver < 12 ?
             1 << ISL_AUX_USAGE_CCS_E : 1 << ISL_AUX_USAGE_GFX12_CCS_E;
       } else if (isl_format_supports_ccs_d(devinfo, res->surf.format)) {