[Mesa-dev] [PATCH 10/11] freedreno: a2xx: split large draws on a20x

Jonathan Marek jonathan at marek.ca
Mon Sep 17 18:22:19 UTC 2018


a20x can only draw 65535 vertices at once. this fix only applies to
triangles.

Signed-off-by: Jonathan Marek <jonathan at marek.ca>
---
 src/gallium/drivers/freedreno/a2xx/fd2_draw.c | 30 +++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c
index 1792505808..7ccbee587f 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c
@@ -171,8 +171,34 @@ fd2_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *pinfo,
 	fd2_emit_state(ctx, ctx->batch->draw, ctx->dirty);
 	fd2_emit_state(ctx, ctx->batch->binning, ctx->dirty);
 
-	draw_impl(ctx, pinfo, ctx->batch->draw, index_offset, false);
-	draw_impl(ctx, pinfo, ctx->batch->binning, index_offset, true);
+	/* a20x can only draw 65535 vertices at once... */
+	if (is_a20x(ctx->screen) && pinfo->count > 0xffff) {
+		struct pipe_draw_info info = *pinfo;
+		unsigned count = info.count;
+		unsigned num_vertices = ctx->batch->num_vertices;
+
+		/* other primitives require more work
+		 * (triangles works because 0xffff is divible by 3)
+		 */
+		if (info.mode != PIPE_PRIM_TRIANGLES)
+			return false;
+
+		for (; count; ) {
+			info.count = MIN2(count, 0xffff);
+
+			draw_impl(ctx, &info, ctx->batch->draw, index_offset, false);
+			draw_impl(ctx, &info, ctx->batch->binning, index_offset, true);
+
+			info.start += 0xffff;
+			ctx->batch->num_vertices += 0xffff;
+			count -= info.count;
+		}
+		/* changing this value is a hack, restore it */
+		ctx->batch->num_vertices = num_vertices;
+	} else {
+		draw_impl(ctx, pinfo, ctx->batch->draw, index_offset, false);
+		draw_impl(ctx, pinfo, ctx->batch->binning, index_offset, true);
+	}
 
 	fd_context_all_clean(ctx);
 
-- 
2.17.1



More information about the mesa-dev mailing list