By the way, apparently VC4 has this restriction as well. Eric Anholt covered more primitives in his logic, but also skipped trifans:
https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/vc4/vc4_draw.c#n431 I think it's worth copying some of that in here, or if you're feeling generous, making a shared helper that can be used in both places. Cheers, -ilia On Mon, Sep 17, 2018 at 3:36 PM, Ilia Mirkin <imir...@alum.mit.edu> wrote: > On Mon, Sep 17, 2018 at 2:22 PM, Jonathan Marek <jonat...@marek.ca> wrote: >> a20x can only draw 65535 vertices at once. this fix only applies to >> triangles. >> >> Signed-off-by: Jonathan Marek <jonat...@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) > > Should be fine for POINTS too, no? > > Other primitives require incrementally more work ... > > LINES: use 0xfffe. > TRIANGLE_STRIP/LINE_STRIP: back up info->start by 2/1 vertices, and > draw an extra primitive. > TRI_FAN: not easy :( could probably do something with an index buffer. > > Hopefully primitive restart isn't enabled for a2xx... > >> + 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; > > Should both of these be += info.count? And then you don't need the > ->num_vertices = num_vertices hack at the end? > >> + 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 >> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev