gallium/util: add alignment parameter to util_upload_index_buffer
authorErico Nunes <nunes.erico@gmail.com>
Sat, 7 Dec 2019 03:38:03 +0000 (04:38 +0100)
committerErico Nunes <nunes.erico@gmail.com>
Sat, 14 Dec 2019 06:44:43 +0000 (07:44 +0100)
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>

src/gallium/auxiliary/util/u_helpers.c
src/gallium/auxiliary/util/u_helpers.h
src/gallium/drivers/etnaviv/etnaviv_context.c
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/lima/lima_draw.c
src/gallium/drivers/zink/zink_draw.c

index 00a1a9791fac0655fe473371d9a6ee5d76f8e992..5e5eeedbf45a92c44600ebc585e5c78469e8151a 100644 (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);
index 16c4295deb54be5b6da1aa4f1b6c78946f32fd03..09a95a7ab70ddc1042604c4702b5bf203e44225a 100644 (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,
index 97eab014b56561f1e376c7269483e430a2a17d3d..5f455c4412a9d696eeb54898b7226f2456f6b005 100644 (file)
@@ -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;
       }
index c1e0afad7e91a8945dc8e2564e6758207cd7b280..a4724221b12522e458c8ef8f8aeb526c48c4e2a5 100644 (file)
@@ -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;
index 768e2c8ce0568a0d2a3294e5c954c75d43e5793f..02d6baadb740044918d3f72037393c25bfead81e 100644 (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
index 1d276502ca9f78bca9eba7e67d261be5796d89d0..76dcd30783d995ff26c9ffe694d88e45a06af579 100644 (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;
          }