mesa: skip _MaxElement computation unless driver needs strict bounds checking
If Const.CheckArrayBounds is false, the only code using _MaxElement is glDrawRangeElements, so I changed it and explained in the code why _MaxElement is not very useful there. BTW, the big magic number was copied to the letter from _mesa_update_array_max_element. Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
db38e9a0e1
commit
081c789c3e
|
@ -411,8 +411,10 @@ _mesa_update_state_locked( struct gl_context *ctx )
|
|||
new_prog_state |= update_program( ctx );
|
||||
}
|
||||
|
||||
if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT))
|
||||
if (ctx->Const.CheckArrayBounds &&
|
||||
new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) {
|
||||
_mesa_update_array_object_max_element(ctx, ctx->Array.ArrayObj);
|
||||
}
|
||||
|
||||
out:
|
||||
new_prog_state |= update_program_constants(ctx);
|
||||
|
|
|
@ -986,6 +986,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
|
|||
{
|
||||
static GLuint warnCount = 0;
|
||||
GLboolean index_bounds_valid = GL_TRUE;
|
||||
GLuint max_element;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
if (MESA_VERBOSE & VERBOSE_DRAW)
|
||||
|
@ -998,8 +999,27 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
|
|||
type, indices, basevertex ))
|
||||
return;
|
||||
|
||||
if (ctx->Const.CheckArrayBounds) {
|
||||
/* _MaxElement was computed, so we can use it.
|
||||
* This path is used for drivers which need strict bounds checking.
|
||||
*/
|
||||
max_element = ctx->Array.ArrayObj->_MaxElement;
|
||||
}
|
||||
else {
|
||||
/* Generally, hardware drivers don't need to know the buffer bounds
|
||||
* if all vertex attributes are in VBOs.
|
||||
* However, if none of vertex attributes are in VBOs, _MaxElement
|
||||
* is always set to some random big number anyway, so bounds checking
|
||||
* is mostly useless.
|
||||
*
|
||||
* This is only useful to catch invalid values in the "end" parameter
|
||||
* like ~0.
|
||||
*/
|
||||
max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
|
||||
}
|
||||
|
||||
if ((int) end + basevertex < 0 ||
|
||||
start + basevertex >= ctx->Array.ArrayObj->_MaxElement) {
|
||||
start + basevertex >= max_element) {
|
||||
/* The application requested we draw using a range of indices that's
|
||||
* outside the bounds of the current VBO. This is invalid and appears
|
||||
* to give undefined results. The safest thing to do is to simply
|
||||
|
@ -1013,7 +1033,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
|
|||
"\trange is outside VBO bounds (max=%u); ignoring.\n"
|
||||
"\tThis should be fixed in the application.",
|
||||
start, end, basevertex, count, type, indices,
|
||||
ctx->Array.ArrayObj->_MaxElement - 1);
|
||||
max_element - 1);
|
||||
}
|
||||
index_bounds_valid = GL_FALSE;
|
||||
}
|
||||
|
@ -1044,7 +1064,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
|
|||
}
|
||||
|
||||
if ((int) start + basevertex < 0 ||
|
||||
end + basevertex >= ctx->Array.ArrayObj->_MaxElement)
|
||||
end + basevertex >= max_element)
|
||||
index_bounds_valid = GL_FALSE;
|
||||
|
||||
#if 0
|
||||
|
|
Loading…
Reference in New Issue