ilo: add ILO_DEBUG=flush
authorChia-I Wu <olvaffe@gmail.com>
Tue, 20 Aug 2013 03:40:49 +0000 (11:40 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 20 Aug 2013 05:54:39 +0000 (13:54 +0800)
When specified, ilo will print a line similar to

  cp flushed for render with 949+888 DWords (22.4%) because of frame end

for every ilo_cp_flush() call.

src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_3d_pipeline.c
src/gallium/drivers/ilo/ilo_blitter_blt.c
src/gallium/drivers/ilo/ilo_common.h
src/gallium/drivers/ilo/ilo_context.c
src/gallium/drivers/ilo/ilo_cp.c
src/gallium/drivers/ilo/ilo_cp.h
src/gallium/drivers/ilo/ilo_query.c
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/ilo/ilo_transfer.c

index 3a810adf6f6558f2bc52c859ca1eeedf7ca6373f..c7e5014075a17d0ee1a9f0837202283de2a78434 100644 (file)
@@ -402,7 +402,7 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_context *ilo,
    }
 
    if (max_len > ilo_cp_space(hw3d->cp)) {
-      ilo_cp_flush(hw3d->cp);
+      ilo_cp_flush(hw3d->cp, "out of space");
       need_flush = false;
       assert(max_len <= ilo_cp_space(hw3d->cp));
    }
@@ -782,7 +782,7 @@ ilo_texture_barrier(struct pipe_context *pipe)
 
    /* don't know why */
    if (ilo->dev->gen >= ILO_GEN(7))
-      ilo_cp_flush(hw3d->cp);
+      ilo_cp_flush(hw3d->cp, "texture barrier");
 }
 
 static void
index dee3e0ce542d757e9e0a62431f5171d5956c374d..afe1e4c09b346aff16b4905b56ad1b085c6c4273 100644 (file)
@@ -198,7 +198,7 @@ ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
       }
       else {
          /* flush and try again */
-         ilo_cp_flush(p->cp);
+         ilo_cp_flush(p->cp, "out of aperture");
       }
    }
 
index 80c0dcc46d685ff99cf75fa9e9828385dafe78b8..4e501f14bf13e54c9305faa5e78d68254ac271a3 100644 (file)
@@ -349,7 +349,7 @@ ilo_blitter_blt_begin(struct ilo_blitter *blitter, int max_cmd_size,
    }
 
    if (intel_winsys_check_aperture_space(ilo->winsys, aper_check, count))
-      ilo_cp_flush(ilo->cp);
+      ilo_cp_flush(ilo->cp, "out of aperture");
 
    /* set BCS_SWCTRL */
    swctrl = 0x0;
