Mesa (master): freedreno: Split out helper for updating sw stats

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Mar 20 20:42:51 UTC 2021


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Sun Mar 14 10:09:28 2021 -0700

freedreno: Split out helper for updating sw stats

And while we're at it, handle the num_draws > 1 case, to prepare for
plumbing num_draws further down.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9581>

---

 src/gallium/drivers/freedreno/freedreno_draw.c | 53 +++++++++++++++-----------
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c
index 673fbaf50b5..a25eefb81e2 100644
--- a/src/gallium/drivers/freedreno/freedreno_draw.c
+++ b/src/gallium/drivers/freedreno/freedreno_draw.c
@@ -225,6 +225,36 @@ batch_draw_tracking(struct fd_batch *batch, const struct pipe_draw_info *info,
 	fd_screen_unlock(ctx->screen);
 }
 
+static void
+update_draw_stats(struct fd_context *ctx, const struct pipe_draw_info *info,
+		const struct pipe_draw_start_count *draws, unsigned num_draws)
+	assert_dt
+{
+	/* Counting prims in sw doesn't work for GS and tesselation. For older
+	 * gens we don't have those stages and don't have the hw counters enabled,
+	 * so keep the count accurate for non-patch geometry.
+	 */
+	unsigned prims = 0;
+	if ((info->mode != PIPE_PRIM_PATCHES) &&
+			(info->mode != PIPE_PRIM_MAX)) {
+		for (unsigned i = 0; i < num_draws; i++) {
+			prims += u_reduced_prims_for_vertices(info->mode, draws[i].count);
+		}
+	}
+
+	ctx->stats.draw_calls++;
+
+	/* TODO prims_emitted should be clipped when the stream-out buffer is
+	 * not large enough.  See max_tf_vtx().. probably need to move that
+	 * into common code.  Although a bit more annoying since a2xx doesn't
+	 * use ir3 so no common way to get at the pipe_stream_output_info
+	 * which is needed for this calculation.
+	 */
+	if (ctx->streamout.num_targets > 0)
+		ctx->stats.prims_emitted += prims;
+	ctx->stats.prims_generated += prims;
+}
+
 static void
 fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
             const struct pipe_draw_indirect_info *indirect,
@@ -318,28 +348,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
 	batch->back_blit = ctx->in_shadow;
 	batch->num_draws++;
 
-	/* Counting prims in sw doesn't work for GS and tesselation. For older
-	 * gens we don't have those stages and don't have the hw counters enabled,
-	 * so keep the count accurate for non-patch geometry.
-	 */
-	unsigned prims;
-	if ((info->mode != PIPE_PRIM_PATCHES) &&
-			(info->mode != PIPE_PRIM_MAX))
-		prims = u_reduced_prims_for_vertices(info->mode, draws[0].count);
-	else
-		prims = 0;
-
-	ctx->stats.draw_calls++;
-
-	/* TODO prims_emitted should be clipped when the stream-out buffer is
-	 * not large enough.  See max_tf_vtx().. probably need to move that
-	 * into common code.  Although a bit more annoying since a2xx doesn't
-	 * use ir3 so no common way to get at the pipe_stream_output_info
-	 * which is needed for this calculation.
-	 */
-	if (ctx->streamout.num_targets > 0)
-		ctx->stats.prims_emitted += prims;
-	ctx->stats.prims_generated += prims;
+	update_draw_stats(ctx, info, draws, num_draws);
 
 	/* Clearing last_fence must come after the batch dependency tracking
 	 * (resource_read()/resource_written()), as that can trigger a flush,



More information about the mesa-commit mailing list