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 bffacc6..570c5fd 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 42214d8..5ce33a0 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 1e7436b..748eaf5 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 db3ea39..4195f6b 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 },