diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index fdde294..023573c 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -378,8 +378,22 @@ void _tnl_vbo_draw_prims(GLcontext *ctx, GLuint min_index, GLuint max_index) { - if (!index_bounds_valid) - vbo_get_minmax_index(ctx, prim, ib, &min_index, &max_index); + if (!index_bounds_valid) { + /* find min/max of all primitives' indexes */ + GLuint i; + for (i = 0; i < nr_prims; i++) { + GLuint min, max; + vbo_get_minmax_index(ctx, prim + i, ib, &min, &max); + if (i == 0) { + min_index = min; + max_index = max; + } + else { + min_index = MIN2(min_index, min); + max_index = MAX2(max_index, max); + } + } + } _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index c32a504..1a53034 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -49,7 +49,8 @@ vbo_get_minmax_index(GLcontext *ctx, GLuint *min_index, GLuint *max_index) { GLuint i; - GLuint count = prim->count; + const GLuint start = prim->start; + const GLuint count = prim->count; const void *indices; if (_mesa_is_bufferobj(ib->obj)) { @@ -61,9 +62,10 @@ vbo_get_minmax_index(GLcontext *ctx, indices = ib->ptr; } + /* scan the indexes from 'start' through 'start+count-1' */ switch (ib->type) { case GL_UNSIGNED_INT: { - const GLuint *ui_indices = (const GLuint *)indices; + const GLuint *ui_indices = (const GLuint *)indices + start; GLuint max_ui = ui_indices[count-1]; GLuint min_ui = ui_indices[0]; for (i = 0; i < count; i++) { @@ -75,7 +77,7 @@ vbo_get_minmax_index(GLcontext *ctx, break; } case GL_UNSIGNED_SHORT: { - const GLushort *us_indices = (const GLushort *)indices; + const GLushort *us_indices = (const GLushort *)indices + start; GLuint max_us = us_indices[count-1]; GLuint min_us = us_indices[0]; for (i = 0; i < count; i++) { @@ -87,7 +89,7 @@ vbo_get_minmax_index(GLcontext *ctx, break; } case GL_UNSIGNED_BYTE: { - const GLubyte *ub_indices = (const GLubyte *)indices; + const GLubyte *ub_indices = (const GLubyte *)indices + start; GLuint max_ub = ub_indices[count-1]; GLuint min_ub = ub_indices[0]; for (i = 0; i < count; i++) { @@ -1003,6 +1005,8 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, /* Check if we can handle this thing as a bunch of index offsets from the * same index pointer. If we can't, then we have to fall back to doing * a draw_prims per primitive. + * Check that the difference between each prim's indexes is a multiple of + * the index/element size. */ if (index_type_size != 1) { for (i = 0; i < primcount; i++) {