Replace draw_set_vertex_attributes() with simpler draw_set_vertex_info().
authorBrian <brian.paul@tungstengraphics.com>
Wed, 21 Nov 2007 23:00:57 +0000 (16:00 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 21 Nov 2007 23:00:57 +0000 (16:00 -0700)
Just pass in the vertex_info object and make a copy of it.

src/mesa/pipe/draw/draw_vertex.c
src/mesa/pipe/draw/draw_vertex.h
src/mesa/pipe/i915simple/i915_state_derived.c
src/mesa/pipe/softpipe/sp_state_derived.c
src/mesa/state_tracker/st_draw.c

index 983ed71ec0fc68c39809e269255860c6db2b7c18..89f54ff18690ef12bf771a5c3388e37cc9114207 100644 (file)
@@ -87,37 +87,34 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
 
 
 /**
- * Tell the drawing module about the layout of post-transformation vertices
+ * Tell the drawing module about the contents of post-transformation vertices.
+ * Note that the vertex attribute format info isn't used by 'draw'; all
+ * attributes are handled as float[4].  But when the driver emits vertices
+ * it'll use that info.
+ * We _do_ care about the number of attributes and their interpolation modes.
  */
 void
-draw_set_vertex_attributes( struct draw_context *draw,
-                            const uint *slot_to_vf_attr,
-                            const enum interp_mode *interps,
-                            unsigned nr_attrs )
+draw_set_vertex_info( struct draw_context *draw,
+                      const struct vertex_info *info)
 {
-   struct vertex_info *vinfo = &draw->vertex_info;
-   unsigned i;
+   assert(info->interp_mode[0] == INTERP_LINEAR); /* should be vert pos */
 
-   assert(interps[0] == INTERP_LINEAR); /* should be vert pos */
-
-   assert(nr_attrs <= PIPE_MAX_SHADER_OUTPUTS);
+   assert(info->num_attribs <= PIPE_MAX_SHADER_OUTPUTS);
 
    /* Note that draw-module vertices will consist of the attributes passed
     * to this function, plus a header/prefix containing the vertex header
     * flags and GLfloat[4] clip pos.
     */
 
-   memset(vinfo, 0, sizeof(*vinfo));
-
-   /* copy attrib info */
-   for (i = 0; i < nr_attrs; i++) {
-      emit_vertex_attr(vinfo, FORMAT_4F, interps[i]);
-   }
+   memcpy(&draw->vertex_info, info, sizeof(*info));
 
-   draw_compute_vertex_size(vinfo);
+   draw_compute_vertex_size(&draw->vertex_info);
 
-   /* add extra words for vertex header (uint), clip pos (float[4]) */
-   vinfo->size += 5;
+   /* Need to know vertex size (in words) for vertex copying elsewhere.
+    * Four words per attribute, plus vertex header (uint) and clip
+    * position (float[4]).
+    */
+   draw->vertex_info.size = draw->vertex_info.num_attribs * 4 + 5;
 }
 
 
index d9b5e7c8c0f9dd6b86b874d61083fa92cf211a14..8bb328affa3a6cc785d505a00e801d4202230f27 100644 (file)
@@ -92,10 +92,8 @@ draw_emit_vertex_attr(struct vertex_info *vinfo,
 }
 
 
-extern void draw_set_vertex_attributes( struct draw_context *draw,
-                                        const uint *attrs,
-                                        const enum interp_mode *interps,
-                                        unsigned nr_attrs );
+extern void draw_set_vertex_info( struct draw_context *draw,
+                                  const struct vertex_info *info);
 
 extern void draw_set_twoside_attributes(struct draw_context *draw,
                                         uint front0, uint back0,
index ed1521fcce297f3bc917fe3970ebdd069625d5d6..688c0c5798b5525bab8c9d0ee6689248e2ea7320 100644 (file)
@@ -132,11 +132,8 @@ static void calculate_vertex_layout( struct i915_context *i915 )
       /* If the attributes have changed, tell the draw module about the new
        * vertex layout.  We'll also update the hardware vertex format info.
        */
-      draw_set_vertex_attributes( i915->draw,
-                                  NULL,/*vinfo.slot_to_attrib,*/
-                                  vinfo.interp_mode,
-                                  vinfo.num_attribs);
-      
+      draw_set_vertex_info( i915->draw, &vinfo);
+
       draw_set_twoside_attributes(i915->draw,
                                   front0, back0, front1, back1);
 
index 81f70f0f244fa3f2714802577f715cc9b93be58f..7e5efbfde39899712bb9c6c60ab9f6e8e27b5d0d 100644 (file)
@@ -156,10 +156,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
    if (1/*vinfo->attr_mask != softpipe->attr_mask*/) {
       /*softpipe->attr_mask = vinfo->attr_mask;*/
 
-      draw_set_vertex_attributes( softpipe->draw,
-                                  NULL,/*vinfo->slot_to_attrib,*/
-                                  vinfo->interp_mode,
-                                  vinfo->num_attribs);
+      draw_set_vertex_info( softpipe->draw, vinfo);
 
       draw_set_twoside_attributes(softpipe->draw,
                                   front0, back0, front1, back1);
index 3b6d8291452cf7628a8d81f07f89d8cd991a26c5..61ff034550dcb7bebffd71188de2c55ca243f4be 100644 (file)
@@ -324,27 +324,26 @@ static void
 set_feedback_vertex_format(GLcontext *ctx)
 {
    struct st_context *st = ctx->st;
-   uint attrs[PIPE_MAX_SHADER_OUTPUTS];
-   enum interp_mode interp[PIPE_MAX_SHADER_OUTPUTS];
-   GLuint n, i;
+   struct vertex_info vinfo;
+   GLuint i;
 
    if (ctx->RenderMode == GL_SELECT) {
       assert(ctx->RenderMode == GL_SELECT);
-      n = 1;
-      attrs[0] = FORMAT_4F;
-      interp[0] = INTERP_NONE;
+      vinfo.num_attribs = 1;
+      vinfo.format[0] = FORMAT_4F;
+      vinfo.interp_mode[0] = INTERP_NONE;
    }
    else {
       /* GL_FEEDBACK, or glRasterPos */
       /* emit all attribs (pos, color, texcoord) as GLfloat[4] */
-      n = st->state.vs->state.num_outputs;
-      for (i = 0; i < n; i++) {
-         attrs[i] = FORMAT_4F;
-         interp[i] = INTERP_NONE;
+      vinfo.num_attribs = st->state.vs->state.num_outputs;
+      for (i = 0; i < vinfo.num_attribs; i++) {
+         vinfo.format[i] = FORMAT_4F;
+         vinfo.interp_mode[i] = INTERP_LINEAR;
       }
    }
 
-   draw_set_vertex_attributes(st->draw, attrs, interp, n);
+   draw_set_vertex_info(st->draw, &vinfo);
 }