diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-07-13 10:33:48 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-07-13 10:33:48 -0600 |
commit | 46bba80a54afbcabc0f064433cc2194473661c30 (patch) | |
tree | 3171f28650d274d28b2605797a505cff6e351922 /src/mesa/pipe/softpipe/sp_prim_setup.c | |
parent | 5796056e289c5a698a1883586c7acde36f86618f (diff) |
Implement AA points and AA coverage application in quad pipeline.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_prim_setup.c')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_setup.c | 97 |
1 files changed, 67 insertions, 30 deletions
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index e94ca139aa..3d3f2b74fc 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -858,60 +858,97 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) const GLint ixmax = block((GLint) (x + halfSize)); const GLint iymin = block((GLint) (y - halfSize)); const GLint iymax = block((GLint) (y + halfSize)); - GLfloat halfSizeSquared = halfSize * halfSize; GLint ix, iy; - for (iy = iymin; iy <= iymax; iy += 2) { - for (ix = ixmin; ix <= ixmax; ix += 2) { + if (round) { + /* rounded points */ + const GLfloat rmin = halfSize - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + const GLfloat rmax = halfSize + 0.7071F; + const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); + const GLfloat rmax2 = rmax * rmax; + const GLfloat cscale = 1.0F / (rmax2 - rmin2); - if (round) { - /* rounded points */ - /* XXX for GL_SMOOTH, need to compute per-fragment coverage too */ - GLfloat dx, dy; + for (iy = iymin; iy <= iymax; iy += 2) { + for (ix = ixmin; ix <= ixmax; ix += 2) { + GLfloat dx, dy, dist2, cover; setup->quad.mask = 0x0; dx = (ix + 0.5) - x; dy = (iy + 0.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) + dist2 = dx * dx + dy * dy; + if (dist2 <= rmax2) { + cover = 1.0F - (dist2 - rmin2) * cscale; + setup->quad.coverage[QUAD_BOTTOM_LEFT] = MIN2(cover, 1.0); setup->quad.mask |= MASK_BOTTOM_LEFT; + } dx = (ix + 1.5) - x; dy = (iy + 0.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) + dist2 = dx * dx + dy * dy; + if (dist2 <= rmax2) { + cover = 1.0F - (dist2 - rmin2) * cscale; + setup->quad.coverage[QUAD_BOTTOM_RIGHT] = MIN2(cover, 1.0); setup->quad.mask |= MASK_BOTTOM_RIGHT; + } dx = (ix + 0.5) - x; dy = (iy + 1.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) + dist2 = dx * dx + dy * dy; + if (dist2 <= rmax2) { + cover = 1.0F - (dist2 - rmin2) * cscale; + setup->quad.coverage[QUAD_TOP_LEFT] = MIN2(cover, 1.0); setup->quad.mask |= MASK_TOP_LEFT; + } dx = (ix + 1.5) - x; dy = (iy + 1.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) + dist2 = dx * dx + dy * dy; + if (dist2 <= rmax2) { + cover = 1.0F - (dist2 - rmin2) * cscale; + setup->quad.coverage[QUAD_TOP_RIGHT] = MIN2(cover, 1.0); setup->quad.mask |= MASK_TOP_RIGHT; - } - else { - /* square points */ - setup->quad.mask = 0xf; - - if (ix + 0.5 < x - halfSize) - setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); - - if (ix + 1.5 > x + halfSize) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT); - - if (iy + 0.5 < y - halfSize) - setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT); + } - if (iy + 1.5 > y + halfSize) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); + if (setup->quad.mask) { + setup->quad.x0 = ix; + setup->quad.y0 = iy; + quad_emit( setup->softpipe, &setup->quad ); + } } + } + } + else { + /* square points */ + for (iy = iymin; iy <= iymax; iy += 2) { + for (ix = ixmin; ix <= ixmax; ix += 2) { + setup->quad.mask = 0xf; - if (setup->quad.mask) { - setup->quad.x0 = ix; - setup->quad.y0 = iy; - quad_emit( setup->softpipe, &setup->quad ); + if (ix + 0.5 < x - halfSize) { + /* fragment is past left edge of point, turn off left bits */ + setup->quad.mask &= ~(MASK_BOTTOM_LEFT | MASK_TOP_LEFT); + } + + if (ix + 1.5 > x + halfSize) { + /* past the right edge */ + setup->quad.mask &= ~(MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); + } + + if (iy + 0.5 < y - halfSize) { + /* below the bottom edge */ + setup->quad.mask &= ~(MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); + } + + if (iy + 1.5 > y + halfSize) { + /* above the top edge */ + setup->quad.mask &= ~(MASK_TOP_LEFT | MASK_TOP_RIGHT); + } + + if (setup->quad.mask) { + setup->quad.x0 = ix; + setup->quad.y0 = iy; + quad_emit( setup->softpipe, &setup->quad ); + } } } } |