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>
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);
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,
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;
}
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;
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
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;
}