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);
{
static GLuint warnCount = 0;
GLboolean index_bounds_valid = GL_TRUE;
+ GLuint max_element;
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
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
"\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;
}
}
if ((int) start + basevertex < 0 ||
- end + basevertex >= ctx->Array.ArrayObj->_MaxElement)
+ end + basevertex >= max_element)
index_bounds_valid = GL_FALSE;
#if 0