[Mesa-dev] [PATCH 14/22] mesa: Implement VertexArrayAttribBinding

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


---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 ++
 src/mesa/main/tests/dispatch_sanity.cpp        |  1 +
 src/mesa/main/varray.c                         | 77 ++++++++++++++++++--------
 src/mesa/main/varray.h                         |  4 ++
 4 files changed, 66 insertions(+), 22 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index ae2b0d1..4d36657 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -443,5 +443,11 @@
       <param name="relativeoffset" type="GLuint" />
    </function>
 
+   <function name="VertexArrayAttribBinding" offset="assign">
+      <param name="vaobj" type="GLuint" />
+      <param name="attribindex" type="GLuint" />
+      <param name="bindingindex" type="GLuint" />
+   </function>
+
 </category>
 </OpenGLAPI>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index c1fdc07..b545175 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -979,6 +979,7 @@ const struct function gl_core_functions_possible[] = {
    { "glVertexArrayAttribFormat", 45, -1 },
    { "glVertexArrayAttribIFormat", 45, -1 },
    { "glVertexArrayAttribLFormat", 45, -1 },
+   { "glVertexArrayAttribBinding", 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 4347a92..6cfe240 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1912,26 +1912,16 @@ _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
 }
 
 
-void GLAPIENTRY
-_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
+static void
+vertex_array_attrib_binding(struct gl_context *ctx,
+                            struct gl_vertex_array_object *vao,
+                            GLuint attribIndex, GLuint bindingIndex,
+                            const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
    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,
-                  "glVertexAttribBinding(No array object bound)");
-      return;
-   }
-
-   /* The ARB_vertex_attrib_binding spec says:
-    *
     *    "<attribindex> must be less than the value of MAX_VERTEX_ATTRIBS and
     *     <bindingindex> must be less than the value of
     *     MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
@@ -1939,30 +1929,73 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
     */
    if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glVertexAttribBinding(attribindex=%u >= "
+                  "%s(attribindex=%u >= "
                   "GL_MAX_VERTEX_ATTRIBS)",
-                  attribIndex);
+                  func, attribIndex);
       return;
    }
 
    if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glVertexAttribBinding(bindingindex=%u >= "
+                  "%s(bindingindex=%u >= "
                   "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
-                  bindingIndex);
+                  func, bindingIndex);
       return;
    }
 
-   assert(VERT_ATTRIB_GENERIC(attribIndex) <
-          ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
+   assert(VERT_ATTRIB_GENERIC(attribIndex) < ARRAY_SIZE(vao->VertexAttrib));
 
-   vertex_attrib_binding(ctx, ctx->Array.VAO,
+   vertex_attrib_binding(ctx, vao,
                          VERT_ATTRIB_GENERIC(attribIndex),
                          VERT_ATTRIB_GENERIC(bindingIndex));
 }
 
 
 void GLAPIENTRY
+_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
+{
+   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,
+                  "glVertexAttribBinding(No array object bound)");
+      return;
+   }
+
+   vertex_array_attrib_binding(ctx, ctx->Array.VAO,
+                               attribIndex, bindingIndex,
+                               "glVertexAttribBinding");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingIndex)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_vertex_array_object *vao;
+
+   /* The ARB_direct_state_access specification says:
+    *
+    *   "An INVALID_OPERATION error is generated by VertexArrayAttribBinding
+    *    if <vaobj> is not [compatibility profile: zero or] the name of an
+    *    existing vertex array object."
+    */
+   vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayAttribBinding");
+   if (!vao)
+      return;
+
+   vertex_array_attrib_binding(ctx, vao, attribIndex, bindingIndex,
+                               "glVertexArrayAttribBinding");
+}
+
+
+void GLAPIENTRY
 _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
 {
    GET_CURRENT_CONTEXT(ctx);
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 023cd61..6eeb571 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -329,6 +329,10 @@ extern void GLAPIENTRY
 _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
 
 extern void GLAPIENTRY
+_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex,
+                               GLuint bindingIndex);
+
+extern void GLAPIENTRY
 _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
 
 
-- 
1.8.5.3



More information about the mesa-dev mailing list