From a11c7e3fb51ff185675220083d4d33c7ee6a58c5 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 31 May 2017 12:35:25 +0200 Subject: [PATCH] mesa: add vertex_array_vertex_buffers_err() helper This also adds a 'no_error' parameter to vertex_array_vertex_buffer() to be used in a following patch. Signed-off-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- src/mesa/main/varray.c | 108 +++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 47 deletions(-) diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 47528ba2a79..c2c771c173c 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -2117,29 +2117,14 @@ _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer, } -static void +static ALWAYS_INLINE void vertex_array_vertex_buffers(struct gl_context *ctx, struct gl_vertex_array_object *vao, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides, - const char *func) + bool no_error, const char *func) { - GLuint i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* The ARB_multi_bind spec says: - * - * "An INVALID_OPERATION error is generated if + - * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS." - */ - if (first + count > ctx->Const.MaxVertexAttribBindings) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(first=%u + count=%d > the value of " - "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)", - func, first, count, ctx->Const.MaxVertexAttribBindings); - return; - } + GLint i; if (!buffers) { /** @@ -2184,31 +2169,33 @@ vertex_array_vertex_buffers(struct gl_context *ctx, for (i = 0; i < count; i++) { struct gl_buffer_object *vbo; - /* The ARB_multi_bind spec says: - * - * "An INVALID_VALUE error is generated if any value in - * or is negative (per binding)." - */ - if (offsets[i] < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "%s(offsets[%u]=%" PRId64 " < 0)", - func, i, (int64_t) offsets[i]); - continue; - } + if (!no_error) { + /* The ARB_multi_bind spec says: + * + * "An INVALID_VALUE error is generated if any value in + * or is negative (per binding)." + */ + if (offsets[i] < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(offsets[%u]=%" PRId64 " < 0)", + func, i, (int64_t) offsets[i]); + continue; + } - if (strides[i] < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "%s(strides[%u]=%d < 0)", - func, i, strides[i]); - continue; - } + if (strides[i] < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(strides[%u]=%d < 0)", + func, i, strides[i]); + continue; + } - if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 && - strides[i] > ctx->Const.MaxVertexAttribStride) { - _mesa_error(ctx, GL_INVALID_VALUE, - "%s(strides[%u]=%d > " - "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]); - continue; + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 && + strides[i] > ctx->Const.MaxVertexAttribStride) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(strides[%u]=%d > " + "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]); + continue; + } } if (buffers[i]) { @@ -2234,6 +2221,33 @@ vertex_array_vertex_buffers(struct gl_context *ctx, } +static void +vertex_array_vertex_buffers_err(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLuint first, GLsizei count, + const GLuint *buffers, const GLintptr *offsets, + const GLsizei *strides, const char *func) +{ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + /* The ARB_multi_bind spec says: + * + * "An INVALID_OPERATION error is generated if + + * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS." + */ + if (first + count > ctx->Const.MaxVertexAttribBindings) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(first=%u + count=%d > the value of " + "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)", + func, first, count, ctx->Const.MaxVertexAttribBindings); + return; + } + + vertex_array_vertex_buffers(ctx, vao, first, count, buffers, offsets, + strides, false, func); +} + + void GLAPIENTRY _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides) @@ -2252,9 +2266,9 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, return; } - vertex_array_vertex_buffers(ctx, ctx->Array.VAO, first, count, - buffers, offsets, strides, - "glBindVertexBuffers"); + vertex_array_vertex_buffers_err(ctx, ctx->Array.VAO, first, count, + buffers, offsets, strides, + "glBindVertexBuffers"); } @@ -2276,9 +2290,9 @@ _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, if (!vao) return; - vertex_array_vertex_buffers(ctx, vao, first, count, - buffers, offsets, strides, - "glVertexArrayVertexBuffers"); + vertex_array_vertex_buffers_err(ctx, vao, first, count, + buffers, offsets, strides, + "glVertexArrayVertexBuffers"); } -- 2.30.2