mesa: Refactor enable_vertex_array_attrib to make _mesa_enable_vertex_array_attrib
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 4 Nov 2015 00:16:00 +0000 (16:16 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 24 Nov 2015 19:31:29 +0000 (11:31 -0800)
Pulls the parts of enable_vertex_array_attrib that aren't just parameter
validation out into a function that can be called from other parts of
Mesa (e.g., meta).

_mesa_enable_vertex_array_attrib can also be used to enable
fixed-function arrays.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/main/varray.c
src/mesa/main/varray.h

index e9f78e9bfe06e563a00833d52db714985ba9f014..8836c182a41bba231c458d29da030b813deb8b75 100644 (file)
@@ -770,6 +770,22 @@ _mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
 }
 
 
+void
+_mesa_enable_vertex_array_attrib(struct gl_context *ctx,
+                                 struct gl_vertex_array_object *vao,
+                                 unsigned attrib)
+{
+   assert(attrib < ARRAY_SIZE(vao->VertexAttrib));
+
+   if (!vao->VertexAttrib[attrib].Enabled) {
+      /* was disabled, now being enabled */
+      FLUSH_VERTICES(ctx, _NEW_ARRAY);
+      vao->VertexAttrib[attrib].Enabled = GL_TRUE;
+      vao->_Enabled |= VERT_BIT(attrib);
+      vao->NewArrays |= VERT_BIT(attrib);
+   }
+}
+
 static void
 enable_vertex_array_attrib(struct gl_context *ctx,
                            struct gl_vertex_array_object *vao,
@@ -781,15 +797,7 @@ enable_vertex_array_attrib(struct gl_context *ctx,
       return;
    }
 
-   assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
-
-   if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
-      /* was disabled, now being enabled */
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
-      vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
-      vao->_Enabled |= VERT_BIT_GENERIC(index);
-      vao->NewArrays |= VERT_BIT_GENERIC(index);
-   }
+   _mesa_enable_vertex_array_attrib(ctx, vao, VERT_ATTRIB_GENERIC(index));
 }
 
 
index 744b336512775b25867980afa8e8b33491f0c637..a766afad5bc3a534b58a4e0e13e0631573dca890 100644 (file)
@@ -98,6 +98,11 @@ _mesa_update_array_format(struct gl_context *ctx,
                           GLboolean integer, GLboolean doubles,
                           GLuint relativeOffset, bool flush_vertices);
 
+extern void
+_mesa_enable_vertex_array_attrib(struct gl_context *ctx,
+                                 struct gl_vertex_array_object *vao,
+                                 unsigned attrib);
+
 extern void
 _mesa_bind_vertex_buffer(struct gl_context *ctx,
                          struct gl_vertex_array_object *vao,