[Mesa-dev] [PATCH 11/11] mesa/vbo/tnl: Move gl_vertex_array related stuff to tnl.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Sun Apr 1 18:13:11 UTC 2018


From: Mathias Fröhlich <mathias.froehlich at web.de>

The only remaining users of gl_vertex_array are tnl based
drivers. So move everything related to that into tnl and
rename it accordingly.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 38 +++++------
 src/mesa/main/mtypes.h                       | 14 ----
 src/mesa/main/varray.h                       | 12 ----
 src/mesa/state_tracker/st_draw.h             |  1 -
 src/mesa/state_tracker/st_draw_feedback.c    |  2 +-
 src/mesa/tnl/t_context.c                     |  4 +-
 src/mesa/tnl/t_context.h                     | 41 +++++++++++-
 src/mesa/tnl/t_draw.c                        | 95 ++++++++++++++++++++++++++--
 src/mesa/tnl/t_rebase.c                      |  4 +-
 src/mesa/tnl/t_rebase.h                      |  2 +-
 src/mesa/tnl/t_split.c                       |  2 +-
 src/mesa/tnl/t_split.h                       |  4 +-
 src/mesa/tnl/t_split_copy.c                  | 34 ++++++----
 src/mesa/tnl/t_split_inplace.c               |  4 +-
 src/mesa/tnl/tnl.h                           | 24 +++++--
 src/mesa/vbo/vbo.h                           | 37 -----------
 src/mesa/vbo/vbo_exec.c                      | 86 -------------------------
 17 files changed, 200 insertions(+), 204 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index d031ebeabd..3900c770cb 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -41,7 +41,7 @@
  * structures. */
 
 static int
-get_array_stride(struct gl_context *ctx, const struct gl_vertex_array *a)
+get_array_stride(struct gl_context *ctx, const struct tnl_vertex_array *a)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
 	const struct gl_vertex_buffer_binding *binding = a->BufferBinding;
@@ -57,7 +57,7 @@ get_array_stride(struct gl_context *ctx, const struct gl_vertex_array *a)
 
 static void
 vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
-		const struct gl_vertex_array *arrays)
+		const struct tnl_vertex_array *arrays)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
 	GLboolean imm = (render->mode == IMM);
@@ -78,7 +78,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
 	}
 
 	FOR_EACH_BOUND_ATTR(render, i, attr) {
-		const struct gl_vertex_array *array = &arrays[attr];
+		const struct tnl_vertex_array *array = &arrays[attr];
 		const struct gl_vertex_buffer_binding *binding =
 			array->BufferBinding;
 		const struct gl_array_attributes *attrib = array->VertexAttrib;
@@ -94,7 +94,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
 
 static void
 vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
-		  const struct gl_vertex_array *arrays)
+		  const struct tnl_vertex_array *arrays)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
 	int i, attr;
@@ -118,7 +118,7 @@ vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
 /* Make some rendering decisions from the GL context. */
 
 static void
-vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array *arrays)
+vbo_choose_render_mode(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
 	int i;
@@ -136,12 +136,12 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array *arr
 }
 
 static void
-vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array *arrays,
+vbo_emit_attr(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
 	      int attr)
 {
 	struct nouveau_pushbuf *push = context_push(ctx);
 	struct nouveau_render_state *render = to_render_state(ctx);
-	const struct gl_vertex_array *array = &arrays[attr];
+	const struct tnl_vertex_array *array = &arrays[attr];
 	const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
 	const struct gl_array_attributes *attrib = array->VertexAttrib;
 	const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
@@ -179,7 +179,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array *arrays,
 #define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
 
 static void
-vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array *arrays)
+vbo_choose_attrs(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
 	int i;
@@ -222,13 +222,13 @@ vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array *arrays)
 }
 
 static int
