diff options
author | Brian Paul <[email protected]> | 2001-05-15 21:30:26 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2001-05-15 21:30:26 +0000 |
commit | 5071b0812fc73bcba92e2b6fcbad2f53f063fc32 (patch) | |
tree | d83905130a82d8f6dfc14668f96aa5768a8cb198 /src/mesa | |
parent | a51f07d5a148705c1c118dece1630972753ca349 (diff) |
Apply antialiasing coverage factor to alpha after texture application,
not before.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/swrast/s_aalinetemp.h | 23 | ||||
-rw-r--r-- | src/mesa/swrast/s_aatritemp.h | 111 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 20 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 35 | ||||
-rw-r--r-- | src/mesa/swrast/s_pointtemp.h | 24 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 172 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.h | 89 | ||||
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 34 | ||||
-rw-r--r-- | src/mesa/swrast/s_zoom.c | 9 |
9 files changed, 294 insertions, 223 deletions
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 262af3ee3b3..996784dde4a 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -1,4 +1,4 @@ -/* $Id: s_aalinetemp.h,v 1.9 2001/05/10 17:41:41 brianp Exp $ */ +/* $Id: s_aalinetemp.h,v 1.10 2001/05/15 21:30:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -42,8 +42,11 @@ NAME(plot)(GLcontext *ctx, const struct LineInfo *line, const GLfloat coverage = compute_coveragef(line, ix, iy); GLdepth z; GLfloat fog; +#ifdef DO_RGBA GLchan red, green, blue, alpha; - GLint frac, indx, index; +#else + GLint index; +#endif GLchan specRed, specGreen, specBlue; GLfloat tex[MAX_TEXTURE_UNITS][4], lambda[MAX_TEXTURE_UNITS]; @@ -68,20 +71,11 @@ NAME(plot)(GLcontext *ctx, const struct LineInfo *line, red = solve_plane_chan(fx, fy, line->rPlane); green = solve_plane_chan(fx, fy, line->gPlane); blue = solve_plane_chan(fx, fy, line->bPlane); - alpha = (GLchan) (solve_plane_chan(fx, fy, line->aPlane) * coverage);; -#else - (void) red; - (void) green; - (void) blue; - (void) alpha; + alpha = solve_plane_chan(fx, fy, line->aPlane); #endif #ifdef DO_INDEX - frac = (GLint) (15.0 * coverage); - indx = (GLint) solve_plane(fx, fy, line->iPlane); - index = (indx & ~0xf) | frac; + index = (GLint) solve_plane(fx, fy, line->iPlane); #else - (void) frac; - (void) indx; (void) index; #endif #ifdef DO_SPEC @@ -123,6 +117,8 @@ NAME(plot)(GLcontext *ctx, const struct LineInfo *line, #endif + PB_COVERAGE(pb, coverage); + #if defined(DO_MULTITEX) #if defined(DO_SPEC) PB_WRITE_MULTITEX_SPEC_PIXEL(pb, ix, iy, z, fog, red, green, blue, alpha, @@ -139,6 +135,7 @@ NAME(plot)(GLcontext *ctx, const struct LineInfo *line, PB_WRITE_CI_PIXEL(pb, ix, iy, z, fog, index); #endif + pb->haveCoverage = GL_TRUE; PB_CHECK_FLUSH(ctx, pb); } diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 354dd48abe2..9f6695ce33e 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_aatritemp.h,v 1.14 2001/05/15 16:18:13 brianp Exp $ */ +/* $Id: s_aatritemp.h,v 1.15 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -70,6 +70,9 @@ #ifdef DO_INDEX GLfloat iPlane[4]; /* color index */ GLuint index[MAX_WIDTH]; + GLint icoverageSpan[MAX_WIDTH]; +#else + GLfloat coverageSpan[MAX_WIDTH]; #endif #ifdef DO_SPEC GLfloat srPlane[4], sgPlane[4], sbPlane[4]; /* spec color */ @@ -283,6 +286,11 @@ while (coverage > 0.0F) { /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; +#ifdef DO_INDEX + icoverageSpan[count] = compute_coveragei(pMin, pMid, pMax, ix, iy); +#else + coverageSpan[count] = coverage; +#endif #ifdef DO_Z z[count] = (GLdepth) solve_plane(cx, cy, zPlane); #endif @@ -293,14 +301,10 @@ rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane); rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane); rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane); - rgba[count][ACOMP] = (GLchan) (solve_plane_chan(cx, cy, aPlane) * coverage); + rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane); #endif #ifdef DO_INDEX - { - GLint frac = compute_coveragei(pMin, pMid, pMax, ix, iy); - GLint indx = (GLint) solve_plane(cx, cy, iPlane); - index[count] = (indx & ~0xf) | frac; - } + index[count] = (GLint) solve_plane(cx, cy, iPlane); #endif #ifdef DO_SPEC spec[count][RCOMP] = solve_plane_chan(cx, cy, srPlane); @@ -344,33 +348,37 @@ #ifdef DO_MULTITEX # ifdef DO_SPEC _mesa_write_multitexture_span(ctx, n, startX, iy, z, fog, - (const GLfloat (*)[MAX_WIDTH]) s, - (const GLfloat (*)[MAX_WIDTH]) t, - (const GLfloat (*)[MAX_WIDTH]) u, - (GLfloat (*)[MAX_WIDTH]) lambda, - rgba, (const GLchan (*)[4]) spec, - GL_POLYGON); + (const GLfloat (*)[MAX_WIDTH]) s, + (const GLfloat (*)[MAX_WIDTH]) t, + (const GLfloat (*)[MAX_WIDTH]) u, + (GLfloat (*)[MAX_WIDTH]) lambda, + rgba, (const GLchan (*)[4]) spec, + coverageSpan, GL_POLYGON); # else _mesa_write_multitexture_span(ctx, n, startX, iy, z, fog, - (const GLfloat (*)[MAX_WIDTH]) s, - (const GLfloat (*)[MAX_WIDTH]) t, - (const GLfloat (*)[MAX_WIDTH]) u, - lambda, rgba, NULL, GL_POLYGON); + (const GLfloat (*)[MAX_WIDTH]) s, + (const GLfloat (*)[MAX_WIDTH]) t, + (const GLfloat (*)[MAX_WIDTH]) u, + lambda, rgba, NULL, coverageSpan, + GL_POLYGON); # endif #elif defined(DO_TEX) # ifdef DO_SPEC _mesa_write_texture_span(ctx, n, startX, iy, z, fog, - s, t, u, lambda, rgba, - (const GLchan (*)[4]) spec, GL_POLYGON); + s, t, u, lambda, rgba, + (const GLchan (*)[4]) spec, + coverageSpan, GL_POLYGON); # else _mesa_write_texture_span(ctx, n, startX, iy, z, fog, - s, t, u, lambda, - rgba, NULL, GL_POLYGON); + s, t, u, lambda, + rgba, NULL, coverageSpan, GL_POLYGON); # endif #elif defined(DO_RGBA) - _mesa_write_rgba_span(ctx, n, startX, iy, z, fog, rgba, GL_POLYGON); + _mesa_write_rgba_span(ctx, n, startX, iy, z, fog, rgba, + coverageSpan, GL_POLYGON); #elif defined(DO_INDEX) - _mesa_write_index_span(ctx, n, startX, iy, z, fog, index, GL_POLYGON); + _mesa_write_index_span(ctx, n, startX, iy, z, fog, index, + icoverageSpan, GL_POLYGON); #endif } } @@ -407,6 +415,11 @@ while (coverage > 0.0F) { /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; +#ifdef DO_INDEX + icoverageSpan[ix] = compute_coveragei(pMin, pMid, pMax, ix, iy); +#else + coverageSpan[ix] = coverage; +#endif #ifdef DO_Z z[ix] = (GLdepth) solve_plane(cx, cy, zPlane); #endif @@ -417,14 +430,10 @@ rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane); rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane); rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane); - rgba[ix][ACOMP] = (GLchan) (solve_plane_chan(cx, cy, aPlane) * coverage); + rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane); #endif #ifdef DO_INDEX - { - GLint frac = compute_coveragei(pMin, pMax, pMid, ix, iy); - GLint indx = (GLint) solve_plane(cx, cy, iPlane); - index[ix] = (indx & ~0xf) | frac; - } + index[ix] = (GLint) solve_plane(cx, cy, iPlane); #endif #ifdef DO_SPEC spec[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane); @@ -483,39 +492,43 @@ } # ifdef DO_SPEC _mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left, - (const GLfloat (*)[MAX_WIDTH]) s, - (const GLfloat (*)[MAX_WIDTH]) t, - (const GLfloat (*)[MAX_WIDTH]) u, - lambda, rgba + left, - (const GLchan (*)[4]) (spec + left), - GL_POLYGON); + (const GLfloat (*)[MAX_WIDTH]) s, + (const GLfloat (*)[MAX_WIDTH]) t, + (const GLfloat (*)[MAX_WIDTH]) u, + lambda, rgba + left, + (const GLchan (*)[4]) (spec + left), + coverageSpan + left, + GL_POLYGON); # else _mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left, - (const GLfloat (*)[MAX_WIDTH]) s, - (const GLfloat (*)[MAX_WIDTH]) t, - (const GLfloat (*)[MAX_WIDTH]) u, - lambda, - rgba + left, NULL, GL_POLYGON); + (const GLfloat (*)[MAX_WIDTH]) s, + (const GLfloat (*)[MAX_WIDTH]) t, + (const GLfloat (*)[MAX_WIDTH]) u, + lambda, + rgba + left, NULL, coverageSpan + left, + GL_POLYGON); # endif #elif defined(DO_TEX) # ifdef DO_SPEC _mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left, - s + left, t + left, u + left, - lambda + left, rgba + left, - (const GLchan (*)[4]) (spec + left), - GL_POLYGON); + s + left, t + left, u + left, + lambda + left, rgba + left, + (const GLchan (*)[4]) (spec + left), + coverageSpan + left, + GL_POLYGON); # else _mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left, - s + left, t + left, - u + left, lambda + left, - rgba + left, NULL, GL_POLYGON); + s + left, t + left, + u + left, lambda + left, + rgba + left, NULL, + coverageSpan + left, GL_POLYGON); # endif #elif defined(DO_RGBA) _mesa_write_rgba_span(ctx, n, left, iy, z + left, fog + left, - rgba + left, GL_POLYGON); + rgba + left, coverageSpan + left, GL_POLYGON); #elif defined(DO_INDEX) _mesa_write_index_span(ctx, n, left, iy, z + left, fog + left, - index + left, GL_POLYGON); + index + left, icoverageSpan + left, GL_POLYGON); #endif } } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index f85af995d32..36e9974d387 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -1,4 +1,4 @@ -/* $Id: s_copypix.c,v 1.16 2001/03/19 02:25:36 keithw Exp $ */ +/* $Id: s_copypix.c,v 1.17 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -286,7 +286,8 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, (const GLchan (*)[4])rgba, desty); } else { - _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, GL_BITMAP ); + _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, + NULL, GL_BITMAP ); } } @@ -531,7 +532,8 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, (const GLchan (*)[4])rgba, desty); } else { - _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, GL_BITMAP ); + _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, + NULL, GL_BITMAP ); } } @@ -641,10 +643,12 @@ static void copy_ci_pixels( GLcontext *ctx, } if (zoom) { - _mesa_write_zoomed_index_span( ctx, width, destx, dy, zspan, 0, indexes, desty ); + _mesa_write_zoomed_index_span(ctx, width, destx, dy, zspan, 0, + indexes, desty ); } else { - _mesa_write_index_span(ctx, width, destx, dy, zspan, 0, indexes, GL_BITMAP); + _mesa_write_index_span(ctx, width, destx, dy, zspan, 0, indexes, + NULL, GL_BITMAP); } } @@ -751,17 +755,17 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } else { _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, - rgba, GL_BITMAP); + rgba, NULL, GL_BITMAP); } } else { if (zoom) { _mesa_write_zoomed_index_span( ctx, width, destx, dy, - zspan, 0, indexes, desty ); + zspan, 0, indexes, desty ); } else { _mesa_write_index_span( ctx, width, destx, dy, - zspan, 0, indexes, GL_BITMAP ); + zspan, 0, indexes, NULL, GL_BITMAP ); } } } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index ea4fef7d53a..e914eb70136 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -1,4 +1,4 @@ -/* $Id: s_drawpix.c,v 1.17 2001/04/20 19:21:41 brianp Exp $ */ +/* $Id: s_drawpix.c,v 1.18 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -513,10 +513,12 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, type, source, &ctx->Unpack, ctx->_ImageTransferState); if (zoom) { - _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, desty); + _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, 0, + indexes, desty); } else { - _mesa_write_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, GL_BITMAP); + _mesa_write_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, + NULL, GL_BITMAP); } } } @@ -638,7 +640,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, GLint i; for (i = 0; i < width; i++) zspan[i] = zptr[i]; - _mesa_write_rgba_span( ctx, width, x, y, zspan, 0, rgba, GL_BITMAP ); + _mesa_write_rgba_span(ctx, width, x, y, zspan, 0, rgba, + NULL, GL_BITMAP); } } else if (type==GL_UNSIGNED_INT && ctx->Visual.depthBits == 32 @@ -649,7 +652,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, const GLuint *zptr = (const GLuint *) _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); - _mesa_write_rgba_span( ctx, width, x, y, zptr, 0, rgba, GL_BITMAP ); + _mesa_write_rgba_span(ctx, width, x, y, zptr, 0, rgba, + NULL, GL_BITMAP); } } else { @@ -674,20 +678,21 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, if (ctx->Visual.rgbMode) { if (zoom) { _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0, - (const GLchan (*)[4]) rgba, desty); + (const GLchan (*)[4]) rgba, desty); } else { - _mesa_write_rgba_span(ctx, width, x, y, zspan, 0, rgba, GL_BITMAP); + _mesa_write_rgba_span(ctx, width, x, y, zspan, 0, + rgba, NULL, GL_BITMAP); } } else { if (zoom) { _mesa_write_zoomed_index_span(ctx, width, x, y, zspan, 0, - ispan, GL_BITMAP); + ispan, GL_BITMAP); } else { _mesa_write_index_span(ctx, width, x, y, zspan, 0, - ispan, GL_BITMAP); + ispan, NULL, GL_BITMAP); } } @@ -832,16 +837,16 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, } if (quickDraw) { - (*swrast->Driver.WriteRGBASpan)( ctx, width, x, y, - (CONST GLchan (*)[4]) rgba, NULL); + (*swrast->Driver.WriteRGBASpan)(ctx, width, x, y, + (CONST GLchan (*)[4]) rgba, NULL); } else if (zoom) { - _mesa_write_zoomed_rgba_span( ctx, width, x, y, zspan, 0, - (CONST GLchan (*)[4]) rgba, desty ); + _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0, + (CONST GLchan (*)[4]) rgba, desty); } else { - _mesa_write_rgba_span( ctx, (GLuint) width, x, y, zspan, 0, - rgba, GL_BITMAP); + _mesa_write_rgba_span(ctx, (GLuint) width, x, y, zspan, 0, + rgba, NULL, GL_BITMAP); } } } diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index 7fe3351e665..9711238937f 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -1,4 +1,4 @@ -/* $Id: s_pointtemp.h,v 1.6 2001/05/09 17:31:46 brianp Exp $ */ +/* $Id: s_pointtemp.h,v 1.7 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -184,7 +184,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) const GLfloat rmax = radius + 0.7071F; const GLfloat rmin2 = MAX2(0.0, rmin * rmin); const GLfloat rmax2 = rmax * rmax; - const GLfloat cscale = 256.0F / (rmax2 - rmin2); + const GLfloat cscale = 1.0F / (rmax2 - rmin2); const GLint xmin = (GLint) (vert->win[0] - radius); const GLint xmax = (GLint) (vert->win[0] + radius); const GLint ymin = (GLint) (vert->win[1] - radius); @@ -225,15 +225,14 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) alpha = vert->color[3]; #endif if (dist2 >= rmin2) { - GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); -#if FLAGS & RGBA - /* coverage is in [0,256] */ - alpha = (alpha * coverage) >> 8; -#else - /* 4 fractional index bits */ - index = (index & ~0xf) | (coverage >> 4); /* XXX verify */ -#endif + /* compute partial coverage */ + PB_COVERAGE(PB, 1.0F - (dist2 - rmin2) * cscale); } + else { + /* full coverage */ + PB_COVERAGE(PB, 1.0F); + } + #endif /* SMOOTH */ #if ((FLAGS & (ATTENUATE | RGBA)) == (ATTENUATE | RGBA)) @@ -273,6 +272,11 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) #endif } } + +#if FLAGS & SMOOTH + PB->haveCoverage = GL_TRUE; +#endif + PB_CHECK_FLUSH(ctx,PB); } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index c0c47f82b18..e161ff473fd 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,4 +1,4 @@ -/* $Id: s_span.c,v 1.13 2001/05/03 22:13:32 brianp Exp $ */ +/* $Id: s_span.c,v 1.14 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -51,12 +51,12 @@ - /* * Apply the current polygon stipple pattern to a span of pixels. */ -static void stipple_polygon_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLubyte mask[] ) +static void +stipple_polygon_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte mask[] ) { const GLuint highbit = 0x80000000; GLuint i, m, stipple; @@ -83,8 +83,8 @@ static void stipple_polygon_span( GLcontext *ctx, * as a special case: * 0 = all pixels clipped */ -static GLuint clip_span( GLcontext *ctx, - GLint n, GLint x, GLint y, GLubyte mask[] ) +static GLuint +clip_span( GLcontext *ctx, GLint n, GLint x, GLint y, GLubyte mask[] ) { /* Clip to top and bottom */ if (y < 0 || y >= ctx->DrawBuffer->Height) { @@ -123,9 +123,9 @@ static GLuint clip_span( GLcontext *ctx, /* * Draw to more than one color buffer (or none). */ -static void multi_write_index_span( GLcontext *ctx, GLuint n, - GLint x, GLint y, const GLuint indexes[], - const GLubyte mask[] ) +static void +multi_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLuint indexes[], const GLubyte mask[] ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint bufferBit; @@ -178,10 +178,11 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n, * index - array of [n] color indexes * primitive - either GL_POINT, GL_LINE, GL_POLYGON, or GL_BITMAP */ -void _mesa_write_index_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfloat fog[], - GLuint indexIn[], GLenum primitive ) +void +_mesa_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + GLuint indexIn[], const GLint coverage[], + GLenum primitive ) { const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT; GLubyte mask[MAX_WIDTH]; @@ -244,6 +245,15 @@ void _mesa_write_index_span( GLcontext *ctx, _mesa_depth_fog_ci_pixels( ctx, n, z, index ); } + /* Antialias coverage application */ + if (coverage) { + GLuint i; + for (i = 0; i < n; i++) { + ASSERT(coverage[i] < 16); + index[i] = (index[i] & ~0xf) | coverage[i]; + } + } + if (swrast->_RasterMask & MULTI_DRAW_BIT) { /* draw to zero or two or more buffers */ multi_write_index_span( ctx, n, x, y, index, mask ); @@ -269,11 +279,11 @@ void _mesa_write_index_span( GLcontext *ctx, -void _mesa_write_monoindex_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - const GLfloat fog[], - GLuint index, GLenum primitive ) +void +_mesa_write_monoindex_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + GLuint index, const GLint coverage[], + GLenum primitive ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLubyte mask[MAX_WIDTH]; @@ -322,7 +332,8 @@ void _mesa_write_monoindex_span( GLcontext *ctx, if (ctx->Fog.Enabled || ctx->Color.IndexLogicOpEnabled - || ctx->Color.IndexMask != 0xffffffff) { + || ctx->Color.IndexMask != 0xffffffff + || coverage) { /* different index per pixel */ GLuint indexes[MAX_WIDTH]; for (i = 0; i < n; i++) { @@ -336,6 +347,15 @@ void _mesa_write_monoindex_span( GLcontext *ctx, _mesa_depth_fog_ci_pixels( ctx, n, z, indexes ); } + /* Antialias coverage application */ + if (coverage) { + GLuint i; + for (i = 0; i < n; i++) { + ASSERT(coverage[i] < 16); + indexes[i] = (indexes[i] & ~0xf) | coverage[i]; + } + } + if (swrast->_RasterMask & MULTI_DRAW_BIT) { /* draw to zero or two or more buffers */ multi_write_index_span( ctx, n, x, y, indexes, mask ); @@ -377,9 +397,9 @@ void _mesa_write_monoindex_span( GLcontext *ctx, /* * Draw to more than one RGBA color buffer (or none). */ -static void multi_write_rgba_span( GLcontext *ctx, GLuint n, - GLint x, GLint y, CONST GLchan rgba[][4], - const GLubyte mask[] ) +static void +multi_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + CONST GLchan rgba[][4], const GLubyte mask[] ) { const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask); GLuint bufferBit; @@ -442,11 +462,11 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n, -void _mesa_write_rgba_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfloat *fog, - GLchan rgbaIn[][4], - GLenum primitive ) +void +_mesa_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + GLchan rgbaIn[][4], const GLfloat coverage[], + GLenum primitive ) { const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT | TEXTURE_BIT; @@ -530,6 +550,14 @@ void _mesa_write_rgba_span( GLcontext *ctx, _mesa_depth_fog_rgba_pixels( ctx, n, z, rgba ); } + /* Antialias coverage application */ + if (coverage) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * coverage[i]); + } + } + if (swrast->_RasterMask & MULTI_DRAW_BIT) { multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask ); } @@ -578,11 +606,11 @@ void _mesa_write_rgba_span( GLcontext *ctx, * r, g, b, a - the color of the pixels * primitive - either GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP. */ -void _mesa_write_monocolor_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfloat fog[], - const GLchan color[4], - GLenum primitive ) +void +_mesa_write_monocolor_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + const GLchan color[4], const GLfloat coverage[], + GLenum primitive ) { const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask); GLuint i; @@ -656,7 +684,7 @@ void _mesa_write_monocolor_span( GLcontext *ctx, } if (ctx->Color.ColorLogicOpEnabled || colorMask != 0xffffffff || - (swrast->_RasterMask & (BLEND_BIT | FOG_BIT))) { + (swrast->_RasterMask & (BLEND_BIT | FOG_BIT)) || coverage) { /* assign same color to each pixel */ for (i = 0; i < n; i++) { if (mask[i]) { @@ -672,6 +700,14 @@ void _mesa_write_monocolor_span( GLcontext *ctx, _mesa_depth_fog_rgba_pixels( ctx, n, z, rgba ); } + /* Antialias coverage application */ + if (coverage) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * coverage[i]); + } + } + if (swrast->_RasterMask & MULTI_DRAW_BIT) { multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask ); @@ -734,7 +770,8 @@ void _mesa_write_monocolor_span( GLcontext *ctx, * Add specular color to base color. This is used only when * GL_LIGHT_MODEL_COLOR_CONTROL = GL_SEPARATE_SPECULAR_COLOR. */ -static void add_colors(GLuint n, GLchan rgba[][4], CONST GLchan specular[][4] ) +static void +add_colors(GLuint n, GLchan rgba[][4], CONST GLchan specular[][4] ) { GLuint i; for (i = 0; i < n; i++) { @@ -761,13 +798,13 @@ static void add_colors(GLuint n, GLchan rgba[][4], CONST GLchan specular[][4] ) * rgba - array of [n] color components * primitive - either GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP. */ -void _mesa_write_texture_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfloat fog[], - const GLfloat s[], const GLfloat t[], - const GLfloat u[], GLfloat lambda[], - GLchan rgbaIn[][4], CONST GLchan spec[][4], - GLenum primitive ) +void +_mesa_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + const GLfloat s[], const GLfloat t[], + const GLfloat u[], GLfloat lambda[], + GLchan rgbaIn[][4], CONST GLchan spec[][4], + const GLfloat coverage[], GLenum primitive ) { const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask); GLubyte mask[MAX_WIDTH]; @@ -859,8 +896,9 @@ void _mesa_write_texture_span( GLcontext *ctx, /* Add base and specular colors */ if (spec && (ctx->Fog.ColorSumEnabled || - (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR))) - add_colors( n, rgba, spec ); /* rgba = rgba + spec */ + (ctx->Light.Enabled && + ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR))) + add_colors( n, rgba, spec ); /* rgba = rgba + spec */ /* Per-pixel fog */ if (ctx->Fog.Enabled) { @@ -870,6 +908,14 @@ void _mesa_write_texture_span( GLcontext *ctx, _mesa_depth_fog_rgba_pixels( ctx, n, z, rgba ); } + /* Antialias coverage application */ + if (coverage) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * coverage[i]); + } + } + if (swrast->_RasterMask & MULTI_DRAW_BIT) { multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask ); } @@ -903,17 +949,16 @@ void _mesa_write_texture_span( GLcontext *ctx, * As above but perform multiple stages of texture application. */ void -_mesa_write_multitexture_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - const GLfloat fog[], - CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH], - CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH], - CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH], - GLfloat lambda[][MAX_WIDTH], - GLchan rgbaIn[MAX_TEXTURE_UNITS][4], - CONST GLchan spec[MAX_TEXTURE_UNITS][4], - GLenum primitive ) +_mesa_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH], + CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH], + CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH], + GLfloat lambda[][MAX_WIDTH], + GLchan rgbaIn[MAX_TEXTURE_UNITS][4], + CONST GLchan spec[MAX_TEXTURE_UNITS][4], + const GLfloat coverage[], + GLenum primitive ) { GLubyte mask[MAX_WIDTH]; GLboolean write_all = GL_TRUE; @@ -1022,6 +1067,14 @@ _mesa_write_multitexture_span( GLcontext *ctx, _mesa_depth_fog_rgba_pixels( ctx, n, z, rgba ); } + /* Antialias coverage application */ + if (coverage) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * coverage[i]); + } + } + if (swrast->_RasterMask & MULTI_DRAW_BIT) { multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask ); } @@ -1058,9 +1111,9 @@ _mesa_write_multitexture_span( GLcontext *ctx, * Read RGBA pixels from frame buffer. Clipping will be done to prevent * reading ouside the buffer's boundaries. */ -void _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, - GLuint n, GLint x, GLint y, - GLchan rgba[][4] ) +void +_mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, + GLuint n, GLint x, GLint y, GLchan rgba[][4] ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); if (y < 0 || y >= buffer->Height @@ -1112,8 +1165,9 @@ void _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, * Read CI pixels from frame buffer. Clipping will be done to prevent * reading ouside the buffer's boundaries. */ -void _mesa_read_index_span( GLcontext *ctx, GLframebuffer *buffer, - GLuint n, GLint x, GLint y, GLuint indx[] ) +void +_mesa_read_index_span( GLcontext *ctx, GLframebuffer *buffer, + GLuint n, GLint x, GLint y, GLuint indx[] ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); if (y < 0 || y >= buffer->Height diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index b1bb847bf67..5c5e49c12d0 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -1,4 +1,4 @@ -/* $Id: s_span.h,v 1.5 2001/05/03 22:13:32 brianp Exp $ */ +/* $Id: s_span.h,v 1.6 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,9 +25,6 @@ */ - - - #ifndef S_SPAN_H #define S_SPAN_H @@ -36,64 +33,62 @@ #include "swrast.h" -extern void _mesa_write_index_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfloat fog[], - GLuint index[], GLenum primitive ); +extern void +_mesa_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + GLuint index[], const GLint coverage[], + GLenum primitive ); -extern void _mesa_write_monoindex_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - const GLfloat fog[], - GLuint index, GLenum primitive ); +extern void +_mesa_write_monoindex_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + GLuint index, const GLint coverage[], + GLenum primitive ); -extern void _mesa_write_rgba_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfloat fog[], - GLchan rgba[][4], GLenum primitive ); +extern void +_mesa_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + GLchan rgba[][4], const GLfloat coverage[], + GLenum primitive ); -extern void _mesa_write_monocolor_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - const GLfloat fog[], - const GLchan color[4], - GLenum primitive ); +extern void +_mesa_write_monocolor_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + const GLchan color[4], const GLfloat coverage[], + GLenum primitive ); -extern void _mesa_write_texture_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - const GLfloat fog[], - const GLfloat s[], const GLfloat t[], - const GLfloat u[], GLfloat lambda[], - GLchan rgba[][4], CONST GLchan spec[][4], - GLenum primitive ); +extern void +_mesa_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + const GLfloat s[], const GLfloat t[], + const GLfloat u[], GLfloat lambda[], + GLchan rgba[][4], CONST GLchan spec[][4], + const GLfloat coverage[], GLenum primitive ); extern void -_mesa_write_multitexture_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - const GLfloat fog[], - CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH], - CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH], - CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH], - GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH], - GLchan rgba[][4], - CONST GLchan spec[][4], - GLenum primitive ); +_mesa_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], const GLfloat fog[], + CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH], + CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH], + CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH], + GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH], + GLchan rgba[][4], CONST GLchan spec[][4], + const GLfloat coverage[], GLenum primitive ); -extern void _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, - GLuint n, GLint x, GLint y, - GLchan rgba[][4] ); +extern void +_mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, + GLuint n, GLint x, GLint y, GLchan rgba[][4] ); -extern void _mesa_read_index_span( GLcontext *ctx, GLframebuffer *buffer, - GLuint n, GLint x, GLint y, GLuint indx[] ); +extern void +_mesa_read_index_span( GLcontext *ctx, GLframebuffer *buffer, + GLuint n, GLint x, GLint y, GLuint indx[] ); #endif diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 29805a537a6..b3c58101237 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1,4 +1,4 @@ -/* $Id: s_triangle.c,v 1.26 2001/05/14 16:23:04 brianp Exp $ */ +/* $Id: s_triangle.c,v 1.27 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -92,7 +92,7 @@ static void flat_ci_triangle( GLcontext *ctx, span.fog += span.fogStep; \ } \ _mesa_write_monoindex_span(ctx, span.count, span.x, span.y, \ - zSpan, fogSpan, v0->index, GL_POLYGON ); + zSpan, fogSpan, v0->index, NULL, GL_POLYGON ); #include "s_tritemp.h" } @@ -125,7 +125,7 @@ static void smooth_ci_triangle( GLcontext *ctx, span.fog += span.fogStep; \ } \ _mesa_write_index_span(ctx, span.count, span.x, span.y, \ - zSpan, fogSpan, indexSpan, GL_POLYGON); + zSpan, fogSpan, indexSpan, NULL, GL_POLYGON); #include "s_tritemp.h" } @@ -154,8 +154,8 @@ static void flat_rgba_triangle( GLcontext *ctx, fogSpan[i] = span.fog; \ span.fog += span.fogStep; \ } \ - _mesa_write_monocolor_span(ctx, span.count, span.x, span.y, \ - zSpan, fogSpan, v2->color, GL_POLYGON ); + _mesa_write_monocolor_span(ctx, span.count, span.x, span.y, zSpan, \ + fogSpan, v2->color, NULL, GL_POLYGON ); #include "s_tritemp.h" @@ -201,7 +201,7 @@ static void smooth_rgba_triangle( GLcontext *ctx, } \ _mesa_write_rgba_span(ctx, span.count, span.x, span.y, \ (CONST GLdepth *) zSpan, \ - fogSpan, rgbaSpan, GL_POLYGON); + fogSpan, rgbaSpan, NULL, GL_POLYGON); #include "s_tritemp.h" @@ -592,7 +592,7 @@ affine_span(GLcontext *ctx, struct triangle_span *span, break; } _mesa_write_rgba_span(ctx, span->count, span->x, span->y, - zspan, fogspan, rgba, GL_POLYGON); + zspan, fogspan, rgba, NULL, GL_POLYGON); #undef SPAN1 #undef SPAN2 @@ -1400,8 +1400,8 @@ static void near_persp_textured_triangle(GLcontext *ctx, } \ } \ _mesa_write_rgba_span( ctx, n, LEFT, Y, zspan, \ - fogspan, rgba, GL_POLYGON); \ - span.red = span.green = span.blue = span.alpha = 0; \ + fogspan, rgba, NULL, GL_POLYGON); \ + span.red = span.green = span.blue = span.alpha = 0; \ } \ } \ @@ -1586,9 +1586,9 @@ static void lin_persp_textured_triangle( GLcontext *ctx, abort(); \ } \ } \ - _mesa_write_rgba_span( ctx, n, LEFT, Y, zspan, \ - fogspan, \ - rgba, GL_POLYGON ); \ + _mesa_write_rgba_span(ctx, n, LEFT, Y, zspan, \ + fogspan, rgba, NULL, \ + GL_POLYGON); \ } \ } @@ -1807,7 +1807,7 @@ rasterize_span(GLcontext *ctx, const struct triangle_span *span) (const GLfloat (*)[MAX_WIDTH]) mrTex, (GLfloat (*)[MAX_WIDTH]) mLambda, rgba, (CONST GLchan (*)[4]) spec, - GL_POLYGON ); + NULL, GL_POLYGON ); } else { _mesa_write_multitexture_span(ctx, span->count, span->x, span->y, @@ -1816,7 +1816,7 @@ rasterize_span(GLcontext *ctx, const struct triangle_span *span) (const GLfloat (*)[MAX_WIDTH]) mtTex, (const GLfloat (*)[MAX_WIDTH]) mrTex, (GLfloat (*)[MAX_WIDTH]) mLambda, - rgba, NULL, GL_POLYGON); + rgba, NULL, NULL, GL_POLYGON); } } else { @@ -1825,12 +1825,12 @@ rasterize_span(GLcontext *ctx, const struct triangle_span *span) _mesa_write_texture_span(ctx, span->count, span->x, span->y, z, fogPtr, sTex, tTex, rTex, lambda, rgba, (CONST GLchan (*)[4]) spec, - GL_POLYGON); + NULL, GL_POLYGON); } else { _mesa_write_texture_span(ctx, span->count, span->x, span->y, z, fogPtr, sTex, tTex, rTex, lambda, - rgba, NULL, GL_POLYGON); + rgba, NULL, NULL, GL_POLYGON); } } } @@ -1910,7 +1910,7 @@ static void general_textured_triangle( GLcontext *ctx, } \ _mesa_write_texture_span(ctx, span.count, span.x, span.y, \ zSpan, fogSpan, sSpan, tSpan, uSpan, \ - NULL, rgbaSpan, NULL, GL_POLYGON ); + NULL, rgbaSpan, NULL, NULL, GL_POLYGON ); #include "s_tritemp.h" } diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 74053d0a5b2..ff3d3f5e0c1 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -1,4 +1,4 @@ -/* $Id: s_zoom.c,v 1.5 2001/05/03 22:13:32 brianp Exp $ */ +/* $Id: s_zoom.c,v 1.6 2001/05/15 21:30:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -143,8 +143,7 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx, /* write the span */ for (r=r0; r<r1; r++) { _mesa_write_rgba_span( ctx, m, x+skipcol, r, zdepth, - (fog ? zfog : 0), - zrgba, GL_BITMAP ); + (fog ? zfog : 0), zrgba, NULL, GL_BITMAP ); } } @@ -254,7 +253,7 @@ _mesa_write_zoomed_rgb_span( GLcontext *ctx, /* write the span */ for (r=r0; r<r1; r++) { _mesa_write_rgba_span( ctx, m, x+skipcol, r, zdepth, - (fog ? zfog : 0), zrgba, GL_BITMAP ); + (fog ? zfog : 0), zrgba, NULL, GL_BITMAP ); } } @@ -361,7 +360,7 @@ _mesa_write_zoomed_index_span( GLcontext *ctx, /* write the span */ for (r=r0; r<r1; r++) { _mesa_write_index_span( ctx, m, x+skipcol, r, zdepth, - (fog ? zfog : 0), zindexes, GL_BITMAP ); + (fog ? zfog : 0), zindexes, NULL, GL_BITMAP ); } } |