From: Fredrik Höglund Date: Mon, 2 Mar 2015 17:30:12 +0000 (+0100) Subject: mesa: Implement VertexArrayElementBuffer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7ccc4f3f2392fa9acbbc034e03e3693c78127f70;p=mesa.git mesa: Implement VertexArrayElementBuffer v2: Add a doxygen comment. Reviewed-by: Laura Ekstrand --- diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index bffacc6dc13..570c5fdfc8f 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -465,6 +465,11 @@ + + + + + diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 42214d8d6a0..5ce33a082f8 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -644,3 +644,44 @@ _mesa_IsVertexArray( GLuint id ) return obj->EverBound; } + + +/** + * Sets the element array buffer binding of a vertex array object. + * + * This is the ARB_direct_state_access equivalent of + * glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer). + */ +void GLAPIENTRY +_mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object *vao; + struct gl_buffer_object *bufObj; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + /* The GL_ARB_direct_state_access specification says: + * + * "An INVALID_OPERATION error is generated by VertexArrayElementBuffer + * if is not [compatibility profile: zero or] the name of an + * existing vertex array object." + */ + vao =_mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayElementBuffer"); + if (!vao) + return; + + /* The GL_ARB_direct_state_access specification says: + * + * "An INVALID_OPERATION error is generated if is not zero or + * the name of an existing buffer object." + */ + if (buffer != 0) + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glVertexArrayElementBuffer"); + else + bufObj = ctx->Shared->NullBufferObj; + + if (bufObj) + _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj); +} diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h index 1e7436bfc55..748eaf57a3a 100644 --- a/src/mesa/main/arrayobj.h +++ b/src/mesa/main/arrayobj.h @@ -100,4 +100,6 @@ void GLAPIENTRY _mesa_CreateVertexArrays(GLsizei n, GLuint *arrays); GLboolean GLAPIENTRY _mesa_IsVertexArray( GLuint id ); +void GLAPIENTRY _mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer); + #endif /* ARRAYOBJ_H */ diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index db3ea39e74e..4195f6beaf4 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -1020,6 +1020,7 @@ const struct function gl_core_functions_possible[] = { { "glCreateVertexArrays", 45, -1 }, { "glDisableVertexArrayAttrib", 45, -1 }, { "glEnableVertexArrayAttrib", 45, -1 }, + { "glVertexArrayElementBuffer", 45, -1 }, { "glCreateSamplers", 45, -1 }, { "glCreateProgramPipelines", 45, -1 }, { "glCreateQueries", 45, -1 },