From 2d7be5f01f003855fce8dffdbd9ee17c60b134b3 Mon Sep 17 00:00:00 2001 From: Erico Nunes Date: Sat, 9 Nov 2019 13:50:07 +0100 Subject: [PATCH] lima: refactor indexed draw indices upload As of this commit this is just a refactor in preparation to enable support for more than 64k vertices. To support splitting the draw_vbo call, indices shouldn't be re-uploaded every time. Signed-off-by: Erico Nunes Reviewed-by: Vasily Khoruzhick Reviewed-by: Andreas Baierl Part-of: --- src/gallium/drivers/lima/lima_context.h | 3 +++ src/gallium/drivers/lima/lima_draw.c | 31 +++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/lima/lima_context.h b/src/gallium/drivers/lima/lima_context.h index abb35000ed8..1a0dee27885 100644 --- a/src/gallium/drivers/lima/lima_context.h +++ b/src/gallium/drivers/lima/lima_context.h @@ -244,6 +244,9 @@ struct lima_context { struct pipe_debug_callback debug; int pp_max_stack_size; + + unsigned index_offset; + struct lima_resource *index_res; }; static inline struct lima_context * diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 2e93e523f3e..0a6e9cc18ac 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -844,21 +844,7 @@ lima_pack_plbu_cmd(struct lima_context *ctx, const struct pipe_draw_info *info) PLBU_CMD_INDEXED_PT_SIZE(gl_point_size_va); } - struct pipe_resource *indexbuf = NULL; - unsigned index_offset = 0; - struct lima_resource *res; - if (info->has_user_indices) { - util_upload_index_buffer(&ctx->base, info, &indexbuf, &index_offset, 0x40); - res = lima_resource(indexbuf); - } - else - res = lima_resource(info->index.resource); - - lima_submit_add_bo(ctx->gp_submit, res->bo, LIMA_SUBMIT_BO_READ); - PLBU_CMD_INDICES(res->bo->va + info->start * info->index_size + index_offset); - - if (indexbuf) - pipe_resource_reference(&indexbuf, NULL); + PLBU_CMD_INDICES(ctx->index_res->bo->va + info->start * info->index_size + ctx->index_offset); } else { /* can this make the attribute info static? */ @@ -1341,6 +1327,7 @@ lima_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) } struct lima_context *ctx = lima_context(pctx); + struct pipe_resource *indexbuf = NULL; if (!ctx->vs || !ctx->fs) { debug_warn_once("no shader, skip draw\n"); @@ -1350,6 +1337,17 @@ lima_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) if (!lima_update_vs_state(ctx) || !lima_update_fs_state(ctx)) return; + if (info->index_size) { + if (info->has_user_indices) { + util_upload_index_buffer(&ctx->base, info, &indexbuf, &ctx->index_offset, 0x40); + ctx->index_res = lima_resource(indexbuf); + } + else + ctx->index_res = lima_resource(info->index.resource); + + lima_submit_add_bo(ctx->gp_submit, ctx->index_res->bo, LIMA_SUBMIT_BO_READ); + } + lima_dump_command_stream_print( ctx->vs->bo->map, ctx->vs->shader_size, false, "add vs at va %x\n", ctx->vs->bo->va); @@ -1406,6 +1404,9 @@ lima_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) } ctx->dirty = 0; + + if (indexbuf) + pipe_resource_reference(&indexbuf, NULL); } static void -- 2.30.2