@@ -371,7 +371,7 @@ ilo_blitter_blt_begin(struct ilo_blitter *blitter, int max_cmd_size,
        * batch buffer.
        */
       if (ilo_cp_space(ilo->cp) < (4 + 3) * 2 + max_cmd_size)
-         ilo_cp_flush(ilo->cp);
+         ilo_cp_flush(ilo->cp, "out of space");
 
       ilo_cp_assert_no_implicit_flush(ilo->cp, true);
 
index dd87734517c6c7983a68b7b3ae14d131c7194d50..6db94b91c04987f98a5e1af94ef022914b8a38c6 100644 (file)
@@ -57,6 +57,7 @@ enum ilo_debug {
    ILO_DEBUG_FS        = 1 << 3,
    ILO_DEBUG_CS        = 1 << 4,
    ILO_DEBUG_DRAW      = ILO_DEBUG_HOT << 5,
+   ILO_DEBUG_FLUSH     = 1 << 6,
 
    /* flags that affect the behaviors of the driver */
    ILO_DEBUG_NOHW      = 1 << 20,
index 7fd5ab6b524d4db9adf255d2c20174222200a1a9..1f8aa232a46758168427fe93e94b8c6b214dc871 100644 (file)
@@ -84,7 +84,8 @@ ilo_flush(struct pipe_context *pipe,
       *f = (struct pipe_fence_handle *) fence;
    }
 
-   ilo_cp_flush(ilo->cp);
+   ilo_cp_flush(ilo->cp,
+         (flags & PIPE_FLUSH_END_OF_FRAME) ? "frame end" : "user request");
 }
 
 static void
index 82668df5e70526d9f78af1dc3a7a8e73087b17bc..85d40aa7a5fcc58efb0171f6aa345992a5debb9a 100644 (file)
@@ -220,7 +220,7 @@ ilo_cp_exec_bo(struct ilo_cp *cp)
  * is empty, the callback is not invoked.
  */
 void
-ilo_cp_flush(struct ilo_cp *cp)
+ilo_cp_flush_internal(struct ilo_cp *cp)
 {
    int err;
 
index d551225a23547373806c1b21edd22f79fef4eebd..6d6bb16716e01b7ce4d0f50523eadd498a6a61a6 100644 (file)
@@ -91,7 +91,21 @@ void
 ilo_cp_destroy(struct ilo_cp *cp);
 
 void
-ilo_cp_flush(struct ilo_cp *cp);
+ilo_cp_flush_internal(struct ilo_cp *cp);
+
+static inline void
+ilo_cp_flush(struct ilo_cp *cp, const char *reason)
+{
+   if (ilo_debug & ILO_DEBUG_FLUSH) {
+      ilo_printf("cp flushed for %s with %d+%d DWords (%.1f%%) because of %s\n",
+            (cp->ring == ILO_CP_RING_RENDER) ? "render" : "blt",
+             cp->used, cp->stolen,
+             (float) (100 * (cp->used + cp->stolen)) / cp->bo_size,
+             reason);
+   }
+
+   ilo_cp_flush_internal(cp);
+}
 
 void
 ilo_cp_dump(struct ilo_cp *cp);
@@ -132,7 +146,7 @@ ilo_cp_implicit_flush(struct ilo_cp *cp)
       cp->used = 0;
    }
 
-   ilo_cp_flush(cp);
+   ilo_cp_flush(cp, "out of space (implicit)");
 }
 
 /**
index 6f2956ec6f412e433e85ee26d940a8c841d3be70..5154ddbdefc9200928e82965bb045546181362b3 100644 (file)
@@ -169,7 +169,7 @@ ilo_get_query_result(struct pipe_context *pipe, struct pipe_query *query,
 
    if (q->bo) {
       if (intel_bo_references(ilo->cp->bo, q->bo))
-         ilo_cp_flush(ilo->cp);
+         ilo_cp_flush(ilo->cp, "syncing for queries");
 
       if (!wait && intel_bo_is_busy(q->bo))
          return false;
index 6d5b2ffbd97f5321492666ea1ac5ae9565a9f92a..3f8d4319c91b761c1e4ddddb20d4df31cbac9c47 100644 (file)
@@ -47,6 +47,7 @@ static const struct debug_named_value ilo_debug_flags[] = {
    { "fs",        ILO_DEBUG_FS,       "Dump fragment shaders" },
    { "cs",        ILO_DEBUG_CS,       "Dump compute shaders" },
    { "draw",      ILO_DEBUG_DRAW,     "Show draw information" },
+   { "flush",     ILO_DEBUG_FLUSH,    "Show batch buffer flushes" },
    { "nohw",      ILO_DEBUG_NOHW,     "Do not send commands to HW" },
    { "nocache",   ILO_DEBUG_NOCACHE,  "Always invalidate HW caches" },
    DEBUG_NAMED_VALUE_END
index 9f68d4ad9761b8f0f44ecafe1e0f33e8dc73077c..7d87537e99f5022ef6b371f7387e18bb6f5428ed 100644 (file)
@@ -165,7 +165,7 @@ choose_transfer_method(struct ilo_context *ilo, struct ilo_transfer *xfer)
 
          /* flush to make bo busy (so that map() stalls as it should be) */
          if (need_flush)
-            ilo_cp_flush(ilo->cp);
+            ilo_cp_flush(ilo->cp, "syncing for transfers");
       }
    }
 
@@ -938,7 +938,7 @@ buf_pwrite(struct ilo_context *ilo, struct ilo_buffer *buf,
 
       /* flush to make bo busy (so that pwrite() stalls as it should be) */
       if (will_stall && need_flush)
-         ilo_cp_flush(ilo->cp);
+         ilo_cp_flush(ilo->cp, "syncing for pwrites");
    }
 
    intel_bo_pwrite(buf->bo, offset, size, data);