mesa: Implement VertexArrayElementBuffer
authorFredrik Höglund <fredrik@kde.org>
Mon, 2 Mar 2015 17:30:12 +0000 (18:30 +0100)
committerFredrik Höglund <fredrik@kde.org>
Fri, 8 May 2015 13:31:03 +0000 (15:31 +0200)
v2: Add a doxygen comment.

Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/arrayobj.c
src/mesa/main/arrayobj.h
src/mesa/main/tests/dispatch_sanity.cpp

index bffacc6dc132339c814e0f133e226753c02ca579..570c5fdfc8f7113fb07a23b598a69af508a9ad3b 100644 (file)
       <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">
index 42214d8d6a02ea1435f035c7f43586421018145d..5ce33a082f84cf1947ffe27ff81e044cd7e15b30 100644 (file)
@@ -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);
+}
index 1e7436bfc55215dd9440511804339430614088e1..748eaf57a3af87ee2717da2f94bb1a8105c0f5cb 100644 (file)
@@ -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 */
index db3ea39e74e2c45675ccf59febe5b141ba225a2e..4195f6beaf451454769f75fdb27e7cd5df6ad112 100644 (file)
@@ -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 },