-get_max_client_stride(struct gl_context *ctx, const struct gl_vertex_array *arrays)
+get_max_client_stride(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
 	int i, attr, s = 0;
 
 	FOR_EACH_BOUND_ATTR(render, i, attr) {
-		const struct gl_vertex_array *a = &arrays[attr];
+		const struct tnl_vertex_array *a = &arrays[attr];
 
 		if (!_mesa_is_bufferobj(a->BufferBinding->BufferObj))
 			s = MAX2(s, get_array_stride(ctx, a));
@@ -239,7 +239,7 @@ get_max_client_stride(struct gl_context *ctx, const struct gl_vertex_array *arra
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
-		      const struct gl_vertex_array *arrays,
+		      const struct tnl_vertex_array *arrays,
 		      const struct _mesa_prim *prims, GLuint nr_prims,
 		      const struct _mesa_index_buffer *ib,
 		      GLboolean index_bounds_valid,
@@ -249,7 +249,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
 		      struct gl_buffer_object *indirect);
 
 static GLboolean
-vbo_maybe_split(struct gl_context *ctx, const struct gl_vertex_array *arrays,
+vbo_maybe_split(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
 	    const struct _mesa_prim *prims, GLuint nr_prims,
 	    const struct _mesa_index_buffer *ib,
 	    GLuint min_index, GLuint max_index)
@@ -309,7 +309,7 @@ check_update_array(struct nouveau_array *a, unsigned offset,
 }
 
 static void
-vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays,
+vbo_bind_vertices(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
 		  int base, unsigned min_index, unsigned max_index, int *pdelta)
 {
 	struct nouveau_render_state *render = to_render_state(ctx);
@@ -323,7 +323,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays,
 	*pdelta = -1;
 
 	FOR_EACH_BOUND_ATTR(render, i, attr) {
-		const struct gl_vertex_array *array = &arrays[attr];
+		const struct tnl_vertex_array *array = &arrays[attr];
 		const struct gl_vertex_buffer_binding *binding =
 			array->BufferBinding;
 		const struct gl_array_attributes *attrib = array->VertexAttrib;
@@ -381,7 +381,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays,
 }
 
 static void
-vbo_draw_vbo(struct gl_context *ctx, const struct gl_vertex_array *arrays,
+vbo_draw_vbo(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
 	     const struct _mesa_prim *prims, GLuint nr_prims,
 	     const struct _mesa_index_buffer *ib, GLuint min_index,
 	     GLuint max_index)
@@ -431,7 +431,7 @@ extract_id(struct nouveau_array *a, int i, int j)
 }
 
 static void
-vbo_draw_imm(struct gl_context *ctx, const struct gl_vertex_array *arrays,
+vbo_draw_imm(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
 	     const struct _mesa_prim *prims, GLuint nr_prims,
 	     const struct _mesa_index_buffer *ib, GLuint min_index,
 	     GLuint max_index)
@@ -477,7 +477,7 @@ vbo_draw_imm(struct gl_context *ctx, const struct gl_vertex_array *arrays,
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
-		      const struct gl_vertex_array *arrays,
+		      const struct tnl_vertex_array *arrays,
 		      const struct _mesa_prim *prims, GLuint nr_prims,
 		      const struct _mesa_index_buffer *ib,
 		      GLboolean index_bounds_valid,
@@ -515,7 +515,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
 
 static void
 TAG(vbo_check_render_prims)(struct gl_context *ctx,
-			    const struct gl_vertex_array *arrays,
+			    const struct tnl_vertex_array *arrays,
 			    const struct _mesa_prim *prims, GLuint nr_prims,
 			    const struct _mesa_index_buffer *ib,
 			    GLboolean index_bounds_valid,
@@ -550,7 +550,7 @@ TAG(vbo_draw)(struct gl_context *ctx,
 	      struct gl_buffer_object *indirect)
 {
 	/* Borrow and update the inputs list from the tnl context */
-	const struct gl_vertex_array* arrays = _tnl_bind_inputs(ctx);
+	const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx);
 
 	TAG(vbo_check_render_prims)(ctx, arrays,
 				    prims, nr_prims, ib,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 284c48dda5..787f56c96a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1601,20 +1601,6 @@ struct gl_vertex_buffer_binding
 };
 
 
-/**
- * Vertex array information which is derived from gl_array_attributes
- * and gl_vertex_buffer_binding information.  Used by the VBO module and
- * device drivers.
- */
-struct gl_vertex_array
-{
-   /** Vertex attribute array */
-   const struct gl_array_attributes *VertexAttrib;
-   /** Vertex buffer binding */
-   const struct gl_vertex_buffer_binding *BufferBinding;
-};
-
-
 /**
  * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
  * the GL_ARB_vertex_array_object extension.
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 3888e5f469..a4f844f224 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -451,18 +451,6 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex,
                                 GLuint divisor);
 
 
-/**
- * Shallow copy one vertex array to another.
- */
-static inline void
-_mesa_copy_vertex_array(struct gl_vertex_array *dst,
-                        const struct gl_vertex_array *src)
-{
-   dst->VertexAttrib = src->VertexAttrib;
-   dst->BufferBinding = src->BufferBinding;
-}
-
-
 extern void
 _mesa_copy_vertex_attrib_array(struct gl_context *ctx,
                                struct gl_array_attributes *dst,
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index c1ebcd9f74..5b897bda11 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -38,7 +38,6 @@
 
 struct _mesa_index_buffer;
 struct _mesa_prim;
-struct gl_vertex_array;
 struct gl_context;
 struct st_context;
 
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 1e3f52c12e..696ebbf78d 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -180,7 +180,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
 
       if (_mesa_is_bufferobj(binding->BufferObj)) {
          /* Attribute data is in a VBO.
-          * Recall that for VBOs, the gl_vertex_array->Ptr field is
+          * Recall that for VBOs, the gl_array_attributes::Ptr field is
           * really an offset from the start of the VBO, not a pointer.
           */
          struct st_buffer_object *stobj = st_buffer_object(binding->BufferObj);
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 345f0bf858..3383b23525 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -99,8 +99,8 @@ _tnl_CreateContext( struct gl_context *ctx )
    _math_init_transformation();
    _math_init_translate();
 
-   /* Keep our list of gl_vertex_array inputs */
-   _vbo_init_inputs(&tnl->draw_arrays);
+   /* Keep our list of tnl_vertex_array inputs */
+   _tnl_init_inputs(&tnl->draw_arrays);
 
    return GL_TRUE;
 }
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 4827480e1a..eca9f66037 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -57,6 +57,8 @@
 
 #include "vbo/vbo.h"
 
+#include "tnl.h"
+
 #define MAX_PIPELINE_STAGES     30
 
 /*
@@ -496,6 +498,41 @@ struct tnl_device_driver
 };
 
 
+/**
+ * Utility that tracks and updates the current array entries.
+ */
+struct tnl_inputs
+{
+   /**
+    * Array of inputs to be set to the _DrawArrays pointer.
+    * The array contains pointers into the _DrawVAO and to the vbo modules
+    * current values. The array of pointers is updated incrementally
+    * based on the current and vertex_processing_mode values below.
+    */
+   struct tnl_vertex_array inputs[VERT_ATTRIB_MAX];
+   /** Those VERT_BIT_'s where the inputs array point to current values. */
+   GLbitfield current;
+   /** Store which aliasing current values - generics or materials - are set. */
+   gl_vertex_processing_mode vertex_processing_mode;
+};
+
+
+/**
+ * Initialize inputs.
+ */
+void
+_tnl_init_inputs(struct tnl_inputs *inputs);
+
+
+/**
+ * Update the tnl_vertex_array array inside the tnl_inputs structure
+ * provided the current _VPMode, the provided vao and
+ * the vao's enabled arrays filtered by the filter bitmask.
+ */
+void
+_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs);
+
+
 /**
  * Context state for T&L context.
  */
@@ -537,8 +574,8 @@ typedef struct
    struct tnl_shine_tab *_ShineTabList;  /**< MRU list of inactive shine tables */
    /**@}*/
 
-   /* The list of gl_vertex_array inputs. */
-   struct vbo_inputs draw_arrays;
+   /* The list of tnl_vertex_array inputs. */
+   struct tnl_inputs draw_arrays;
 } TNLcontext;
 
 
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index 9814cdcec1..1fe2d405cb 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 
 #include "main/glheader.h"
+#include "main/arrayobj.h"
 #include "main/bufferobj.h"
 #include "main/condrender.h"
 #include "main/context.h"
@@ -273,7 +274,7 @@ static GLboolean *_tnl_import_edgeflag( struct gl_context *ctx,
 
 
 static void bind_inputs( struct gl_context *ctx, 
-			 const struct gl_vertex_array *inputs,
+			 const struct tnl_vertex_array *inputs,
 			 GLint count,
 			 struct gl_buffer_object **bo,
 			 GLuint *nr_bo )
@@ -285,7 +286,7 @@ static void bind_inputs( struct gl_context *ctx,
    /* Map all the VBOs
     */
    for (i = 0; i < VERT_ATTRIB_MAX; i++) {
-      const struct gl_vertex_array *array = &inputs[i];
+      const struct tnl_vertex_array *array = &inputs[i];
       const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
       const struct gl_array_attributes *attrib = array->VertexAttrib;
       const void *ptr;
@@ -426,7 +427,7 @@ static void unmap_vbos( struct gl_context *ctx,
 /* This is the main workhorse doing all the rendering work.
  */
 void _tnl_draw_prims(struct gl_context *ctx,
-                     const struct gl_vertex_array *arrays,
+                     const struct tnl_vertex_array *arrays,
 			 const struct _mesa_prim *prim,
 			 GLuint nr_prims,
 			 const struct _mesa_index_buffer *ib,
@@ -537,11 +538,93 @@ void _tnl_draw_prims(struct gl_context *ctx,
 }
 
 
-const struct gl_vertex_array*
+void
+_tnl_init_inputs(struct tnl_inputs *inputs)
+{
+   inputs->current = 0;
+   inputs->vertex_processing_mode = VP_MODE_FF;
+}
+
+
+/**
+ * Update the tnl_inputs's arrays to point to the vao->_VertexArray arrays
+ * according to the 'enable' bitmask.
+ * \param enable  bitfield of VERT_BIT_x flags.
+ */
+static inline void
+update_vao_inputs(struct gl_context *ctx,
+                  struct tnl_inputs *inputs, GLbitfield enable)
+{
+   const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
+
+   /* Make sure we process only arrays enabled in the VAO */
+   assert((enable & ~_mesa_get_vao_vp_inputs(vao)) == 0);
+
+   /* Fill in the client arrays from the VAO */
+   const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0];
+   while (enable) {
+      const int attr = u_bit_scan(&enable);
+      struct tnl_vertex_array *input = &inputs->inputs[attr];
+      const struct gl_array_attributes *attrib;
+      attrib = _mesa_draw_array_attrib(vao, attr);
+      input->VertexAttrib = attrib;
+      input->BufferBinding = &bindings[attrib->BufferBindingIndex];
+   }
+}
+
+
+/**
+ * Update the tnl_inputs's arrays to point to the vbo->currval arrays
+ * according to the 'current' bitmask.
+ * \param current  bitfield of VERT_BIT_x flags.
+ */
+static inline void
+update_current_inputs(struct gl_context *ctx,
+                      struct tnl_inputs *inputs, GLbitfield current)
+{
+   gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
+
+   /* All previously non current array pointers need update. */
+   GLbitfield mask = current & ~inputs->current;
+   /* On mode change, the slots aliasing with materials need update too */
+   if (mode != inputs->vertex_processing_mode)
+      mask |= current & VERT_BIT_MAT_ALL;
+
+   while (mask) {
+      const int attr = u_bit_scan(&mask);
+      struct tnl_vertex_array *input = &inputs->inputs[attr];
+      input->VertexAttrib = _vbo_current_attrib(ctx, attr);
+      input->BufferBinding = _vbo_current_binding(ctx);
+   }
+
+   inputs->current = current;
+   inputs->vertex_processing_mode = mode;
+}
+
+
+/**
+ * Update the tnl_inputs's arrays to point to the vao->_VertexArray and
+ * vbo->currval arrays according to Array._DrawVAO and
+ * Array._DrawVAOEnableAttribs.
+ */
+void
+_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs)
+{
+   const GLbitfield enable = ctx->Array._DrawVAOEnabledAttribs;
+
+   /* Update array input pointers */
+   update_vao_inputs(ctx, inputs, enable);
+
+   /* The rest must be current inputs. */
+   update_current_inputs(ctx, inputs, ~enable & VERT_BIT_ALL);
+}
+
+
+const struct tnl_vertex_array*
 _tnl_bind_inputs( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   _vbo_update_inputs(ctx, &tnl->draw_arrays);
+   _tnl_update_inputs(ctx, &tnl->draw_arrays);
    return tnl->draw_arrays.inputs;
 }
 
@@ -560,7 +643,7 @@ _tnl_draw(struct gl_context *ctx,
 {
    /* Update TNLcontext::draw_arrays and return that pointer.
     */
-   const struct gl_vertex_array* arrays = _tnl_bind_inputs(ctx);
+   const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx);
 
    _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib,
                    index_bounds_valid, min_index, max_index,
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
index d28512423c..7df8e3cd8e 100644
--- a/src/mesa/tnl/t_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -103,7 +103,7 @@ REBASE(GLubyte)
  *      all or nothing.
  */
 void t_rebase_prims( struct gl_context *ctx,
-                     const struct gl_vertex_array *arrays,
+                     const struct tnl_vertex_array *arrays,
                      const struct _mesa_prim *prim,
                      GLuint nr_prims,
                      const struct _mesa_index_buffer *ib,
@@ -112,7 +112,7 @@ void t_rebase_prims( struct gl_context *ctx,
                      tnl_draw_func draw )
 {
    struct gl_array_attributes tmp_attribs[VERT_ATTRIB_MAX];
-   struct gl_vertex_array tmp_arrays[VERT_ATTRIB_MAX];
+   struct tnl_vertex_array tmp_arrays[VERT_ATTRIB_MAX];
 
    struct _mesa_index_buffer tmp_ib;
    struct _mesa_prim *tmp_prims = NULL;
diff --git a/src/mesa/tnl/t_rebase.h b/src/mesa/tnl/t_rebase.h
index ce2e8b0590..d0aa9e1890 100644
--- a/src/mesa/tnl/t_rebase.h
+++ b/src/mesa/tnl/t_rebase.h
@@ -28,7 +28,7 @@
 #include "tnl.h"
 
 void t_rebase_prims( struct gl_context *ctx,
-                     const struct gl_vertex_array *arrays,
+                     const struct tnl_vertex_array *arrays,
                      const struct _mesa_prim *prim,
                      GLuint nr_prims,
                      const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/tnl/t_split.c b/src/mesa/tnl/t_split.c
index b98bd404d5..d7aac10e4c 100644
--- a/src/mesa/tnl/t_split.c
+++ b/src/mesa/tnl/t_split.c
@@ -100,7 +100,7 @@ _tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr)
 
 void
 _tnl_split_prims(struct gl_context *ctx,
-                 const struct gl_vertex_array arrays[],
+                 const struct tnl_vertex_array arrays[],
                  const struct _mesa_prim *prim,
                  GLuint nr_prims,
                  const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/tnl/t_split.h b/src/mesa/tnl/t_split.h
index ced7d30bdf..49017e5dfb 100644
--- a/src/mesa/tnl/t_split.h
+++ b/src/mesa/tnl/t_split.h
@@ -51,7 +51,7 @@ _tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr);
 
 void
 _tnl_split_inplace(struct gl_context *ctx,
-                   const struct gl_vertex_array arrays[],
+                   const struct tnl_vertex_array arrays[],
                    const struct _mesa_prim *prim,
                    GLuint nr_prims,
                    const struct _mesa_index_buffer *ib,
@@ -64,7 +64,7 @@ _tnl_split_inplace(struct gl_context *ctx,
  */
 void
 _tnl_split_copy(struct gl_context *ctx,
-                const struct gl_vertex_array arrays[],
+                const struct tnl_vertex_array arrays[],
                 const struct _mesa_prim *prim,
                 GLuint nr_prims,
                 const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/tnl/t_split_copy.c b/src/mesa/tnl/t_split_copy.c
index f76a470b5f..cbb7eb409f 100644
--- a/src/mesa/tnl/t_split_copy.c
+++ b/src/mesa/tnl/t_split_copy.c
@@ -53,7 +53,7 @@
  */
 struct copy_context {
    struct gl_context *ctx;
-   const struct gl_vertex_array *array;
+   const struct tnl_vertex_array *array;
    const struct _mesa_prim *prim;
    GLuint nr_prims;
    const struct _mesa_index_buffer *ib;
@@ -64,7 +64,7 @@ struct copy_context {
    struct {
       GLuint attr;
       GLuint size;
-      const struct gl_vertex_array *array;
+      const struct tnl_vertex_array *array;
       const GLubyte *src_ptr;
 
       struct gl_vertex_buffer_binding dstbinding;
@@ -73,7 +73,7 @@ struct copy_context {
    } varying[VERT_ATTRIB_MAX];
    GLuint nr_varying;
 
-   struct gl_vertex_array dstarray[VERT_ATTRIB_MAX];
+   struct tnl_vertex_array dstarray[VERT_ATTRIB_MAX];
    struct _mesa_index_buffer dstib;
 
    GLuint *translated_elt_buf;
@@ -112,6 +112,18 @@ attr_size(const struct gl_array_attributes *attrib)
 }
 
 
+/**
+ * Shallow copy one vertex array to another.
+ */
+static inline void
+copy_vertex_array(struct tnl_vertex_array *dst,
+                  const struct tnl_vertex_array *src)
+{
+   dst->VertexAttrib = src->VertexAttrib;
+   dst->BufferBinding = src->BufferBinding;
+}
+
+
 /**
  * Starts returning true slightly before the buffer fills, to ensure
  * that there is sufficient room for any remaining vertices to finish
@@ -142,7 +154,7 @@ check_flush(struct copy_context *copy)
  */
 static void
 dump_draw_info(struct gl_context *ctx,
-               const struct gl_vertex_array *arrays,
+               const struct tnl_vertex_array *arrays,
                const struct _mesa_prim *prims,
                GLuint nr_prims,
                const struct _mesa_index_buffer *ib,
@@ -157,7 +169,7 @@ dump_draw_info(struct gl_context *ctx,
       printf("  Prim mode 0x%x\n", prims[i].mode);
       printf("  IB: %p\n", (void*) ib);
       for (j = 0; j < VERT_ATTRIB_MAX; j++) {
-         const struct gl_vertex_array *array = &arrays[j];
+         const struct tnl_vertex_array *array = &arrays[j];
          const struct gl_vertex_buffer_binding *binding
             = array->BufferBinding;
          const struct gl_array_attributes *attrib = array->VertexAttrib;
@@ -254,7 +266,7 @@ elt(struct copy_context *copy, GLuint elt_idx)
       GLuint i;
 
       for (i = 0; i < copy->nr_varying; i++) {
-         const struct gl_vertex_array *srcarray = copy->varying[i].array;
+         const struct tnl_vertex_array *srcarray = copy->varying[i].array;
          const struct gl_vertex_buffer_binding* srcbinding
             = srcarray->BufferBinding;
          const GLubyte *srcptr
@@ -432,11 +444,11 @@ replay_init(struct copy_context *copy)
     */
    copy->vertex_size = 0;
    for (i = 0; i < VERT_ATTRIB_MAX; i++) {
-      const struct gl_vertex_array *array = &copy->array[i];
+      const struct tnl_vertex_array *array = &copy->array[i];
       const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
 
       if (binding->Stride == 0) {
-         _mesa_copy_vertex_array(&copy->dstarray[i], array);
+         copy_vertex_array(&copy->dstarray[i], array);
       }
       else {
          const struct gl_array_attributes *attrib = array->VertexAttrib;
@@ -517,9 +529,9 @@ replay_init(struct copy_context *copy)
    /* Setup new vertex arrays to point into the output buffer:
     */
    for (offset = 0, i = 0; i < copy->nr_varying; i++) {
-      const struct gl_vertex_array *src = copy->varying[i].array;
+      const struct tnl_vertex_array *src = copy->varying[i].array;
       const struct gl_array_attributes *srcattr = src->VertexAttrib;
-      struct gl_vertex_array *dst = &copy->dstarray[i];
+      struct tnl_vertex_array *dst = &copy->dstarray[i];
       struct gl_vertex_buffer_binding *dstbind = &copy->varying[i].dstbinding;
       struct gl_array_attributes *dstattr = &copy->varying[i].dstattribs;
 
@@ -591,7 +603,7 @@ replay_finish(struct copy_context *copy)
  */
 void
 _tnl_split_copy(struct gl_context *ctx,
-                const struct gl_vertex_array *arrays,
+                const struct tnl_vertex_array *arrays,
                 const struct _mesa_prim *prim,
                 GLuint nr_prims,
                 const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/tnl/t_split_inplace.c b/src/mesa/tnl/t_split_inplace.c
index 15a09861c7..8e9ecb7046 100644
--- a/src/mesa/tnl/t_split_inplace.c
+++ b/src/mesa/tnl/t_split_inplace.c
@@ -43,7 +43,7 @@
  */
 struct split_context {
    struct gl_context *ctx;
-   const struct gl_vertex_array *array;
+   const struct tnl_vertex_array *array;
    const struct _mesa_prim *prim;
    GLuint nr_prims;
    const struct _mesa_index_buffer *ib;
@@ -265,7 +265,7 @@ split_prims(struct split_context *split)
 
 void
 _tnl_split_inplace(struct gl_context *ctx,
-                   const struct gl_vertex_array *arrays,
+                   const struct tnl_vertex_array *arrays,
                    const struct _mesa_prim *prim,
                    GLuint nr_prims,
                    const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h
index 01f8226aa6..d6dee9583a 100644
--- a/src/mesa/tnl/tnl.h
+++ b/src/mesa/tnl/tnl.h
@@ -30,7 +30,6 @@
 
 #include "main/glheader.h"
 
-struct gl_vertex_array;
 struct gl_context;
 struct gl_program;
 
@@ -63,7 +62,22 @@ _tnl_wakeup( struct gl_context *ctx );
 extern void
 _tnl_need_projected_coords( struct gl_context *ctx, GLboolean flag );
 
-extern const struct gl_vertex_array*
+
+/**
+ * Vertex array information which is derived from gl_array_attributes
+ * and gl_vertex_buffer_binding information.  Used by the VBO module and
+ * device drivers.
+ */
+struct tnl_vertex_array
+{
+   /** Vertex attribute array */
+   const struct gl_array_attributes *VertexAttrib;
+   /** Vertex buffer binding */
+   const struct gl_vertex_buffer_binding *BufferBinding;
+};
+
+
+extern const struct tnl_vertex_array*
 _tnl_bind_inputs( struct gl_context *ctx );
 
 
@@ -83,7 +97,7 @@ struct _mesa_index_buffer;
 
 void
 _tnl_draw_prims(struct gl_context *ctx,
-                const struct gl_vertex_array *arrays,
+                const struct tnl_vertex_array *arrays,
 		     const struct _mesa_prim *prim,
 		     GLuint nr_prims,
 		     const struct _mesa_index_buffer *ib,
@@ -150,7 +164,7 @@ _tnl_validate_shine_tables( struct gl_context *ctx );
  *                  This may be deprecated in the future
  */
 typedef void (*tnl_draw_func)(struct gl_context *ctx,
-                              const struct gl_vertex_array* arrays,
+                              const struct tnl_vertex_array* arrays,
                               const struct _mesa_prim *prims,
                               GLuint nr_prims,
                               const struct _mesa_index_buffer *ib,
@@ -178,7 +192,7 @@ struct split_limits
 
 void
 _tnl_split_prims(struct gl_context *ctx,
-                 const struct gl_vertex_array *arrays,
+                 const struct tnl_vertex_array *arrays,
                  const struct _mesa_prim *prim,
                  GLuint nr_prims,
                  const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index ca46f9baa7..4e3f15999c 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -38,9 +38,7 @@
 extern "C" {
 #endif
 
-struct gl_vertex_array;
 struct gl_context;
-struct gl_transform_feedback_object;
 
 struct _mesa_prim
 {
@@ -151,41 +149,6 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
                          struct gl_buffer_object *indirect);
 
 
-/**
- * Utility that tracks and updates the current array entries.
- */
-struct vbo_inputs
-{
-   /**
-    * Array of inputs to be set to the _DrawArrays pointer.
-    * The array contains pointers into the _DrawVAO and to the vbo modules
-    * current values. The array of pointers is updated incrementally
-    * based on the current and vertex_processing_mode values below.
-    */
-   struct gl_vertex_array inputs[VERT_ATTRIB_MAX];
-   /** Those VERT_BIT_'s where the inputs array point to current values. */
-   GLbitfield current;
-   /** Store which aliasing current values - generics or materials - are set. */
-   gl_vertex_processing_mode vertex_processing_mode;
-};
-
-
-/**
- * Initialize inputs.
- */
-void
-_vbo_init_inputs(struct vbo_inputs *inputs);
-
-
-/**
- * Update the gl_vertex_array array inside the vbo_inputs structure
- * provided the current _VPMode, the provided vao and
- * the vao's enabled arrays filtered by the filter bitmask.
- */
-void
-_vbo_update_inputs(struct gl_context *ctx, struct vbo_inputs *inputs);
-
-
 const struct gl_array_attributes*
 _vbo_current_attrib(const struct gl_context *ctx, gl_vert_attrib attr);
 
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index b23747aa39..db4920b4cf 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -240,89 +240,3 @@ vbo_merge_prims(struct _mesa_prim *p0, const struct _mesa_prim *p1)
    p0->count += p1->count;
    p0->end = p1->end;
 }
-
-
-void
-_vbo_init_inputs(struct vbo_inputs *inputs)
-{
-   inputs->current = 0;
-   inputs->vertex_processing_mode = VP_MODE_FF;
-}
-
-
-/**
- * Update the vbo_inputs's arrays to point to the vao->_VertexArray arrays
- * according to the 'enable' bitmask.
- * \param enable  bitfield of VERT_BIT_x flags.
- */
-static inline void
-update_vao_inputs(struct gl_context *ctx,
-                  struct vbo_inputs *inputs, GLbitfield enable)
-{
-   const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
-
-   /* Make sure we process only arrays enabled in the VAO */
-   assert((enable & ~_mesa_get_vao_vp_inputs(vao)) == 0);
-
-   /* Fill in the client arrays from the VAO */
-   const GLubyte *const map = _mesa_vao_attribute_map[vao->_AttributeMapMode];
-   const struct gl_array_attributes *attribs = &vao->VertexAttrib[0];
-   const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0];
-   while (enable) {
-      const int attr = u_bit_scan(&enable);
-      struct gl_vertex_array *input = &inputs->inputs[attr];
-      const struct gl_array_attributes *attrib = &attribs[map[attr]];
-      input->VertexAttrib = attrib;
-      input->BufferBinding = &bindings[attrib->BufferBindingIndex];
-   }
-}
-
-
-/**
- * Update the vbo_inputs's arrays to point to the vbo->currval arrays
- * according to the 'current' bitmask.
- * \param current  bitfield of VERT_BIT_x flags.
- */
-static inline void
-update_current_inputs(struct gl_context *ctx,
-                      struct vbo_inputs *inputs, GLbitfield current)
-{
-   gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
-
-   /* All previously non current array pointers need update. */
-   GLbitfield mask = current & ~inputs->current;
-   /* On mode change, the slots aliasing with materials need update too */
-   if (mode != inputs->vertex_processing_mode)
-      mask |= current & VERT_BIT_MAT_ALL;
-
-   struct vbo_context *vbo = vbo_context(ctx);
-   const struct gl_array_attributes *const currval = &vbo->current[0];
-   const GLubyte *const map = _vbo_attribute_alias_map[mode];
-   while (mask) {
-      const int attr = u_bit_scan(&mask);
-      struct gl_vertex_array *input = &inputs->inputs[attr];
-      input->VertexAttrib = &currval[map[attr]];
-      input->BufferBinding = &vbo->binding;
-   }
-
-   inputs->current = current;
-   inputs->vertex_processing_mode = mode;
-}
-
-
-/**
- * Update the vbo_inputs's arrays to point to the vao->_VertexArray and
- * vbo->currval arrays according to Array._DrawVAO and
- * Array._DrawVAOEnableAttribs.
- */
-void
-_vbo_update_inputs(struct gl_context *ctx, struct vbo_inputs *inputs)
-{
-   const GLbitfield enable = ctx->Array._DrawVAOEnabledAttribs;
-
-   /* Update array input pointers */
-   update_vao_inputs(ctx, inputs, enable);
-
-   /* The rest must be current inputs. */
-   update_current_inputs(ctx, inputs, ~enable & VERT_BIT_ALL);
-}
-- 
2.14.3



More information about the mesa-dev mailing list