[Mesa-dev] [PATCH 074/101] mesa: add vertex_array_element_buffer() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Jul 21 17:40:23 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/mesa/main/arrayobj.c | 59 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 21 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index f0a3f7b1fd..2ce49c7c8c 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -642,35 +642,44 @@ _mesa_IsVertexArray( GLuint id )
  * This is the ARB_direct_state_access equivalent of
  * glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer).
  */
-void GLAPIENTRY
-_mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
+static ALWAYS_INLINE void
+vertex_array_element_buffer(struct gl_context *ctx, GLuint vaobj, GLuint buffer,
+                            bool no_error)
 {
-   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;
+   if (!no_error) {
+      /* 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;
+   } else {
+      vao = _mesa_lookup_vao(ctx, vaobj);
+   }
 
-   /* 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
+   if (buffer != 0) {
+      if (!no_error) {
+         /* 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."
+          */
+         bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+                                             "glVertexArrayElementBuffer");
+      } else {
+         bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+      }
+   } else {
       bufObj = ctx->Shared->NullBufferObj;
+   }
 
    if (bufObj)
       _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj);
@@ -678,6 +687,14 @@ _mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
 
 
 void GLAPIENTRY
+_mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   vertex_array_element_buffer(ctx, vaobj, buffer, false);
+}
+
+
+void GLAPIENTRY
 _mesa_GetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param)
 {
    GET_CURRENT_CONTEXT(ctx);
-- 
2.13.3



More information about the mesa-dev mailing list