summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-04-26 01:17:47 +0200
committerMarek Olšák <[email protected]>2013-05-11 23:45:01 +0200
commit081c789c3e1c6896bd8446d67db4a6740efdf92d (patch)
tree6682b591c3918757a8f0815a003e65db6aeb23db /src/mesa/vbo
parentdb38e9a0e179441f59274f6f2a751912c29872e2 (diff)
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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo_exec_array.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index d2cadf941bc..cf766af9056 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -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