From 308926853d132a4d096e70447a262bef1e576789 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fredrik=20H=C3=B6glund?= Date: Mon, 2 Mar 2015 18:37:27 +0100 Subject: [PATCH] mesa: Implement VertexArrayVertexBuffers Reviewed-by: Laura Ekstrand --- .../glapi/gen/ARB_direct_state_access.xml | 9 ++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/varray.c | 90 +++++++++++++------ src/mesa/main/varray.h | 5 ++ 4 files changed, 78 insertions(+), 27 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 46f5ea28c0e..645c9cc80d7 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -478,6 +478,15 @@ + + + + + + + + + diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 906ffaf6d04..55edadf4686 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -1022,6 +1022,7 @@ const struct function gl_core_functions_possible[] = { { "glEnableVertexArrayAttrib", 45, -1 }, { "glVertexArrayElementBuffer", 45, -1 }, { "glVertexArrayVertexBuffer", 45, -1 }, + { "glVertexArrayVertexBuffers", 45, -1 }, { "glCreateSamplers", 45, -1 }, { "glCreateProgramPipelines", 45, -1 }, { "glCreateQueries", 45, -1 }, diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index bbefc389cd2..77a1af09a29 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1612,28 +1612,17 @@ _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer, } -void GLAPIENTRY -_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, - const GLintptr *offsets, const GLsizei *strides) +static 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) { - GET_CURRENT_CONTEXT(ctx); - struct gl_vertex_array_object * const vao = ctx->Array.VAO; GLuint i; ASSERT_OUTSIDE_BEGIN_END(ctx); - /* The ARB_vertex_attrib_binding spec says: - * - * "An INVALID_OPERATION error is generated if no - * vertex array object is bound." - */ - if (ctx->API == API_OPENGL_CORE && - ctx->Array.VAO == ctx->Array.DefaultVAO) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindVertexBuffers(No array object bound)"); - return; - } - /* The ARB_multi_bind spec says: * * "An INVALID_OPERATION error is generated if + @@ -1641,9 +1630,9 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, */ if (first + count > ctx->Const.MaxVertexAttribBindings) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindVertexBuffers(first=%u + count=%d > the value of " + "%s(first=%u + count=%d > the value of " "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)", - first, count, ctx->Const.MaxVertexAttribBindings); + func, first, count, ctx->Const.MaxVertexAttribBindings); return; } @@ -1697,23 +1686,23 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, */ if (offsets[i] < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glBindVertexBuffers(offsets[%u]=%" PRId64 " < 0)", - i, (int64_t) offsets[i]); + "%s(offsets[%u]=%" PRId64 " < 0)", + func, i, (int64_t) offsets[i]); continue; } if (strides[i] < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glBindVertexBuffers(strides[%u]=%d < 0)", - i, strides[i]); + "%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, - "glBindVertexBuffers(strides[%u]=%d > " - "GL_MAX_VERTEX_ATTRIB_STRIDE)", i, strides[i]); + "%s(strides[%u]=%d > " + "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]); continue; } @@ -1724,8 +1713,7 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, if (buffers[i] == binding->BufferObj->Name) vbo = binding->BufferObj; else - vbo = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i, - "glBindVertexBuffers"); + vbo = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i, func); if (!vbo) continue; @@ -1741,6 +1729,54 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, } +void GLAPIENTRY +_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, + const GLintptr *offsets, const GLsizei *strides) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The ARB_vertex_attrib_binding spec says: + * + * "An INVALID_OPERATION error is generated if no + * vertex array object is bound." + */ + if (ctx->API == API_OPENGL_CORE && + ctx->Array.VAO == ctx->Array.DefaultVAO) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindVertexBuffers(No array object bound)"); + return; + } + + vertex_array_vertex_buffers(ctx, ctx->Array.VAO, first, count, + buffers, offsets, strides, + "glBindVertexBuffers"); +} + + +void GLAPIENTRY +_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, + const GLuint *buffers, + const GLintptr *offsets, const GLsizei *strides) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object *vao; + + /* The ARB_direct_state_access specification says: + * + * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer + * if is not [compatibility profile: zero or] the name of an + * existing vertex array object." + */ + vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayVertexBuffers"); + if (!vao) + return; + + vertex_array_vertex_buffers(ctx, vao, first, count, + buffers, offsets, strides, + "glVertexArrayVertexBuffers"); +} + + void GLAPIENTRY _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLuint relativeOffset) diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 6dd3ffc7ba6..df1cbeb946a 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -298,6 +298,11 @@ extern void GLAPIENTRY _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +extern void GLAPIENTRY +_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, + const GLuint *buffers, + const GLintptr *offsets, const GLsizei *strides); + extern void GLAPIENTRY _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLuint relativeOffset); -- 2.30.2