mesa: Implement VertexArrayAttribBinding
authorFredrik Höglund <fredrik@kde.org>
Mon, 2 Mar 2015 17:49:06 +0000 (18:49 +0100)
committerFredrik Höglund <fredrik@kde.org>
Fri, 8 May 2015 13:31:03 +0000 (15:31 +0200)
Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/tests/dispatch_sanity.cpp
src/mesa/main/varray.c
src/mesa/main/varray.h

index 0268f5ff5b042b76731ed65ef20ddca094d9b091..8cc1ab0479da8aca9e6265c05a21531eaba89ad2 100644 (file)
       <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>
+
    <!-- Sampler object functions -->
 
    <function name="CreateSamplers" offset="assign">
index f36f5b3e402ce5e86c7abb7ffafb2a66e994b57a..bc9832177c41c0749aeeb7bd3e20ba37eb2c1d89 100644 (file)
@@ -1026,6 +1026,7 @@ const struct function gl_core_functions_possible[] = {
    { "glVertexArrayAttribFormat", 45, -1 },
    { "glVertexArrayAttribIFormat", 45, -1 },
    { "glVertexArrayAttribLFormat", 45, -1 },
+   { "glVertexArrayAttribBinding", 45, -1 },
    { "glCreateSamplers", 45, -1 },
    { "glCreateProgramPipelines", 45, -1 },
    { "glCreateQueries", 45, -1 },
index 9a8441a646d9842c0b58ce252a390b447aa71a37..0cfa948a0530bc98a459cb45824ddeaa22e3a7b9 100644 (file)
@@ -1957,24 +1957,14 @@ _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
@@ -1984,29 +1974,72 @@ _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)
 {
index d2234391eddc53ed472b663f3e143ca9261e0d0c..b9544dc7cd73b29ad496a70675c547f47cba3f87 100644 (file)
@@ -333,6 +333,10 @@ _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
 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);