[Mesa-dev] [PATCH 3/3] intel/blorp_blit: Add option to dump surfaces on blits

Jordan Justen jordan.l.justen at intel.com
Wed Nov 16 08:56:58 UTC 2016


Enabling this option causes the source and destination surfaces to be
dumped out to debug files. The destination is dumped both before and
after the blit operation.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/intel/blorp/blorp_blit.c | 53 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index c0b56c3..c1c4219 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -28,6 +28,8 @@
 
 #define FILE_DEBUG_FLAG DEBUG_BLORP
 
+static const bool isl_surface_debug_dump = false;
+
 /**
  * Enum to specify the order of arguments in a sampler message
  */
@@ -1428,6 +1430,41 @@ surf_retile_w_to_y(const struct isl_device *isl_dev,
 }
 
 static void
+dump_blorp_surf(const struct blorp_context *blorp,
+                const struct brw_blorp_surface_info *surf,
+                const char *basename)
+{
+   void *map, *aux_map;
+   unsigned int size, aux_size;
+   bool was_mapped, aux_was_mapped;
+
+   blorp->map(blorp, &surf->addr, &map, &size, &was_mapped);
+   if (map == NULL)
+      return;
+
+   if (surf->aux_addr.buffer) {
+      blorp->map(blorp, &surf->aux_addr, &aux_map, &aux_size, &aux_was_mapped);
+      if (aux_map == NULL) {
+         if (!was_mapped)
+            blorp->unmap(blorp, &surf->addr);
+         return;
+      }
+   } else {
+      aux_map = NULL;
+      aux_size = 0;
+   }
+
+   isl_dump_surf(blorp->isl_dev, &surf->surf, map, size,
+                 aux_map ? &surf->aux_surf : NULL, aux_map, aux_size,
+                 basename);
+
+   if (!was_mapped)
+      blorp->unmap(blorp, &surf->addr);
+   if (surf->aux_addr.buffer && !aux_was_mapped)
+      blorp->unmap(blorp, &surf->aux_addr);
+}
+
+static void
 do_blorp_blit(struct blorp_batch *batch,
               struct blorp_params *params,
               struct brw_blorp_blit_prog_key *wm_prog_key,
@@ -1657,6 +1694,11 @@ blorp_blit(struct blorp_batch *batch,
    brw_blorp_surface_info_init(batch->blorp, &params.dst, dst_surf, dst_level,
                                dst_layer, dst_format, true);
 
+   if (isl_surface_debug_dump) {
+      dump_blorp_surf(batch->blorp, &params.src, "blorp-blit-src");
+      dump_blorp_surf(batch->blorp, &params.dst, "blorp-blit-dst-before");
+   }
+
    params.src.view.swizzle = src_swizzle;
    params.dst.view.swizzle = dst_swizzle;
 
@@ -1708,6 +1750,9 @@ blorp_blit(struct blorp_batch *batch,
                  src_x0, src_y0, src_x1, src_y1,
                  dst_x0, dst_y0, dst_x1, dst_y1,
                  mirror_x, mirror_y);
+
+   if (isl_surface_debug_dump)
+      dump_blorp_surf(batch->blorp, &params.dst, "blorp-blit-dst-after");
 }
 
 static enum isl_format
@@ -1850,6 +1895,11 @@ blorp_copy(struct blorp_batch *batch,
    brw_blorp_surface_info_init(batch->blorp, &params.dst, dst_surf, dst_level,
                                dst_layer, ISL_FORMAT_UNSUPPORTED, true);
 
+   if (isl_surface_debug_dump) {
+      dump_blorp_surf(batch->blorp, &params.src, "blorp-copy-src");
+      dump_blorp_surf(batch->blorp, &params.dst, "blorp-copy-dst-before");
+   }
+
    struct brw_blorp_blit_prog_key wm_prog_key;
    memset(&wm_prog_key, 0, sizeof(wm_prog_key));
 
@@ -1889,4 +1939,7 @@ blorp_copy(struct blorp_batch *batch,
                  src_x, src_y, src_x + src_width, src_y + src_height,
                  dst_x, dst_y, dst_x + dst_width, dst_y + dst_height,
                  false, false);
+
+   if (isl_surface_debug_dump)
+      dump_blorp_surf(batch->blorp, &params.dst, "blorp-copy-dst-after");
 }
-- 
2.10.2



More information about the mesa-dev mailing list