[Mesa-dev] [PATCH 04/22] mesa: Implement DisableVertexArrayAttrib

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


---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  5 +++
 src/mesa/main/tests/dispatch_sanity.cpp        |  1 +
 src/mesa/main/varray.c                         | 45 ++++++++++++++++++++------
 src/mesa/main/varray.h                         |  4 +++
 4 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index f5097e7..cc9c350 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -386,5 +386,10 @@
       <param name="arrays" type="GLuint *" />
    </function>
 
+   <function name="DisableVertexArrayAttrib" offset="assign">
+      <param name="vaobj" type="GLuint" />
+      <param name="index" type="GLuint" />
+   </function>
+
 </category>
 </OpenGLAPI>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index cc6b505..1d82038 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -971,6 +971,7 @@ const struct function gl_core_functions_possible[] = {
    { "glTextureBuffer", 45, -1 },
    { "glTextureBufferRange", 45, -1 },
    { "glCreateVertexArrays", 45, -1 },
+   { "glDisableVertexArrayAttrib", 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 42e7f89..203c858 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -727,20 +727,17 @@ _mesa_EnableVertexAttribArray(GLuint index)
 }
 
 
-void GLAPIENTRY
-_mesa_DisableVertexAttribArray(GLuint index)
+static void
+disable_vertex_array_attrib(struct gl_context *ctx,
+                            struct gl_vertex_array_object *vao,
+                            GLuint index,
+                            const char *func)
 {
-   struct gl_vertex_array_object *vao;
-   GET_CURRENT_CONTEXT(ctx);
-
    if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
-      _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glDisableVertexAttribArrayARB(index)");
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
       return;
    }
 
-   vao = ctx->Array.VAO;
-
    assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
 
    if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
@@ -753,6 +750,36 @@ _mesa_DisableVertexAttribArray(GLuint index)
 }
 
 
+void GLAPIENTRY
+_mesa_DisableVertexAttribArray(GLuint index)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   disable_vertex_array_attrib(ctx, ctx->Array.VAO, index,
+                               "glDisableVertexAttribArray");
+}
+
+
+void GLAPIENTRY
+_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_vertex_array_object *vao;
+
+   /* The ARB_direct_state_access specification says:
+    *
+    *   "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
+    *    and DisableVertexArrayAttrib if <vaobj> is not
+    *    [compatibility profile: zero or] the name of an existing vertex
+    *    array object."
+    */
+   vao = _mesa_lookup_vao_err(ctx, vaobj, "glDisableVertexArrayAttrib");
+   if (!vao)
+      return;
+
+   disable_vertex_array_attrib(ctx, vao, index, "glDisableVertexArrayAttrib");
+}
+
+
 /**
  * Return info for a vertex attribute array (no alias with legacy
  * vertex attributes (pos, normal, color, etc)).  This function does
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 4e4bd5f..df78e1d 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -176,6 +176,10 @@ _mesa_DisableVertexAttribArray(GLuint index);
 
 
 extern void GLAPIENTRY
+_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index);
+
+
+extern void GLAPIENTRY
 _mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
 
 
-- 
1.8.5.3



More information about the mesa-dev mailing list