diff options
author | Timothy Arceri <[email protected]> | 2017-03-31 15:02:40 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-04-19 16:53:25 +1000 |
commit | c495c2398ca69e3dde6010398e5dcc64a316c3a9 (patch) | |
tree | 5040e87d9e1ae4e913e874b49b6f6775e8a75e6f | |
parent | 9e60742ddcce04bb218fda15f0b577f850668080 (diff) |
mesa/varray: rename update_array_format() -> validate_array_format()
We also move _mesa_update_array_format() into the caller.
This gets these functions ready for KHR_no_error support.
V2: Updated function comment as suggested by Brian.
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/mesa/main/varray.c | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index f4e4372d11d..9d3fe136605 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -320,7 +320,7 @@ _mesa_update_array_format(struct gl_context *ctx, } /** - * Does error checking and updates the format in an attrib array. + * Does error checking of the format in an attrib array. * * Called by update_array() and VertexAttrib*Format(). * @@ -335,19 +335,18 @@ _mesa_update_array_format(struct gl_context *ctx, * \param integer Integer-valued values (will not be normalized to [-1, 1]) * \param doubles Double values not reduced to floats * \param relativeOffset Offset of the first element relative to the binding offset. + * \return bool True if validation is successful, False otherwise. */ static bool -update_array_format(struct gl_context *ctx, - const char *func, - struct gl_vertex_array_object *vao, - GLuint attrib, GLbitfield legalTypesMask, - GLint sizeMin, GLint sizeMax, - GLint size, GLenum type, - GLboolean normalized, GLboolean integer, GLboolean doubles, - GLuint relativeOffset) +validate_array_format(struct gl_context *ctx, const char *func, + struct gl_vertex_array_object *vao, + GLuint attrib, GLbitfield legalTypesMask, + GLint sizeMin, GLint sizeMax, + GLint size, GLenum type, GLboolean normalized, + GLboolean integer, GLboolean doubles, + GLuint relativeOffset, GLenum format) { GLbitfield typeBit; - GLenum format = get_array_format(ctx, sizeMax, &size); /* at most, one of these bools can be true */ assert((int) normalized + (int) integer + (int) doubles <= 1); @@ -441,9 +440,6 @@ update_array_format(struct gl_context *ctx, return false; } - _mesa_update_array_format(ctx, vao, attrib, size, type, format, - normalized, integer, doubles, relativeOffset); - return true; } @@ -547,16 +543,21 @@ update_array(struct gl_context *ctx, const GLvoid *ptr) { struct gl_vertex_array_object *vao = ctx->Array.VAO; + GLenum format = get_array_format(ctx, sizeMax, &size); validate_array(ctx, func, attrib, legalTypesMask, sizeMin, sizeMax, size, type, stride, normalized, integer, doubles, ptr); - if (!update_array_format(ctx, func, vao, attrib, - legalTypesMask, sizeMin, sizeMax, - size, type, normalized, integer, doubles, 0)) { + if (!validate_array_format(ctx, func, vao, attrib, + legalTypesMask, sizeMin, sizeMax, + size, type, normalized, integer, doubles, 0, + format)) { return; } + _mesa_update_array_format(ctx, vao, attrib, size, type, format, + normalized, integer, doubles, 0); + /* Reset the vertex attrib binding */ vertex_attrib_binding(ctx, vao, attrib, attrib); @@ -2007,12 +2008,14 @@ static void vertex_attrib_format(GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLboolean integer, GLboolean doubles, GLbitfield legalTypes, - GLsizei maxSize, GLuint relativeOffset, + GLsizei sizeMax, GLuint relativeOffset, const char *func) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + GLenum format = get_array_format(ctx, sizeMax, &size); + /* The ARB_vertex_attrib_binding spec says: * * "An INVALID_OPERATION error is generated under any of the following @@ -2047,10 +2050,18 @@ vertex_attrib_format(GLuint attribIndex, GLint size, GLenum type, FLUSH_VERTICES(ctx, 0); - update_array_format(ctx, func, ctx->Array.VAO, - VERT_ATTRIB_GENERIC(attribIndex), - legalTypes, 1, maxSize, size, type, - normalized, integer, doubles, relativeOffset); + if (!validate_array_format(ctx, func, ctx->Array.VAO, + VERT_ATTRIB_GENERIC(attribIndex), + legalTypes, 1, sizeMax, size, type, + normalized, integer, doubles, relativeOffset, + format)) { + return; + } + + _mesa_update_array_format(ctx, ctx->Array.VAO, + VERT_ATTRIB_GENERIC(attribIndex), size, type, + format, normalized, integer, doubles, + relativeOffset); } @@ -2089,7 +2100,7 @@ static void vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLboolean integer, GLboolean doubles, - GLbitfield legalTypes, GLsizei maxSize, + GLbitfield legalTypes, GLsizei sizeMax, GLuint relativeOffset, const char *func) { GET_CURRENT_CONTEXT(ctx); @@ -2097,6 +2108,8 @@ vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size, ASSERT_OUTSIDE_BEGIN_END(ctx); + GLenum format = get_array_format(ctx, sizeMax, &size); + /* The ARB_direct_state_access spec says: * * "An INVALID_OPERATION error is generated by VertexArrayAttrib*Format @@ -2121,10 +2134,16 @@ vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size, FLUSH_VERTICES(ctx, 0); - update_array_format(ctx, func, vao, - VERT_ATTRIB_GENERIC(attribIndex), - legalTypes, 1, maxSize, size, type, normalized, - integer, doubles, relativeOffset); + if (!validate_array_format(ctx, func, vao, + VERT_ATTRIB_GENERIC(attribIndex), + legalTypes, 1, sizeMax, size, type, normalized, + integer, doubles, relativeOffset, format)) { + return; + } + + _mesa_update_array_format(ctx, vao, VERT_ATTRIB_GENERIC(attribIndex), size, + type, format, normalized, integer, doubles, + relativeOffset); } |