aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFredrik Höglund <[email protected]>2015-03-02 18:30:12 +0100
committerFredrik Höglund <[email protected]>2015-05-08 15:31:03 +0200
commit7ccc4f3f2392fa9acbbc034e03e3693c78127f70 (patch)
treefc665e97cf4bb124477e9a4e9055d9374667021d /src
parentc99efbd3c2d496dc7e62adf11ab56b7eb006bbc3 (diff)
mesa: Implement VertexArrayElementBuffer
v2: Add a doxygen comment. Reviewed-by: Laura Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mapi/glapi/gen/ARB_direct_state_access.xml5
-rw-r--r--src/mesa/main/arrayobj.c41
-rw-r--r--src/mesa/main/arrayobj.h2
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp1
4 files changed, 49 insertions, 0 deletions
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 @@
<param name="index" type="GLuint" />
</function>
+ <function name="VertexArrayElementBuffer" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="buffer" type="GLuint" />
+ </function>
+
<!-- Sampler object functions -->
<function name="CreateSamplers" offset="assign">
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 <vaobj> 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 <buffer> 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 },