From 8bf2b5db786b8608ddd7c83fffa695ae011bf6b3 Mon Sep 17 00:00:00 2001 From: Erico Nunes Date: Sat, 7 Dec 2019 04:38:03 +0100 Subject: [PATCH] gallium/util: add alignment parameter to util_upload_index_buffer At least on Mali Utgard, index buffers need to be aligned on 0x40. To avoid duplicating this, add an alignment parameter. Keep the previous default for the other existing users. Signed-off-by: Erico Nunes Reviewed-by: Eric Anholt Part-of: --- src/gallium/auxiliary/util/u_helpers.c | 4 ++-- src/gallium/auxiliary/util/u_helpers.h | 2 +- src/gallium/drivers/etnaviv/etnaviv_context.c | 2 +- src/gallium/drivers/freedreno/freedreno_draw.c | 2 +- src/gallium/drivers/lima/lima_draw.c | 2 +- src/gallium/drivers/zink/zink_draw.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c index 00a1a9791fa..5e5eeedbf45 100644 --- a/src/gallium/auxiliary/util/u_helpers.c +++ b/src/gallium/auxiliary/util/u_helpers.c @@ -144,12 +144,12 @@ bool util_upload_index_buffer(struct pipe_context *pipe, const struct pipe_draw_info *info, struct pipe_resource **out_buffer, - unsigned *out_offset) + unsigned *out_offset, unsigned alignment) { unsigned start_offset = info->start * info->index_size; u_upload_data(pipe->stream_uploader, start_offset, - info->count * info->index_size, 4, + info->count * info->index_size, alignment, (char*)info->index.user + start_offset, out_offset, out_buffer); u_upload_unmap(pipe->stream_uploader); diff --git a/src/gallium/auxiliary/util/u_helpers.h b/src/gallium/auxiliary/util/u_helpers.h index 16c4295deb5..09a95a7ab70 100644 --- a/src/gallium/auxiliary/util/u_helpers.h +++ b/src/gallium/auxiliary/util/u_helpers.h @@ -54,7 +54,7 @@ void util_set_shader_buffers_mask(struct pipe_shader_buffer *dst, bool util_upload_index_buffer(struct pipe_context *pipe, const struct pipe_draw_info *info, struct pipe_resource **out_buffer, - unsigned *out_offset); + unsigned *out_offset, unsigned alignment); void util_pin_driver_threads_to_random_L3(struct pipe_context *ctx, diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 97eab014b56..5f455c4412a 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -226,7 +226,7 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) if (info->index_size) { indexbuf = info->has_user_indices ? NULL : info->index.resource; if (info->has_user_indices && - !util_upload_index_buffer(pctx, info, &indexbuf, &index_offset)) { + !util_upload_index_buffer(pctx, info, &indexbuf, &index_offset, 4)) { BUG("Index buffer upload failed."); return; } diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index c1e0afad7e9..a4724221b12 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -101,7 +101,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) struct pipe_draw_info new_info; if (info->index_size) { if (info->has_user_indices) { - if (!util_upload_index_buffer(pctx, info, &indexbuf, &index_offset)) + if (!util_upload_index_buffer(pctx, info, &indexbuf, &index_offset, 4)) return; new_info = *info; new_info.index.resource = indexbuf; diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 768e2c8ce05..02d6baadb74 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -848,7 +848,7 @@ lima_pack_plbu_cmd(struct lima_context *ctx, const struct pipe_draw_info *info) unsigned index_offset = 0; struct lima_resource *res; if (info->has_user_indices) { - util_upload_index_buffer(&ctx->base, info, &indexbuf, &index_offset); + util_upload_index_buffer(&ctx->base, info, &indexbuf, &index_offset, 0x40); res = lima_resource(indexbuf); } else diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index 1d276502ca9..76dcd30783d 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -149,7 +149,7 @@ zink_draw_vbo(struct pipe_context *pctx, struct pipe_resource *index_buffer = NULL; if (dinfo->index_size > 0) { if (dinfo->has_user_indices) { - if (!util_upload_index_buffer(pctx, dinfo, &index_buffer, &index_offset)) { + if (!util_upload_index_buffer(pctx, dinfo, &index_buffer, &index_offset, 4)) { debug_printf("util_upload_index_buffer() failed\n"); return; } -- 2.30.2