Mesa (master): freedreno: don't overflow cmdstream buffer so much

Rob Clark robclark at kemper.freedesktop.org
Tue Sep 9 23:46:38 UTC 2014


Module: Mesa
Branch: master
Commit: 4f338c9bbff090d606afdc22373cc7869b0d0c89
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f338c9bbff090d606afdc22373cc7869b0d0c89

Author: Rob Clark <robclark at freedesktop.org>
Date:   Mon Sep  8 11:18:01 2014 -0400

freedreno: don't overflow cmdstream buffer so much

We currently aren't too clever about dealing with running out of
cmdstream buffer space.  Since we use a single buffer for both drawing
and tiling commands, we need to ensure there is enough space at the tail
of the cmdstream buffer to fit the tiling commands.

Until we get more clever, the easy solution is a threshold to trigger
flushing rendering even if the application does not trigger flush (swap,
changing render target, etc).  This way we at least don't crash for apps
that do several thousand draw calls (like some piglit tests do).

Signed-off-by: Rob Clark <robclark at freedesktop.org>

---

 src/gallium/drivers/freedreno/freedreno_draw.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c
index e3c8cc8..e463495 100644
--- a/src/gallium/drivers/freedreno/freedreno_draw.c
+++ b/src/gallium/drivers/freedreno/freedreno_draw.c
@@ -157,8 +157,23 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
 	/* and any buffers used, need to be resolved: */
 	ctx->resolve |= buffers;
 
+	DBG("%x num_draws=%u (%s/%s)", buffers, ctx->num_draws,
+		util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
+		util_format_short_name(pipe_surface_format(pfb->zsbuf)));
+
 	fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_DRAW);
 	ctx->draw(ctx, info);
+
+	/* if an app (or, well, piglit test) does many thousands of draws
+	 * without flush (or anything which implicitly flushes, like
+	 * changing render targets), we can exceed the ringbuffer size.
+	 * Since we don't currently have a sane way to wrapparound, and
+	 * we use the same buffer for both draw and tiling commands, for
+	 * now we need to do this hack and trigger flush if we are running
+	 * low on remaining space for cmds:
+	 */
+	if ((ctx->ring->cur - ctx->ring->start) > ctx->ring->size/8)
+		fd_context_render(pctx);
 }
 
 /* TODO figure out how to make better use of existing state mechanism




More information about the mesa-commit mailing list