Add 'prim' field to quad so that stipple and aa coverage stages can do the right...
authorBrian <brian.paul@tungstengraphics.com>
Fri, 13 Jul 2007 17:15:10 +0000 (11:15 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 13 Jul 2007 17:15:10 +0000 (11:15 -0600)
src/mesa/pipe/softpipe/sp_headers.h
src/mesa/pipe/softpipe/sp_prim_setup.c
src/mesa/pipe/softpipe/sp_quad_coverage.c
src/mesa/pipe/softpipe/sp_quad_stipple.c

index bcc0f99..68a8462 100644 (file)
@@ -64,17 +64,16 @@ struct setup_coefficient {
 
 
 
-/* Encodes everything we need to know about a 2x2 pixel block.  Uses
+/**
+ * Encodes everything we need to know about a 2x2 pixel block.  Uses
  * "Channel-Serial" or "SoA" layout.  
- *
- * Will expand to include non-attribute things like AA coverage and
- * maybe prefetched depth from the depth buffer.
  */
 struct quad_header {
    GLint x0;
    GLint y0;
-   GLuint mask;
-   GLuint facing;   /**< Front (0) or back (1) facing? */
+   GLuint mask:4;
+   GLuint facing:1;   /**< Front (0) or back (1) facing? */
+   GLuint prim:2;     /**< PRIM_POINT, LINE, TRI */
 
    struct {
       GLfloat color[4][QUAD_SIZE];     /* rrrr, gggg, bbbb, aaaa */
index 3d3f2b7..6420fc8 100644 (file)
@@ -569,6 +569,8 @@ static void setup_tri( struct draw_stage *stage,
    setup_tri_coefficients( setup );
    setup_tri_edges( setup );
 
+   setup->quad.prim = PRIM_TRI;
+
    setup->span.y = 0;
    setup->span.y_flags = 0;
    setup->span.right[0] = 0;
@@ -751,6 +753,7 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
 
    setup->quad.x0 = setup->quad.y0 = -1;
    setup->quad.mask = 0x0;
+   setup->quad.prim = PRIM_LINE;
 
    if (dx > dy) {
       /*** X-major line ***/
@@ -842,6 +845,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
          const_coeff(setup, slot, j);
    }
 
+   setup->quad.prim = PRIM_POINT;
+
    /* XXX need to clip against scissor bounds too */
 
    if (halfSize <= 0.5 && !round) {
index 05cd03b..cdd8890 100644 (file)
  * Multiply quad's alpha values by the fragment coverage.
  */
 static void
-apply_aa_coverage_quad(struct quad_stage *qs, struct quad_header *quad)
+coverage_quad(struct quad_stage *qs, struct quad_header *quad)
 {
-#if 0
    struct softpipe_context *softpipe = qs->softpipe;
 
-   /* XXX need to know if this quad is from a point, line or polygon! */
-   if ((softpipe->setup.poly_smooth && prim == POLYGON) ||
-       (softpipe->setup.line_smooth && prim == LINE) ||
-       (softpipe->setup.point_smooth && prim == POINT)) {
-#endif
+   if ((softpipe->setup.poly_smooth && quad->prim == PRIM_TRI) ||
+       (softpipe->setup.line_smooth && quad->prim == PRIM_LINE) ||
+       (softpipe->setup.point_smooth && quad->prim == PRIM_POINT)) {
       GLuint j;
       for (j = 0; j < QUAD_SIZE; j++) {
          assert(quad->coverage[j] >= 0.0);
          assert(quad->coverage[j] <= 1.0);
          quad->outputs.color[3][j] *= quad->coverage[j];
       }
-#if 0
    }
-#endif
 
    qs->next->run(qs->next, quad);
 }
@@ -73,7 +68,7 @@ struct quad_stage *sp_quad_coverage_stage( struct softpipe_context *softpipe )
    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
 
    stage->softpipe = softpipe;
-   stage->run = apply_aa_coverage_quad;
+   stage->run = coverage_quad;
 
    return stage;
 }
index 928771e..532ffc6 100644 (file)
 
 /**
  * Apply polygon stipple to quads produced by triangle rasterization
- * XXX we need to skip this for lines and points!!!
  */
 static void
 stipple_quad(struct quad_stage *qs, struct quad_header *quad)
 {
-   struct softpipe_context *softpipe = qs->softpipe;
-   const GLint col0 = quad->x0 % 32;
-   const GLint row0 = quad->y0 % 32;
-   const GLuint stipple0 = softpipe->poly_stipple.stipple[row0];
-   const GLuint stipple1 = softpipe->poly_stipple.stipple[row0 + 1];
+   if (quad->prim == PRIM_TRI) {
+      struct softpipe_context *softpipe = qs->softpipe;
+      const GLint col0 = quad->x0 % 32;
+      const GLint row0 = quad->y0 % 32;
+      const GLuint stipple0 = softpipe->poly_stipple.stipple[row0];
+      const GLuint stipple1 = softpipe->poly_stipple.stipple[row0 + 1];
 
-   /* XXX this should be acheivable without conditionals */
+      /* XXX this should be acheivable without conditionals */
 #if 1
-   GLbitfield mask = 0x0;
+      GLbitfield mask = 0x0;
 
-   if ((1 << col0) & stipple0)
-      mask |= MASK_BOTTOM_LEFT;
+      if ((1 << col0) & stipple0)
+         mask |= MASK_BOTTOM_LEFT;
 
-   if ((2 << col0) & stipple0) /* note: col0 <= 30 */
-      mask |= MASK_BOTTOM_RIGHT;
+      if ((2 << col0) & stipple0)      /* note: col0 <= 30 */
+         mask |= MASK_BOTTOM_RIGHT;
 
-   if ((1 << col0) & stipple1)
-      mask |= MASK_TOP_LEFT;
+      if ((1 << col0) & stipple1)
+         mask |= MASK_TOP_LEFT;
 
-   if ((2 << col0) & stipple1)
-      mask |= MASK_TOP_RIGHT;
+      if ((2 << col0) & stipple1)
+         mask |= MASK_TOP_RIGHT;
 
-   quad->mask &= mask;
+      quad->mask &= mask;
 #else
-   /* XXX there may be a better way to lay out the stored stipple
-    * values to further simplify this computation.
-    */
-   quad->mask &= (((stipple0 >> col0) & 0x3) | 
-                 (((stipple1 >> col0) & 0x3) << 2));
+      /* XXX there may be a better way to lay out the stored stipple
+       * values to further simplify this computation.
+       */
+      quad->mask &= (((stipple0 >> col0) & 0x3) | 
+                     (((stipple1 >> col0) & 0x3) << 2));
 #endif
 
-   if (quad->mask)
-      qs->next->run(qs->next, quad);
+      if (quad->mask)
+         qs->next->run(qs->next, quad);
+   }
 }