vbo: fix a index buffer map failure with size = 0 in get_minmax_indices_gallium

Fixes: 85b6ba136b "st/mesa: implement Driver.DrawGallium callbacks

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8345>
This commit is contained in:
Marek Olšák 2021-01-05 23:14:08 -05:00 committed by Marge Bot
parent 3c75473525
commit c69b8fd651
3 changed files with 11 additions and 3 deletions

View File

@ -238,7 +238,10 @@ prepare_indexed_draw(/* pass both st and ctx to reduce dereferences */
/* Get index bounds for user buffers. */
if (!info->index_bounds_valid &&
st->draw_needs_minmax_index) {
vbo_get_minmax_indices_gallium(ctx, info, draws, num_draws);
/* Return if this fails, which means all draws have count == 0. */
if (!vbo_get_minmax_indices_gallium(ctx, info, draws, num_draws))
return false;
info->index_bounds_valid = true;
}

View File

@ -256,7 +256,7 @@ vbo_get_minmax_indices(struct gl_context *ctx, const struct _mesa_prim *prim,
bool primitive_restart,
unsigned restart_index);
void
bool
vbo_get_minmax_indices_gallium(struct gl_context *ctx,
struct pipe_draw_info *info,
const struct pipe_draw_start_count *draws,

View File

@ -398,7 +398,7 @@ vbo_get_minmax_indices(struct gl_context *ctx,
/**
* Same as vbo_get_minmax_index, but using gallium draw structures.
*/
void
bool
vbo_get_minmax_indices_gallium(struct gl_context *ctx,
struct pipe_draw_info *info,
const struct pipe_draw_start_count *draws,
@ -417,6 +417,9 @@ vbo_get_minmax_indices_gallium(struct gl_context *ctx,
i++;
}
if (!draw.count)
continue;
unsigned tmp_min, tmp_max;
vbo_get_minmax_index(ctx, info->has_user_indices ?
NULL : info->index.gl_bo,
@ -428,4 +431,6 @@ vbo_get_minmax_indices_gallium(struct gl_context *ctx,
info->min_index = MIN2(info->min_index, tmp_min);
info->max_index = MAX2(info->max_index, tmp_max);
}
return info->min_index <= info->max_index;
}