From 7daff157bb3474373a03fceb1ffd2c98f115653e Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Tue, 20 Jul 2021 11:46:51 -0700 Subject: [PATCH] iris: Refactor the assignment to possible_usages * 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 Part-of: --- src/gallium/drivers/iris/iris_resource.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 35dc31c..8610a55 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -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)) { -- 2.7.4