summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-09-14 22:38:14 -0700
committerKenneth Graunke <[email protected]>2014-09-19 00:43:01 -0700
commit26ee6f23a9aec6b1f392baa0e3f1f2c62c038a57 (patch)
treee53380a98e2895a1e22c3a17d12defb19a045f02 /src/mesa/vbo
parent19589147ef660c0bf7fcc52ca82dfbbadf3a9a23 (diff)
mesa: Delete VAO _MaxElement code and index buffer bounds checking.
Fredrik's implementation of ARB_vertex_attrib_binding introduced new gl_vertex_attrib_array and gl_vertex_buffer_binding structures, and converted Mesa's older gl_client_array to be derived state. Ultimately, we'd like to drop gl_client_array and use those structures directly. One hitch is that gl_client_array::_MaxElement doesn't correspond to either structure (unlike every other field), so we'd have to figure out where to store it. The _MaxElement computation uses values from both structures, so it doesn't really belong in either place. We could put it in the VAO, but we'd have to pass it around everywhere. It turns out that it's only used when ctx->Const.CheckArrayBounds is set, which is only set by the (rarely used) classic swrast driver. It appears that drivers/x11 used to set it as well, which was intended to avoid segmentation faults on out-of-bounds memory access in the X server (probably for indirect GLX clients). However, ajax deleted that code in 2010 (commit 1ccef926be46dce3b6b5c76e812e2fae4e205ce7). The bounds checking apparently doesn't actually work, either. Non-VBO attributes arbitrarily set _MaxElement to 2 * 1000 * 1000 * 1000. vbo_save_draw and vbo_exec_draw remark /* ??? */ when setting it, and the i965 code contains a comment noting that _MaxElement is often bogus. Given that the code is complex, rarely used, and dubiously functional, it doesn't seem worth maintaining going forward. This patch drops it. This will probably mean the classic swrast driver may begin crashing on out of bounds vertex buffer access in some cases, but I believe that is allowed by OpenGL (and probably happened for non-VBO accesses anyway). There do not appear to be any Piglit regressions, either. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo_exec_array.c26
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c2
-rw-r--r--src/mesa/vbo/vbo_save_draw.c1
-rw-r--r--src/mesa/vbo/vbo_split_copy.c1
4 files changed, 6 insertions, 24 deletions
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 22557e16844..111321bd7f2 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -1032,7 +1032,12 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
{
static GLuint warnCount = 0;
GLboolean index_bounds_valid = GL_TRUE;
- GLuint max_element;
+
+ /* This is only useful to catch invalid values in the "end" parameter
+ * like ~0.
+ */
+ GLuint max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
+
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
@@ -1045,25 +1050,6 @@ 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.VAO->_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 >= max_element) {
/* The application requested we draw using a range of indices that's
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index c454c6943b4..362cc10405c 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -159,7 +159,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
struct gl_client_array *arrays = exec->vtx.arrays;
- const GLuint count = exec->vtx.vert_count;
const GLuint *map;
GLuint attr;
GLbitfield64 varying_inputs = 0x0;
@@ -241,7 +240,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
_mesa_reference_buffer_object(ctx,
&arrays[attr].BufferObj,
exec->vtx.bufferobj);
- arrays[attr]._MaxElement = count; /* ??? */
varying_inputs |= VERT_BIT(attr);
}
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 89fd30e0fb1..d0521d79485 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -203,7 +203,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
_mesa_reference_buffer_object(ctx,
&arrays[attr].BufferObj,
node->vertex_store->bufferobj);
- arrays[attr]._MaxElement = node->count; /* ??? */
assert(arrays[attr].BufferObj->Name);
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index 719ad651a89..ca752e81060 100644
--- a/src/mesa/vbo/vbo_split_copy.c
+++ b/src/mesa/vbo/vbo_split_copy.c
@@ -533,7 +533,6 @@ replay_init( struct copy_context *copy )
dst->Integer = src->Integer;
dst->BufferObj = ctx->Shared->NullBufferObj;
dst->_ElementSize = src->_ElementSize;
- dst->_MaxElement = copy->dstbuf_size; /* may be less! */
offset += copy->varying[i].size;
}