From 80362a90d8ad1fca14d7276169fc962f953d936d Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 13 Jul 2007 11:15:10 -0600 Subject: Add 'prim' field to quad so that stipple and aa coverage stages can do the right thing. --- src/mesa/pipe/softpipe/sp_headers.h | 11 ++++--- src/mesa/pipe/softpipe/sp_prim_setup.c | 5 ++++ src/mesa/pipe/softpipe/sp_quad_coverage.c | 15 ++++------ src/mesa/pipe/softpipe/sp_quad_stipple.c | 49 ++++++++++++++++--------------- 4 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/softpipe/sp_headers.h b/src/mesa/pipe/softpipe/sp_headers.h index bcc0f99add..68a84621f2 100644 --- a/src/mesa/pipe/softpipe/sp_headers.h +++ b/src/mesa/pipe/softpipe/sp_headers.h @@ -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 */ diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 3d3f2b74fc..6420fc8809 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -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) { diff --git a/src/mesa/pipe/softpipe/sp_quad_coverage.c b/src/mesa/pipe/softpipe/sp_quad_coverage.c index 05cd03bce0..cdd8890c7f 100644 --- a/src/mesa/pipe/softpipe/sp_quad_coverage.c +++ b/src/mesa/pipe/softpipe/sp_quad_coverage.c @@ -44,25 +44,20 @@ * 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; } diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c index 928771e454..532ffc61b0 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stipple.c +++ b/src/mesa/pipe/softpipe/sp_quad_stipple.c @@ -13,44 +13,45 @@ /** * 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); + } } -- cgit v1.2.3