From ce87c51e9ad131670fd8e4dcc0d023d0b057612b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 20 Aug 2013 11:40:49 +0800 Subject: [PATCH] ilo: add ILO_DEBUG=flush 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 | 4 ++-- src/gallium/drivers/ilo/ilo_3d_pipeline.c | 2 +- src/gallium/drivers/ilo/ilo_blitter_blt.c | 4 ++-- src/gallium/drivers/ilo/ilo_common.h | 1 + src/gallium/drivers/ilo/ilo_context.c | 3 ++- src/gallium/drivers/ilo/ilo_cp.c | 2 +- src/gallium/drivers/ilo/ilo_cp.h | 18 ++++++++++++++++-- src/gallium/drivers/ilo/ilo_query.c | 2 +- src/gallium/drivers/ilo/ilo_screen.c | 1 + src/gallium/drivers/ilo/ilo_transfer.c | 4 ++-- 10 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c index 3a810adf6f6..c7e5014075a 100644 --- a/src/gallium/drivers/ilo/ilo_3d.c +++ b/src/gallium/drivers/ilo/ilo_3d.c @@ -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 diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.c b/src/gallium/drivers/ilo/ilo_3d_pipeline.c index dee3e0ce542..afe1e4c09b3 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.c @@ -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"); } } diff --git a/src/gallium/drivers/ilo/ilo_blitter_blt.c b/src/gallium/drivers/ilo/ilo_blitter_blt.c index 80c0dcc46d6..4e501f14bf1 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_blt.c +++ b/src/gallium/drivers/ilo/ilo_blitter_blt.c @@ -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); diff --git a/src/gallium/drivers/ilo/ilo_common.h b/src/gallium/drivers/ilo/ilo_common.h index dd87734517c..6db94b91c04 100644 --- a/src/gallium/drivers/ilo/ilo_common.h +++ b/src/gallium/drivers/ilo/ilo_common.h @@ -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, diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c index 7fd5ab6b524..1f8aa232a46 100644 --- a/src/gallium/drivers/ilo/ilo_context.c +++ b/src/gallium/drivers/ilo/ilo_context.c @@ -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 diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c index 82668df5e70..85d40aa7a5f 100644 --- a/src/gallium/drivers/ilo/ilo_cp.c +++ b/src/gallium/drivers/ilo/ilo_cp.c @@ -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; diff --git a/src/gallium/drivers/ilo/ilo_cp.h b/src/gallium/drivers/ilo/ilo_cp.h index d551225a235..6d6bb16716e 100644 --- a/src/gallium/drivers/ilo/ilo_cp.h +++ b/src/gallium/drivers/ilo/ilo_cp.h @@ -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)"); } /** diff --git a/src/gallium/drivers/ilo/ilo_query.c b/src/gallium/drivers/ilo/ilo_query.c index 6f2956ec6f4..5154ddbdefc 100644 --- a/src/gallium/drivers/ilo/ilo_query.c +++ b/src/gallium/drivers/ilo/ilo_query.c @@ -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; diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 6d5b2ffbd97..3f8d4319c91 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -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 diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c index 9f68d4ad976..7d87537e99f 100644 --- a/src/gallium/drivers/ilo/ilo_transfer.c +++ b/src/gallium/drivers/ilo/ilo_transfer.c @@ -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); -- 2.30.2