Simplify draw module's vertex_info.
authorBrian <brian.paul@tungstengraphics.com>
Wed, 21 Nov 2007 22:40:20 +0000 (15:40 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 21 Nov 2007 22:40:20 +0000 (15:40 -0700)
No longer store the vertex header and clip pos info in the draw module's
vertex_info.  The vertex_info just describes the data[] elements.
This simplifies the code in several places.

src/mesa/pipe/draw/draw_clip.c
src/mesa/pipe/draw/draw_flatshade.c
src/mesa/pipe/draw/draw_vertex.c
src/mesa/pipe/draw/draw_vertex.h
src/mesa/pipe/draw/draw_vertex_shader.c
src/mesa/pipe/draw/draw_vertex_shader_llvm.c

index bc62d42..e4c257a 100644 (file)
@@ -128,12 +128,8 @@ static void interp( const struct clipper *clip,
    /* Other attributes
     * Note: start at 1 to skip winpos (data[0]) since we just computed
     * it above.
-    * Subtract two from nr_attrs since the first two attribs (always 
-    * VF_ATTRIB_VERTEX_HEADER and VF_ATTRIB_CLIP_POS, see
-    * draw_set_vertex_attributes()) are in the vertex_header struct,
-    * not in the data[] array.
     */
-   for (j = 1; j < nr_attrs - 2; j++) {
+   for (j = 1; j < nr_attrs; j++) {
       interp_attr(dst->data[j], t, in->data[j], out->data[j]);
    }
 }
@@ -352,12 +348,8 @@ do_clip_line( struct draw_stage *stage,
 
 static void clip_begin( struct draw_stage *stage )
 {
-   /* sanity checks.  If these fail, review the clip/interp code! */
-   assert(stage->draw->vertex_info.num_attribs >= 3);
-#if 0
-   assert(stage->draw->vertex_info.slot_to_attrib[0] == TGSI_ATTRIB_VERTEX_HEADER);
-   assert(stage->draw->vertex_info.slot_to_attrib[1] == TGSI_ATTRIB_CLIP_POS);
-#endif
+   /* should always have position, at least */
+   assert(stage->draw->vertex_info.num_attribs >= 1);
 
    stage->next->begin( stage->next );
 }
index 3b22c01..d46e53f 100644 (file)
@@ -60,8 +60,9 @@ static INLINE void copy_colors( struct draw_stage *stage,
    uint i;
 
    /* Look for constant/flat attribs and duplicate from src to dst vertex */
-   for (i = 1; i < num_attribs - 2; i++) {
-      if (interp[i + 2] == INTERP_CONSTANT) {
+   /* skip attrib[0] which is vert pos */
+   for (i = 1; i < num_attribs; i++) {
+      if (interp[i] == INTERP_CONSTANT) {
          copy_attr( i, dst, src );
       }
    }
index dea26a3..983ed71 100644 (file)
@@ -75,7 +75,6 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
          vinfo->size += 3;
          break;
       case FORMAT_4F:
-      case FORMAT_4F_VIEWPORT:
          vinfo->size += 4;
          break;
       default:
@@ -99,27 +98,26 @@ draw_set_vertex_attributes( struct draw_context *draw,
    struct vertex_info *vinfo = &draw->vertex_info;
    unsigned i;
 
-#if 0
-   assert(slot_to_vf_attr[0] == TGSI_ATTRIB_POS);
-#endif
+   assert(interps[0] == INTERP_LINEAR); /* should be vert pos */
 
-   memset(vinfo, 0, sizeof(*vinfo));
+   assert(nr_attrs <= PIPE_MAX_SHADER_OUTPUTS);
 
-   /*
-    * First three attribs are always the same: header, clip pos, winpos
+   /* 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.
     */
-   emit_vertex_attr(vinfo, FORMAT_1F, INTERP_NONE);
-   emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
-   emit_vertex_attr(vinfo, FORMAT_4F_VIEWPORT, INTERP_LINEAR);
 
-   /*
-    * Remaining attribs (color, texcoords, etc)
-    */
-   for (i = 1; i < nr_attrs; i++) {
+   memset(vinfo, 0, sizeof(*vinfo));
+
+   /* copy attrib info */
+   for (i = 0; i < nr_attrs; i++) {
       emit_vertex_attr(vinfo, FORMAT_4F, interps[i]);
    }
 
    draw_compute_vertex_size(vinfo);
+
+   /* add extra words for vertex header (uint), clip pos (float[4]) */
+   vinfo->size += 5;
 }
 
 
index a1fa7aa..d9b5e7c 100644 (file)
@@ -46,7 +46,6 @@ enum attrib_format {
    FORMAT_2F,
    FORMAT_3F,
    FORMAT_4F,
-   FORMAT_4F_VIEWPORT,
    FORMAT_4UB
 };
 
index e8801ad..52fb2d8 100644 (file)
@@ -158,10 +158,8 @@ run_vertex_program(struct draw_context *draw,
 #endif
       /* Remaining attributes are packed into sequential post-transform
        * vertex attrib slots.
-       * Skip 0 since we just did it above.
-       * Subtract two because of the VERTEX_HEADER, CLIP_POS attribs.
        */
-      for (slot = 1; slot < draw->vertex_info.num_attribs - 2; slot++) {
+      for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
          vOut[j]->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
          vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
          vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
index 3e005a7..53a1776 100644 (file)
@@ -173,10 +173,8 @@ void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw)
 
       /* Remaining attributes are packed into sequential post-transform
        * vertex attrib slots.
-       * Skip 0 since we just did it above.
-       * Subtract two because of the VERTEX_HEADER, CLIP_POS attribs.
        */
-      for (slot = 1; slot < draw->vertex_info.num_attribs - 2; slot++) {
+      for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
          vOut->data[slot][0] = dests[slot][0];
          vOut->data[slot][1] = dests[slot][1];
          vOut->data[slot][2] = dests[slot][2];