iris: Better determine map_would_stall for Z/S
[mesa.git] / src / gallium / drivers / iris / iris_resource.c
index f1040073ed6c72c9cc0e4e4513c19b46877f0f26..bfd79603ee879a90916e26fdad5edde3fcdea039 100644 (file)
@@ -1788,28 +1788,12 @@ iris_transfer_map(struct pipe_context *ctx,
       usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
    }
 
-   bool need_resolve = false;
-   bool need_color_resolve = false;
-
-   if (resource->target != PIPE_BUFFER) {
-      bool need_hiz_resolve = iris_resource_level_has_hiz(res, level);
-      bool need_stencil_resolve = res->aux.usage == ISL_AUX_USAGE_STC_CCS;
-
-      need_color_resolve =
-         (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);
-
-      need_resolve = need_color_resolve ||
-                     need_hiz_resolve ||
-                     need_stencil_resolve;
-   }
-
    bool map_would_stall = false;
 
    if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
-      map_would_stall = need_resolve || resource_is_busy(ice, res);
+      map_would_stall =
+         resource_is_busy(ice, res) ||
+         iris_has_invalid_primary(res, level, 1, box->z, box->depth);
 
       if (map_would_stall && (usage & PIPE_TRANSFER_DONTBLOCK) &&
                              (usage & PIPE_TRANSFER_MAP_DIRECTLY))
@@ -1856,21 +1840,27 @@ iris_transfer_map(struct pipe_context *ctx,
     * read from the original buffer, we'd simply copy it to a temporary...
     * then stall (a bit longer) to read from that buffer.
     *
-    * Images are less clear-cut.  Color resolves are destructive, removing
-    * the underlying compression, so we'd rather blit the data to a linear
+    * Images are less clear-cut.  Resolves can be destructive, removing some
+    * of the underlying compression, so we'd rather blit the data to a linear
     * temporary and map that, to avoid the resolve.  (It might be better to
     * a tiled temporary and use the tiled_memcpy paths...)
     */
-   if (!(usage & PIPE_TRANSFER_DISCARD_RANGE) && !need_color_resolve)
+   if (!(usage & PIPE_TRANSFER_DISCARD_RANGE) &&
+       !iris_has_invalid_primary(res, level, 1, box->z, box->depth)) {
       no_gpu = true;
+   }
 
    const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
    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.
        */
@@ -1880,7 +1870,7 @@ iris_transfer_map(struct pipe_context *ctx,
    } else {
       /* Otherwise we're free to map on the CPU. */
 
-      if (need_resolve) {
+      if (resource->target != PIPE_BUFFER) {
          iris_resource_access_raw(ice, res, level, box->z, box->depth,
                                   usage & PIPE_TRANSFER_WRITE);
       }