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 <nunes.erico@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2445>
This commit is contained in:
Erico Nunes
2019-12-07 04:38:03 +01:00
parent 9fb45c5bbd
commit 8bf2b5db78
6 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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,
@@ -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;
}
@@ -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;
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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;
}