[Mesa-dev] [PATCH 12/16] i965/blorp/blit: Refactor hiz/ccs prep for blits

Topi Pohjolainen topi.pohjolainen at gmail.com
Fri Feb 17 19:32:15 UTC 2017


They are explicitly considered for blits from now on. Currently
they are part of common surface preparation which is used by all
blorp ops. However, color/hiz/depth/stencil clears and resolves
use hiz/ccs without the tweaks.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_blorp.c | 95 ++++++++++++++++++++++++-----------
 1 file changed, 67 insertions(+), 28 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c
index 3247bd4..e3e4402 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -196,29 +196,9 @@ blorp_surf_for_miptree(struct brw_context *brw,
       if (surf->aux_usage == ISL_AUX_USAGE_HIZ) {
          /* If we're not going to use it as a depth buffer, resolve HiZ */
          if (!(safe_aux_usage & (1 << ISL_AUX_USAGE_HIZ))) {
-            for (unsigned i = 0; i < num_layers; i++) {
-               intel_miptree_slice_resolve_depth(brw, mt, *level,
-                                                 start_layer + i);
-
-               /* If we're rendering to it then we'll need a HiZ resolve once
-                * we're done before we can use it with HiZ again.
-                */
-               if (is_render_target)
-                  intel_miptree_slice_set_needs_hiz_resolve(mt, *level,
-                                                            start_layer + i);
-            }
             surf->aux_usage = ISL_AUX_USAGE_NONE;
          }
       } else if (!(safe_aux_usage & (1 << surf->aux_usage))) {
-         uint32_t flags = 0;
-         if (safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E))
-            flags |= INTEL_MIPTREE_IGNORE_CCS_E;
-
-         intel_miptree_resolve_color(brw, mt,
-                                     *level, start_layer, num_layers, flags);
-
-         assert(!intel_miptree_has_color_unresolved(mt, *level, 1,
-                                                    start_layer, num_layers));
          surf->aux_usage = ISL_AUX_USAGE_NONE;
       }
    }
@@ -335,11 +315,64 @@ physical_to_logical_layer(struct intel_mipmap_tree *mt,
    }
 }
 
+/* If we're not going to use it as a depth buffer, resolve HiZ */
+static bool
+prepare_hiz_for_blit(struct brw_context *brw,
+                     struct intel_mipmap_tree *mt,
+                     unsigned level, unsigned layer,
+                     bool is_render_target)
+{
+   if (!mt->hiz_buf)
+      return false;
+
+   const bool needs_sync =
+      intel_miptree_slice_resolve_depth(brw, mt, level, layer);
+
+   /* If we're rendering to it then we'll need a HiZ resolve once
+    * we're done before we can use it with HiZ again.
+    */
+   if (is_render_target)
+      intel_miptree_slice_set_needs_hiz_resolve(mt, level, layer);
+
+   return needs_sync;
+}
+
+static bool
+prepare_ccs_for_blit(struct brw_context *brw,
+                     struct intel_mipmap_tree *mt,
+                     unsigned level, unsigned layer,
+                     uint32_t safe_aux_usage)
+{
+   if (!mt->mcs_buf || mt->num_samples > 1)
+      return false;
+
+   if (intel_miptree_is_lossless_compressed(brw, mt) &&
+       safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E)) {
+      assert(brw->gen >= 9);
+      return false;
+   }
+
+   const bool needs_sync =
+      intel_miptree_resolve_color(brw, mt, level, layer, 1, 0);
+
+   assert(!intel_miptree_has_color_unresolved(mt, level, 1, layer, 1));
+
+   return needs_sync;
+}
+
 static void
 prepare_blit(struct brw_context *brw,
-             const struct intel_mipmap_tree *src_mt,
-             const struct intel_mipmap_tree *dst_mt)
+             struct intel_mipmap_tree *src_mt,
+             unsigned src_level, unsigned src_layer, uint32_t src_usage_flags,
+             struct intel_mipmap_tree *dst_mt,
+             unsigned dst_level, unsigned dst_layer, uint32_t dst_usage_flags)
 {
+   prepare_hiz_for_blit(brw, src_mt, src_level, src_layer, false);
+   prepare_hiz_for_blit(brw, dst_mt, dst_level, dst_layer, true);
+
+   prepare_ccs_for_blit(brw, src_mt, src_level, src_layer, src_usage_flags);
+   prepare_ccs_for_blit(brw, dst_mt, dst_level, dst_layer, dst_usage_flags);
+
    /* Flush the sampler and render caches.  We definitely need to flush the
     * sampler cache so that we get updated contents from the render cache for
     * the glBlitFramebuffer() source.  Also, we are sometimes warned in the
@@ -422,6 +455,10 @@ brw_blorp_blit_miptrees(struct brw_context *brw,
                          (1 << ISL_AUX_USAGE_CCS_D);
    }
 
+   prepare_blit(brw,
+                src_mt, src_level, src_layer, src_usage_flags,
+                dst_mt, dst_level, dst_layer, dst_usage_flags);
+
    struct isl_surf tmp_surfs[4];
    struct blorp_surf src_surf, dst_surf;
    blorp_surf_for_miptree(brw, &src_surf, src_mt, false, src_usage_flags,
@@ -467,15 +504,17 @@ brw_blorp_copy_miptrees(struct brw_context *brw,
        dst_mt->num_samples, _mesa_get_format_name(dst_mt->format), dst_mt,
        dst_level, dst_layer, dst_x, dst_y);
 
+   const uint32_t safe_usage_flags = (1 << ISL_AUX_USAGE_MCS) |
+                                     (1 << ISL_AUX_USAGE_CCS_E);
+   prepare_blit(brw,
+                src_mt, src_level, src_layer, safe_usage_flags,
+                dst_mt, dst_level, dst_layer, safe_usage_flags);
+
    struct isl_surf tmp_surfs[4];
    struct blorp_surf src_surf, dst_surf;
-   blorp_surf_for_miptree(brw, &src_surf, src_mt, false,
-                          (1 << ISL_AUX_USAGE_MCS) |
-                          (1 << ISL_AUX_USAGE_CCS_E),
+   blorp_surf_for_miptree(brw, &src_surf, src_mt, false, safe_usage_flags,
                           &src_level, src_layer, 1, &tmp_surfs[0]);
-   blorp_surf_for_miptree(brw, &dst_surf, dst_mt, true,
-                          (1 << ISL_AUX_USAGE_MCS) |
-                          (1 << ISL_AUX_USAGE_CCS_E),
+   blorp_surf_for_miptree(brw, &dst_surf, dst_mt, true, safe_usage_flags,
                           &dst_level, dst_layer, 1, &tmp_surfs[2]);
 
    struct blorp_batch batch;
-- 
2.5.5



More information about the mesa-dev mailing list