[Mesa-dev] [PATCH 08/22] mesa: Implement VertexArrayVertexBuffer

Fredrik Höglund fredrik at kde.org
Wed Mar 18 16:18:34 PDT 2015


---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  8 +++
 src/mesa/main/tests/dispatch_sanity.cpp        |  1 +
 src/mesa/main/varray.c                         | 83 ++++++++++++++++++--------
 src/mesa/main/varray.h                         |  4 ++
 4 files changed, 71 insertions(+), 25 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index a6ff206..a4de6e5 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -401,5 +401,13 @@
       <param name="buffer" type="GLuint" />
    </function>
 
+   <function name="VertexArrayVertexBuffer" offset="assign">
+      <param name="vaobj" type="GLuint" />
+      <param name="bindingindex" type="GLuint" />
+      <param name="buffer" type="GLuint" />
+      <param name="offset" type="GLintptr" />
+      <param name="stride" type="GLsizei" />
+   </function>
+
 </category>
 </OpenGLAPI>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 5926061..551e6bd 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -974,6 +974,7 @@ const struct function gl_core_functions_possible[] = {
    { "glDisableVertexArrayAttrib", 45, -1 },
    { "glEnableVertexArrayAttrib", 45, -1 },
    { "glVertexArrayElementBuffer", 45, -1 },
+   { "glVertexArrayVertexBuffer", 45, -1 },
 
    /* GL_EXT_polygon_offset_clamp */
    { "glPolygonOffsetClampEXT", 11, -1 },
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index e41d32f..5dff84f 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1449,38 +1449,25 @@ _mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type)
 /**
  * GL_ARB_vertex_attrib_binding
  */
-void GLAPIENTRY
-_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
-                       GLsizei stride)
+static void
+vertex_array_vertex_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+                           GLuint bindingIndex, GLuint buffer, GLintptr offset,
+                           GLsizei stride, const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
    struct gl_buffer_object *vbo;
 
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    /* The ARB_vertex_attrib_binding spec says:
     *
-    *    "An INVALID_OPERATION error is generated if no vertex array object
-    *     is bound."
-    */
-   if (ctx->API == API_OPENGL_CORE &&
-       ctx->Array.VAO == ctx->Array.DefaultVAO) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glBindVertexBuffer(No array object bound)");
-      return;
-   }
-
-   /* The ARB_vertex_attrib_binding spec says:
-    *
     *    "An INVALID_VALUE error is generated if <bindingindex> is greater than
     *     the value of MAX_VERTEX_ATTRIB_BINDINGS."
     */
    if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glBindVertexBuffer(bindingindex=%u > "
+                  "%s(bindingindex=%u > "
                   "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
-                  bindingIndex);
+                  func, bindingIndex);
       return;
    }
 
@@ -1491,21 +1478,21 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
     */
    if (offset < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glBindVertexBuffer(offset=%" PRId64 " < 0)",
-                  (int64_t) offset);
+                  "%s(offset=%" PRId64 " < 0)",
+                  func, (int64_t) offset);
       return;
    }
 
    if (stride < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glBindVertexBuffer(stride=%d < 0)", stride);
+                  "%s(stride=%d < 0)", func, stride);
       return;
    }
 
    if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
        stride > ctx->Const.MaxVertexAttribStride) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glBindVertexBuffer(stride=%d > "
-                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride);
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > "
+                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride);
       return;
    }
 
@@ -1525,7 +1512,7 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
        * object references (automatically gen it).
        */
       if (!_mesa_handle_bind_buffer_gen(ctx, GL_ARRAY_BUFFER, buffer,
-                                        &vbo, "glBindVertexBuffer"))
+                                        &vbo, func))
          return;
    } else {
       /* The ARB_vertex_attrib_binding spec says:
@@ -1542,6 +1529,52 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
 
 
 void GLAPIENTRY
+_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
+                       GLsizei stride)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* The ARB_vertex_attrib_binding spec says:
+    *
+    *    "An INVALID_OPERATION error is generated if no vertex array object
+    *     is bound."
+    */
+   if (ctx->API == API_OPENGL_CORE &&
+       ctx->Array.VAO == ctx->Array.DefaultVAO) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glBindVertexBuffer(No array object bound)");
+      return;
+   }
+
+   vertex_array_vertex_buffer(ctx, ctx->Array.VAO, bindingIndex,
+                              buffer, offset, stride, "glBindVertexBuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
+                              GLintptr offset, GLsizei stride)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_vertex_array_object *vao;
+
+   /* The ARB_direct_state_access specification says:
+    *
+    *   "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
+    *    if <vaobj> is not [compatibility profile: zero or] the name of an
+    *    existing vertex array object."
+    */
+   vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayVertexBuffer");
+   if (!vao)
+      return;
+
+   vertex_array_vertex_buffer(ctx, vao, bindingIndex,
+                              buffer, offset, stride,
+                              "glVertexArrayVertexBuffer");
+}
+
+
+void GLAPIENTRY
 _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
                         const GLintptr *offsets, const GLsizei *strides)
 {
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index a77cdb8..1e94782 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -286,6 +286,10 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
                        GLsizei stride);
 
 extern void GLAPIENTRY
+_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
+                              GLintptr offset, GLsizei stride);
+
+extern void GLAPIENTRY
 _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
                         const GLintptr *offsets, const GLsizei *strides);
 
-- 
1.8.5.3



More information about the mesa-dev mailing list