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

Ilia Mirkin imirkin at alum.mit.edu
Mon Sep 17 19:36:39 UTC 2018


On Mon, Sep 17, 2018 at 2:22 PM, Jonathan Marek <jonathan at marek.ca> wrote:
> 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)

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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list