iris: Make iris_has_color_unresolved more generic
[mesa.git] / src / gallium / drivers / iris / iris_resource.c
index 212fa803ceac20c3eb6216c0009b2c0636d8942f..3396678154c63c44ea03e8a2050f140be266aa89 100644 (file)
@@ -1183,6 +1183,7 @@ iris_resource_get_handle(struct pipe_screen *pscreen,
 
 #ifndef NDEBUG
    enum isl_aux_usage allowed_usage =
+      usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH ? res->aux.usage :
       res->mod_info ? res->mod_info->aux_usage : ISL_AUX_USAGE_NONE;
 
    if (res->aux.usage != allowed_usage) {
@@ -1798,7 +1799,7 @@ iris_transfer_map(struct pipe_context *ctx,
          (res->aux.usage == ISL_AUX_USAGE_CCS_D ||
           res->aux.usage == ISL_AUX_USAGE_CCS_E ||
           res->aux.usage == ISL_AUX_USAGE_GEN12_CCS_E) &&
-         iris_has_color_unresolved(res, level, 1, box->z, box->depth);
+         iris_has_invalid_primary(res, level, 1, box->z, box->depth);
 
       need_resolve = need_color_resolve ||
                      need_hiz_resolve ||
@@ -1867,9 +1868,13 @@ iris_transfer_map(struct pipe_context *ctx,
    if (fmtl->txc == ISL_TXC_ASTC)
       no_gpu = true;
 
-   if ((map_would_stall ||
-        res->aux.usage == ISL_AUX_USAGE_CCS_E ||
-        res->aux.usage == ISL_AUX_USAGE_GEN12_CCS_E) && !no_gpu) {
+   if (!map_would_stall &&
+       res->aux.usage != ISL_AUX_USAGE_CCS_E &&
+       res->aux.usage != ISL_AUX_USAGE_GEN12_CCS_E) {
+      no_gpu = true;
+   }
+
+   if (!no_gpu) {
       /* If we need a synchronous mapping and the resource is busy, or needs
        * resolving, we copy to/from a linear temporary buffer using the GPU.
        */