diff options
author | Kenneth Graunke <[email protected]> | 2014-09-14 22:38:14 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-09-19 00:43:01 -0700 |
commit | 26ee6f23a9aec6b1f392baa0e3f1f2c62c038a57 (patch) | |
tree | e53380a98e2895a1e22c3a17d12defb19a045f02 /src/mesa/main/api_validate.c | |
parent | 19589147ef660c0bf7fcc52ca82dfbbadf3a9a23 (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/main/api_validate.c')
-rw-r--r-- | src/mesa/main/api_validate.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 8f0b1998dad..51a3d1f01ce 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -160,47 +160,6 @@ check_valid_to_render(struct gl_context *ctx, const char *function) /** - * Do bounds checking on array element indexes. Check that the vertices - * pointed to by the indices don't lie outside buffer object bounds. - * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds - */ -static GLboolean -check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - struct _mesa_prim prim; - struct _mesa_index_buffer ib; - GLuint min, max; - - /* Only the X Server needs to do this -- otherwise, accessing outside - * array/BO bounds allows application termination. - */ - if (!ctx->Const.CheckArrayBounds) - return GL_TRUE; - - memset(&prim, 0, sizeof(prim)); - prim.count = count; - - memset(&ib, 0, sizeof(ib)); - ib.type = type; - ib.ptr = indices; - ib.obj = ctx->Array.VAO->IndexBufferObj; - - vbo_get_minmax_indices(ctx, &prim, &ib, &min, &max, 1); - - if ((int)(min + basevertex) < 0 || - max + basevertex >= ctx->Array.VAO->_MaxElement) { - /* the max element is out of bounds of one or more enabled arrays */ - _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", - max, ctx->Array.VAO->_MaxElement); - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), * etc? The set of legal values depends on whether geometry shaders/programs * are supported. @@ -453,9 +412,6 @@ _mesa_validate_DrawElements(struct gl_context *ctx, return GL_FALSE; } - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - if (count == 0) return GL_FALSE; @@ -517,12 +473,6 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx, } } - for (i = 0; i < primcount; i++) { - if (!check_index_bounds(ctx, count[i], type, indices[i], - basevertex ? basevertex[i] : 0)) - return GL_FALSE; - } - return GL_TRUE; } @@ -588,9 +538,6 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, return GL_FALSE; } - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - if (count == 0) return GL_FALSE; @@ -623,11 +570,6 @@ _mesa_validate_DrawArrays(struct gl_context *ctx, if (!check_valid_to_render(ctx, "glDrawArrays")) return GL_FALSE; - if (ctx->Const.CheckArrayBounds) { - if (start + count > (GLint) ctx->Array.VAO->_MaxElement) - return GL_FALSE; - } - /* From the GLES3 specification, section 2.14.2 (Transform Feedback * Primitive Capture): * @@ -692,11 +634,6 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)")) return GL_FALSE; - if (ctx->Const.CheckArrayBounds) { - if (first + count > (GLint) ctx->Array.VAO->_MaxElement) - return GL_FALSE; - } - /* From the GLES3 specification, section 2.14.2 (Transform Feedback * Primitive Capture): * @@ -791,9 +728,6 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, if (count == 0) return GL_FALSE; - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - return GL_TRUE; } |