diff options
-rw-r--r-- | src/mesa/main/varray.c | 108 |
1 files 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 <first> + <count> - * 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 - * <offsets> or <strides> 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 + * <offsets> or <strides> 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 <first> + <count> + * 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"); } |