More span improvements. Removed _mesa_write_monocolor_span().

Removed last of span.filled* flags and Klaus's macros.
More simplification of triangle functions.
This commit is contained in:
Brian Paul
2002-01-28 03:42:28 +00:00
parent f1e2369878
commit 7956292a76
9 changed files with 160 additions and 356 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: s_aatritemp.h,v 1.25 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: s_aatritemp.h,v 1.26 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -270,7 +270,6 @@
GLint ix, startX = (GLint) (x - xAdj); GLint ix, startX = (GLint) (x - xAdj);
GLuint count; GLuint count;
GLfloat coverage = 0.0F; GLfloat coverage = 0.0F;
SW_SPAN_RESET(span);
/* skip over fragments with zero coverage */ /* skip over fragments with zero coverage */
while (startX < MAX_WIDTH) { while (startX < MAX_WIDTH) {

View File

@@ -1,4 +1,4 @@
/* $Id: s_copypix.c,v 1.29 2002/01/27 18:32:03 brianp Exp $ */ /* $Id: s_copypix.c,v 1.30 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -333,23 +333,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax);
GLfloat fog;
if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
else
fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
for (i=0;i<width;i++) {
span.zArray[i] = z;
span.fogArray[i] = fog;
}
span.arrayMask |= (SPAN_Z | SPAN_FOG);
}
if (ctx->Depth.Test) if (ctx->Depth.Test)
_mesa_span_default_z(ctx, &span); _mesa_span_default_z(ctx, &span);
if (ctx->Fog.Enabled) if (ctx->Fog.Enabled)

View File

@@ -1,4 +1,4 @@
/* $Id: s_fog.c,v 1.19 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: s_fog.c,v 1.20 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -87,7 +87,7 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
ASSERT(ctx->Fog.Enabled); ASSERT(ctx->Fog.Enabled);
ASSERT(span->interpMask & SPAN_FOG); ASSERT(span->interpMask & SPAN_FOG);
ASSERT(span->filledColor == GL_TRUE || (span->arrayMask & SPAN_RGBA)); ASSERT(span->arrayMask & SPAN_RGBA);
UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]); UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]); UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
@@ -120,7 +120,7 @@ _mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
ASSERT(fog != NULL); ASSERT(fog != NULL);
ASSERT(ctx->Fog.Enabled); ASSERT(ctx->Fog.Enabled);
ASSERT(span->filledColor == GL_TRUE || (span->arrayMask & SPAN_RGBA)); ASSERT(span->arrayMask & SPAN_RGBA);
UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]); UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]); UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
@@ -209,7 +209,7 @@ _mesa_fog_ci_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
ASSERT(fog != NULL); ASSERT(fog != NULL);
ASSERT(ctx->Fog.Enabled); ASSERT(ctx->Fog.Enabled);
ASSERT((span->filledColor == GL_TRUE) || (span->arrayMask & SPAN_INDEX)); ASSERT(span->arrayMask & SPAN_INDEX);
for (i = span->start; i < span->end; i++) { for (i = span->start; i < span->end; i++) {
const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F); const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F);

View File

@@ -1,4 +1,4 @@
/* $Id: s_span.c,v 1.25 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: s_span.c,v 1.26 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -491,10 +491,7 @@ multi_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
if (ctx->Color.IndexLogicOpEnabled) { if (ctx->Color.IndexLogicOpEnabled) {
_mesa_logicop_ci_span( ctx, n, x, y, indexTmp, mask ); _mesa_logicop_ci_span( ctx, n, x, y, indexTmp, mask );
} }
if (ctx->Color.IndexMask == 0) { if (ctx->Color.IndexMask != 0xffffffff) {
break;
}
else if (ctx->Color.IndexMask != 0xffffffff) {
_mesa_mask_index_span( ctx, n, x, y, indexTmp ); _mesa_mask_index_span( ctx, n, x, y, indexTmp );
} }
(*swrast->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask ); (*swrast->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask );
@@ -577,40 +574,31 @@ multi_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
/* /*
* Write a horizontal span of color index pixels to the frame buffer. * This function may modify any of the array values in the span.
* Stenciling, Depth-testing, etc. are done as needed. * span->interpMask and span->arrayMask may be changed but will be restored
* Input: primitive - either GL_POINT, GL_LINE, GL_POLYGON, or GL_BITMAP * to their original values before returning.
*/ */
void void
_mesa_write_index_span( GLcontext *ctx, struct sw_span *span, _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive) GLenum primitive)
{ {
const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT;
GLuint indexBackup[MAX_WIDTH];
GLuint *index; /* points to span->color.index or indexBackup */
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint origInterpMask = span->interpMask;
const GLuint origArrayMask = span->arrayMask; const GLuint origArrayMask = span->arrayMask;
MEMSET(span->mask, 1, span->end); ASSERT((span->interpMask & span->arrayMask) == 0);
MEMSET(span->mask, 1, span->end);
span->writeAll = GL_TRUE;
/* Window clipping */
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx,span) == GL_FALSE) { if (clip_span(ctx,span) == GL_FALSE) {
return; return;
} }
} }
if ((primitive==GL_BITMAP && (swrast->_RasterMask & modBits)) /* Scissor test */
|| (swrast->_RasterMask & MULTI_DRAW_BIT)) {
/* Make copy of color indexes */
MEMCPY( indexBackup, span->color.index, span->end * sizeof(GLuint) );
index = indexBackup;
}
else {
index = span->color.index;
}
/* Do the scissor test */
if (ctx->Scissor.Enabled) { if (ctx->Scissor.Enabled) {
if (_mesa_scissor_span( ctx, span ) == GL_FALSE) { if (_mesa_scissor_span( ctx, span ) == GL_FALSE) {
return; return;
@@ -622,51 +610,58 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
stipple_polygon_span(ctx, span); stipple_polygon_span(ctx, span);
} }
/* Depth test and stencil */
if (ctx->Depth.Test || ctx->Stencil.Enabled) {
if (span->interpMask & SPAN_Z)
interpolate_z(ctx, span);
/* I have to think where to put this!! */ if (ctx->Stencil.Enabled) {
if (span->interpMask & SPAN_Z) if (_mesa_stencil_and_ztest_span(ctx, span) == GL_FALSE) {
interpolate_z(ctx, span); span->arrayMask = origArrayMask;
return;
}
if (ctx->Stencil.Enabled) {
/* first stencil test */
if (_mesa_stencil_and_ztest_span(ctx, span) == GL_FALSE) {
span->arrayMask = origArrayMask;
return;
} }
} else {
else if (ctx->Depth.Test) { ASSERT(ctx->Depth.Test);
/* regular depth testing */ if (_mesa_depth_test_span(ctx, span) == 0) {
if (_mesa_depth_test_span(ctx, span) == 0) { span->arrayMask = origArrayMask;
span->arrayMask = origArrayMask; return;
return; }
} }
} }
/* if we get here, something passed the depth test */ /* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE; ctx->OcclusionResult = GL_TRUE;
if (ctx->Color.DrawBuffer == GL_NONE) { /* we have to wait until after occlusion to do this test */
if (ctx->Color.DrawBuffer == GL_NONE || ctx->Color.IndexMask == 0) {
/* write no pixels */ /* write no pixels */
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
} }
if (span->interpMask & SPAN_INDEX) /* Interpolate the color indexes if needed */
if (span->interpMask & SPAN_INDEX) {
interpolate_indexes(ctx, span); interpolate_indexes(ctx, span);
/* clear the bit - this allows the WriteMonoCISpan optimization below */
span->interpMask &= ~SPAN_INDEX;
}
/* Fog */
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
if ((span->arrayMask & SPAN_FOG) && !swrast->_PreferPixelFog) if ((span->arrayMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels_with_array( ctx, span, span->fogArray, index); _mesa_fog_ci_pixels_with_array( ctx, span, span->fogArray,
span->color.index);
else if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog) else if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, span, index); _mesa_fog_ci_pixels( ctx, span, span->color.index);
else else
_mesa_depth_fog_ci_pixels( ctx, span, index); _mesa_depth_fog_ci_pixels( ctx, span, span->color.index);
} }
/* Antialias coverage application */ /* Antialias coverage application */
if (span->arrayMask & SPAN_COVERAGE) { if (span->arrayMask & SPAN_COVERAGE) {
GLuint i; GLuint i;
GLuint *index = span->color.index;
for (i = 0; i < span->end; i++) { for (i = 0; i < span->end; i++) {
ASSERT(span->coverage[i] < 16); ASSERT(span->coverage[i] < 16);
index[i] = (index[i] & ~0xf) | ((GLuint) (span->coverage[i])); index[i] = (index[i] & ~0xf) | ((GLuint) (span->coverage[i]));
@@ -676,84 +671,94 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
if (swrast->_RasterMask & MULTI_DRAW_BIT) { if (swrast->_RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */ /* draw to zero or two or more buffers */
multi_write_index_span( ctx, span->end, span->x, span->y, multi_write_index_span( ctx, span->end, span->x, span->y,
index, span->mask ); span->color.index, span->mask );
} }
else { else {
/* normal situation: draw to exactly one buffer */ /* normal situation: draw to exactly one buffer */
if (ctx->Color.IndexLogicOpEnabled) { if (ctx->Color.IndexLogicOpEnabled) {
_mesa_logicop_ci_span( ctx, span->end, span->x, span->y, _mesa_logicop_ci_span( ctx, span->end, span->x, span->y,
index, span->mask ); span->color.index, span->mask );
} }
if (ctx->Color.IndexMask == 0) { if (ctx->Color.IndexMask != 0xffffffff) {
return; _mesa_mask_index_span( ctx, span->end, span->x, span->y,
} span->color.index );
else if (ctx->Color.IndexMask != 0xffffffff) {
_mesa_mask_index_span( ctx, span->end, span->x, span->y, index );
} }
/* write pixels */ /* write pixels */
(*swrast->Driver.WriteCI32Span)( ctx, span->end, span->x, if ((span->interpMask & SPAN_INDEX) && span->indexStep == 0) {
span->y, index, span->mask ); /* all pixels have same color index */
(*swrast->Driver.WriteMonoCISpan)( ctx, span->end, span->x, span->y,
FixedToInt(span->index),
span->mask );
}
else {
(*swrast->Driver.WriteCI32Span)( ctx, span->end, span->x, span->y,
span->color.index, span->mask );
}
} }
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
} }
/* /*
* Apply fragment processing to a span of RGBA fragments. * This function may modify any of the array values in the span.
* Input: * span->interpMask and span->arrayMask may be changed but will be restored
* to their original values before returning.
*/ */
void void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span, _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive) GLenum primitive)
{ {
const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT |
LOGIC_OP_BIT | TEXTURE_BIT;
GLchan rgbaBackup[MAX_WIDTH][4];
GLchan (*rgba)[4];
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
const GLuint origInterpMask = span->interpMask;
const GLuint origArrayMask = span->arrayMask; const GLuint origArrayMask = span->arrayMask;
GLboolean monoColor;
ASSERT((span->interpMask & span->arrayMask) == 0);
MEMSET(span->mask, 1, span->end); MEMSET(span->mask, 1, span->end);
span->writeAll = GL_TRUE;
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { /* Determine if we have mono-chromatic colors */
if (clip_span( ctx,span ) == GL_FALSE) { monoColor = (span->interpMask & SPAN_RGBA) &&
span->redStep == 0 && span->greenStep == 0 &&
span->blueStep == 0 && span->alphaStep == 0;
/* Window clipping */
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive == GL_BITMAP) {
if (clip_span(ctx, span) == GL_FALSE) {
return; return;
} }
} }
/* Do the scissor test */ /* Scissor test */
if (ctx->Scissor.Enabled) { if (ctx->Scissor.Enabled) {
if (_mesa_scissor_span( ctx, span ) == GL_FALSE) { if (!_mesa_scissor_span(ctx, span)) {
return; return;
} }
} }
/* Polygon Stippling */ /* Polygon Stippling */
if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) { if (ctx->Polygon.StippleFlag && primitive == GL_POLYGON) {
stipple_polygon_span( ctx, span); stipple_polygon_span(ctx, span);
} }
/* Now we may need to interpolate the colors */
if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0) { if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0) {
interpolate_colors(ctx, span); interpolate_colors(ctx, span);
} /* clear the bit - this allows the WriteMonoCISpan optimization below */
span->interpMask &= ~SPAN_RGBA;
if ((primitive==GL_BITMAP && (swrast->_RasterMask & modBits))
|| (swrast->_RasterMask & MULTI_DRAW_BIT)) {
/* must make a copy of the colors since they may be modified */
MEMCPY( rgbaBackup, span->color.rgba, 4 * span->end * sizeof(GLchan) );
rgba = rgbaBackup;
}
else {
rgba = span->color.rgba;
} }
/* Do the alpha test */ /* Do the alpha test */
if (ctx->Color.AlphaEnabled) { if (ctx->Color.AlphaEnabled) {
if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba) == 0) { if (!_mesa_alpha_test(ctx, span,
(const GLchan (*)[4]) span->color.rgba)) {
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
} }
@@ -766,6 +771,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
if (ctx->Stencil.Enabled) { if (ctx->Stencil.Enabled) {
if (!_mesa_stencil_and_ztest_span(ctx, span)) { if (!_mesa_stencil_and_ztest_span(ctx, span)) {
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
} }
@@ -775,6 +781,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
ASSERT(span->arrayMask & SPAN_Z); ASSERT(span->arrayMask & SPAN_Z);
/* regular depth testing */ /* regular depth testing */
if (!_mesa_depth_test_span(ctx, span)) { if (!_mesa_depth_test_span(ctx, span)) {
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
return; return;
} }
@@ -784,229 +791,92 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* if we get here, something passed the depth test */ /* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE; ctx->OcclusionResult = GL_TRUE;
/* can't abort span-writing until after occlusion testing */
if (colorMask == 0x0) {
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask;
return;
}
/* Per-pixel fog */ /* Per-pixel fog */
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
if ((span->arrayMask & SPAN_FOG) && !swrast->_PreferPixelFog) if ((span->arrayMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels_with_array( ctx, span, span->fogArray, rgba); _mesa_fog_rgba_pixels_with_array(ctx, span, span->fogArray,
else if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog) span->color.rgba);
_mesa_fog_rgba_pixels( ctx, span, rgba ); else if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels(ctx, span, span->color.rgba);
else { else {
if ((span->interpMask & SPAN_Z) && (span->arrayMask & SPAN_Z) == 0) if ((span->interpMask & SPAN_Z) && (span->arrayMask & SPAN_Z) == 0)
interpolate_z(ctx, span); interpolate_z(ctx, span);
_mesa_depth_fog_rgba_pixels( ctx, span, rgba ); _mesa_depth_fog_rgba_pixels(ctx, span, span->color.rgba);
} }
monoColor = GL_FALSE;
} }
/* Antialias coverage application */ /* Antialias coverage application */
if (span->arrayMask & SPAN_COVERAGE) { if (span->arrayMask & SPAN_COVERAGE) {
GLchan (*rgba)[4] = span->color.rgba;
GLuint i; GLuint i;
for (i = 0; i < span->end; i++) { for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]); rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
} }
monoColor = GL_FALSE;
} }
if (swrast->_RasterMask & MULTI_DRAW_BIT) { if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, span->mask ); multi_write_rgba_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) span->color.rgba,
span->mask );
} }
else { else {
/* normal: write to exactly one buffer */ /* normal: write to exactly one buffer */
/* logic op or blending */
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
if (ctx->Color.ColorLogicOpEnabled) { if (ctx->Color.ColorLogicOpEnabled) {
_mesa_logicop_rgba_span( ctx, span->end, span->x, span->y, rgba, span->mask ); _mesa_logicop_rgba_span( ctx, span->end, span->x, span->y,
span->color.rgba, span->mask );
monoColor = GL_FALSE;
} }
else if (ctx->Color.BlendEnabled) { else if (ctx->Color.BlendEnabled) {
_mesa_blend_span( ctx, span->end, span->x, span->y, rgba, span->mask ); _mesa_blend_span( ctx, span->end, span->x, span->y,
span->color.rgba, span->mask );
monoColor = GL_FALSE;
} }
/* Color component masking */ /* Color component masking */
if (colorMask == 0x0) { if (colorMask != 0xffffffff) {
span->arrayMask = origArrayMask; _mesa_mask_rgba_span( ctx, span->end, span->x, span->y,
return; span->color.rgba );
} monoColor = GL_FALSE;
else if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
} }
/* write pixels */ /* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, if (monoColor) {
(const GLchan (*)[4]) rgba, /* all pixels have same color */
span->writeAll ? ((const GLubyte *) NULL) : span->mask ); GLchan color[4];
color[RCOMP] = FixedToChan(span->red);
color[GCOMP] = FixedToChan(span->green);
color[BCOMP] = FixedToChan(span->blue);
color[ACOMP] = FixedToChan(span->alpha);
(*swrast->Driver.WriteMonoRGBASpan)( ctx, span->end, span->x, span->y,
color, span->mask);
}
else {
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) span->color.rgba,
span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y, _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, (const GLchan (*)[4]) span->color.rgba,
span->writeAll ? ((const GLubyte *) NULL) : span->mask ); span->writeAll ? ((const GLubyte *) NULL) : span->mask );
} }
} }
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask; span->arrayMask = origArrayMask;
} }
/*
* Write a horizontal span of color pixels to the frame buffer.
* The color is initially constant for the whole span.
* Alpha-testing, stenciling, depth-testing, and blending are done as needed.
* Input: 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, struct sw_span *span,
const GLchan color[4], GLenum primitive )
{
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
GLuint i;
GLchan rgba[MAX_WIDTH][4];
SWcontext *swrast = SWRAST_CONTEXT(ctx);
MEMSET(span->mask, 1, span->end);
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx,span) == GL_FALSE) {
return;
}
}
/* Do the scissor test */
if (ctx->Scissor.Enabled) {
if (_mesa_scissor_span( ctx, span ) == GL_FALSE) {
return;
}
}
/* Polygon Stippling */
if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
stipple_polygon_span( ctx, span);
}
/* Do the alpha test */
if (ctx->Color.AlphaEnabled) {
if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0)
interpolate_colors(ctx, span);
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = color[ACOMP];
}
if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4])rgba) == 0) {
return;
}
}
if (span->interpMask & SPAN_Z)
interpolate_z(ctx, span);
if (ctx->Stencil.Enabled) {
/* first stencil test */
if (_mesa_stencil_and_ztest_span(ctx, span) == GL_FALSE)
return;
}
else if (ctx->Depth.Test) {
/* regular depth testing */
if (_mesa_depth_test_span(ctx, span) == 0)
return;
}
/* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE;
if (ctx->Color.DrawBuffer == GL_NONE) {
/* write no pixels */
return;
}
if (ctx->Color.ColorLogicOpEnabled ||
colorMask != 0xffffffff ||
(swrast->_RasterMask & (BLEND_BIT | FOG_BIT)) ||
(span->arrayMask & SPAN_COVERAGE)) {
/* assign same color to each pixel */
SW_SPAN_SET_FLAG(span->filledColor);
for (i = 0; i < span->end; i++) {
if (span->mask[i]) {
COPY_CHAN4(rgba[i], color);
}
}
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, span, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, span, rgba );
}
/* Antialias coverage application */
if (span->arrayMask & SPAN_COVERAGE) {
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
}
}
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, span->mask );
}
else {
/* normal: write to exactly one buffer */
if (ctx->Color.ColorLogicOpEnabled) {
_mesa_logicop_rgba_span( ctx, span->end, span->x, span->y,
rgba, span->mask );
}
else if (ctx->Color.BlendEnabled) {
_mesa_blend_span( ctx, span->end, span->x, span->y,
rgba, span->mask );
}
/* Color component masking */
if (colorMask == 0x0) {
return;
}
else if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
}
/* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba,
span->writeAll ? ((const GLubyte *) NULL) : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba,
span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
else {
/* same color for all pixels */
ASSERT(!ctx->Color.BlendEnabled);
ASSERT(!ctx->Color.ColorLogicOpEnabled);
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
SW_SPAN_SET_FLAG(span->filledColor);
for (i = 0; i < span->end; i++) {
if (span->mask[i]) {
COPY_CHAN4(rgba[i], color);
}
}
multi_write_rgba_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, span->mask );
}
else {
(*swrast->Driver.WriteMonoRGBASpan)( ctx, span->end, span->x, span->y,
color, span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_mono_alpha_span( ctx, span->end, span->x, span->y,
(GLchan) color[ACOMP],
span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
}
/* /*
* Add specular color to base color. This is used only when * Add specular color to base color. This is used only when
* GL_LIGHT_MODEL_COLOR_CONTROL = GL_SEPARATE_SPECULAR_COLOR. * GL_LIGHT_MODEL_COLOR_CONTROL = GL_SEPARATE_SPECULAR_COLOR.
@@ -1035,8 +905,8 @@ add_colors(GLuint n, GLchan rgba[][4], GLchan specular[][4] )
/* /*
* This function may modify any of the array values in the span. * This function may modify any of the array values in the span.
* span->arrayMask, however, will not be modified (or we'll * span->interpMask and span->arrayMask may be changed but will be restored
* restore it to the original incoming value before returning. * to their original values before returning.
*/ */
void void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span, _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
@@ -1046,11 +916,14 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint origArrayMask = span->arrayMask; const GLuint origArrayMask = span->arrayMask;
ASSERT((span->interpMask & span->arrayMask) == 0);
/* printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);*/ /* printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);*/
ASSERT(ctx->Texture._ReallyEnabled); ASSERT(ctx->Texture._ReallyEnabled);
MEMSET(span->mask, 1, span->end); MEMSET(span->mask, 1, span->end);
span->writeAll = GL_TRUE;
/* clip against window bounds */ /* clip against window bounds */
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {

View File

@@ -1,4 +1,4 @@
/* $Id: s_span.h,v 1.13 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: s_span.h,v 1.14 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -51,14 +51,11 @@ extern void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span, _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive); GLenum primitive);
extern void
_mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
const GLchan color[4], GLenum primitive );
extern void extern void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span, _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive ); GLenum primitive );
extern void extern void
_mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
GLuint n, GLint x, GLint y, GLchan rgba[][4] ); GLuint n, GLint x, GLint y, GLchan rgba[][4] );

View File

@@ -1,4 +1,4 @@
/* $Id: s_triangle.c,v 1.50 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: s_triangle.c,v 1.51 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -106,12 +106,6 @@ static void smooth_ci_triangle( GLcontext *ctx,
#define INTERP_INDEX 1 #define INTERP_INDEX 1
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \
for (i = 0; i < span.end; i++) { \
span.color.index[i] = FixedToInt(span.index); \
span.index += span.indexStep; \
} \
_mesa_write_index_span(ctx, &span, GL_POLYGON); _mesa_write_index_span(ctx, &span, GL_POLYGON);
#include "s_tritemp.h" #include "s_tritemp.h"
@@ -132,6 +126,8 @@ static void flat_rgba_triangle( GLcontext *ctx,
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \ #define SETUP_CODE \
ASSERT(!ctx->Texture._ReallyEnabled); \
ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
span.interpMask |= SPAN_RGBA; \ span.interpMask |= SPAN_RGBA; \
span.red = ChanToFixed(v2->color[0]); \ span.red = ChanToFixed(v2->color[0]); \
span.green = ChanToFixed(v2->color[1]); \ span.green = ChanToFixed(v2->color[1]); \
@@ -142,13 +138,10 @@ static void flat_rgba_triangle( GLcontext *ctx,
span.blueStep = 0; \ span.blueStep = 0; \
span.alphaStep = 0; span.alphaStep = 0;
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
_mesa_write_monocolor_span(ctx, &span, v2->color, GL_POLYGON ); _mesa_write_rgba_span(ctx, &span, GL_POLYGON );
#include "s_tritemp.h" #include "s_tritemp.h"
ASSERT(!ctx->Texture._ReallyEnabled); /* texturing must be off */
ASSERT(ctx->Light.ShadeModel==GL_FLAT);
} }
@@ -169,21 +162,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
#define INTERP_ALPHA 1 #define INTERP_ALPHA 1
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \
SW_SPAN_SET_FLAG(span.filledAlpha); \
ASSERT(span.interpMask & SPAN_RGBA); \ ASSERT(span.interpMask & SPAN_RGBA); \
span.arrayMask |= SPAN_RGBA; \
for (i = 0; i < span.end; i++) { \
span.color.rgba[i][RCOMP] = FixedToChan(span.red); \
span.color.rgba[i][GCOMP] = FixedToChan(span.green); \
span.color.rgba[i][BCOMP] = FixedToChan(span.blue); \
span.color.rgba[i][ACOMP] = FixedToChan(span.alpha); \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
span.alpha += span.alphaStep; \
} \
_mesa_write_rgba_span(ctx, &span, GL_POLYGON); _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
#include "s_tritemp.h" #include "s_tritemp.h"
@@ -225,7 +204,6 @@ static void simple_textured_triangle( GLcontext *ctx,
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
GLuint i; \ GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \
span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
span.intTex[1] -= FIXED_HALF; \ span.intTex[1] -= FIXED_HALF; \
for (i = 0; i < span.end; i++) { \ for (i = 0; i < span.end; i++) { \
@@ -284,7 +262,6 @@ static void simple_z_textured_triangle( GLcontext *ctx,
GLuint i; \ GLuint i; \
span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
span.intTex[1] -= FIXED_HALF; \ span.intTex[1] -= FIXED_HALF; \
SW_SPAN_SET_FLAG(span.filledColor); \
for (i = 0; i < span.end; i++) { \ for (i = 0; i < span.end; i++) { \
const GLdepth z = FixedToDepth(span.z); \ const GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \ if (z < zRow[i]) { \
@@ -477,9 +454,6 @@ affine_span(GLcontext *ctx, struct sw_span *span,
GLuint i; GLuint i;
GLchan *dest = span->color.rgba[0]; GLchan *dest = span->color.rgba[0];
SW_SPAN_SET_FLAG(span->filledColor);
SW_SPAN_SET_FLAG(span->filledAlpha);
span->intTex[0] -= FIXED_HALF; span->intTex[0] -= FIXED_HALF;
span->intTex[1] -= FIXED_HALF; span->intTex[1] -= FIXED_HALF;
switch (info->filter) { switch (info->filter) {
@@ -747,9 +721,6 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
GLfloat tex_coord[3], tex_step[3]; GLfloat tex_coord[3], tex_step[3];
GLchan *dest = span->color.rgba[0]; GLchan *dest = span->color.rgba[0];
SW_SPAN_SET_FLAG(span->filledColor);
SW_SPAN_SET_FLAG(span->filledAlpha);
tex_coord[0] = span->tex[0][0] * (info->smask + 1), tex_coord[0] = span->tex[0][0] * (info->smask + 1),
tex_step[0] = span->texStep[0][0] * (info->smask + 1); tex_step[0] = span->texStep[0][0] * (info->smask + 1);
tex_coord[1] = span->tex[0][1] * (info->tmask + 1), tex_coord[1] = span->tex[0][1] * (info->tmask + 1),
@@ -850,7 +821,6 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
break; break;
} }
ASSERT(span->interpMask & SPAN_RGBA);
ASSERT(span->arrayMask & SPAN_RGBA); ASSERT(span->arrayMask & SPAN_RGBA);
_mesa_write_rgba_span(ctx, span, GL_POLYGON); _mesa_write_rgba_span(ctx, span, GL_POLYGON);
@@ -890,7 +860,6 @@ static void persp_textured_triangle( GLcontext *ctx,
info.format = obj->Image[b]->Format; \ info.format = obj->Image[b]->Format; \
info.filter = obj->MinFilter; \ info.filter = obj->MinFilter; \
info.envmode = unit->EnvMode; \ info.envmode = unit->EnvMode; \
span.arrayMask |= SPAN_RGBA; \
\ \
if (info.envmode == GL_BLEND) { \ if (info.envmode == GL_BLEND) { \
/* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \
@@ -925,7 +894,10 @@ static void persp_textured_triangle( GLcontext *ctx,
} \ } \
info.tsize = obj->Image[b]->Height * info.tbytesline; info.tsize = obj->Image[b]->Height * info.tbytesline;
#define RENDER_SPAN( span ) fast_persp_span(ctx, &span, &info); #define RENDER_SPAN( span ) \
span.interpMask &= ~SPAN_RGBA; \
span.arrayMask |= SPAN_RGBA; \
fast_persp_span(ctx, &span, &info);
#include "s_tritemp.h" #include "s_tritemp.h"

View File

@@ -1,4 +1,4 @@
/* $Id: s_tritemp.h,v 1.31 2002/01/27 18:32:03 brianp Exp $ */ /* $Id: s_tritemp.h,v 1.32 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -1144,8 +1144,7 @@
/* initialize the span interpolants to the leftmost value */ /* initialize the span interpolants to the leftmost value */
/* ff = fixed-pt fragment */ /* ff = fixed-pt fragment */
const GLint right = FixedToInt(fxRightEdge); const GLint right = FixedToInt(fxRightEdge);
/*INIT_SPAN(span);*/
SW_SPAN_RESET(span);
span.x = FixedToInt(fxLeftEdge); span.x = FixedToInt(fxLeftEdge);
if (right <= span.x) if (right <= span.x)

View File

@@ -1,4 +1,4 @@
/* $Id: s_zoom.c,v 1.10 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: s_zoom.c,v 1.11 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -83,11 +83,11 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
{ {
GLint r0, r1, row; GLint r0, r1, row;
GLint i, j; GLint i, j;
struct sw_span zoomed;
const GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH ); const GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
struct sw_span zoomed;
SW_SPAN_RESET(zoomed);
INIT_SPAN(zoomed); INIT_SPAN(zoomed);
zoomed.arrayMask |= SPAN_RGBA;
/* compute width of output row */ /* compute width of output row */
zoomed.end = (GLint) ABSF( n * ctx->Pixel.ZoomX ); zoomed.end = (GLint) ABSF( n * ctx->Pixel.ZoomX );
@@ -148,8 +148,6 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
/* zoom the span horizontally */ /* zoom the span horizontally */
if (ctx->Pixel.ZoomX==-1.0F) { if (ctx->Pixel.ZoomX==-1.0F) {
SW_SPAN_SET_FLAG(zoomed.filledColor);
SW_SPAN_SET_FLAG(zoomed.filledAlpha);
/* n==m */ /* n==m */
for (j=zoomed.start; j<zoomed.end; j++) { for (j=zoomed.start; j<zoomed.end; j++) {
i = n - j - 1; i = n - j - 1;
@@ -165,8 +163,6 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
} }
else { else {
const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX; const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
SW_SPAN_SET_FLAG(zoomed.filledColor);
SW_SPAN_SET_FLAG(zoomed.filledAlpha);
for (j=zoomed.start; j<zoomed.end; j++) { for (j=zoomed.start; j<zoomed.end; j++) {
i = (GLint) (j * xscale); i = (GLint) (j * xscale);
if (i<0) i = n + i - 1; if (i<0) i = n + i - 1;
@@ -182,7 +178,6 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
} }
} }
zoomed.arrayMask |= SPAN_RGBA;
zoomed.arrayMask |= SPAN_Z; zoomed.arrayMask |= SPAN_Z;
if (fog) if (fog)
zoomed.arrayMask |= SPAN_FOG; zoomed.arrayMask |= SPAN_FOG;
@@ -334,7 +329,6 @@ _mesa_write_zoomed_index_span( GLcontext *ctx,
GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH ); GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
struct sw_span zoomed; struct sw_span zoomed;
SW_SPAN_RESET(zoomed);
INIT_SPAN(zoomed); INIT_SPAN(zoomed);
zoomed.arrayMask |= SPAN_INDEX; zoomed.arrayMask |= SPAN_INDEX;

View File

@@ -1,4 +1,4 @@
/* $Id: swrast.h,v 1.17 2002/01/28 00:07:33 brianp Exp $ */ /* $Id: swrast.h,v 1.18 2002/01/28 03:42:28 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -160,10 +160,6 @@ struct sw_span {
/* This mask indicates if fragment is alive or culled */ /* This mask indicates if fragment is alive or culled */
GLubyte mask[MAX_WIDTH]; GLubyte mask[MAX_WIDTH];
#ifdef DEBUG
GLboolean filledAlpha, filledColor;
#endif
}; };
@@ -175,15 +171,6 @@ do { \
} while (0) } while (0)
#ifdef DEBUG
#define SW_SPAN_SET_FLAG(flag) {ASSERT((flag) == GL_FALSE);(flag) = GL_TRUE;}
#define SW_SPAN_RESET(span) { \
(span).filledAlpha = (span).filledColor = GL_FALSE; \
(span).start = 0; (span).writeAll = GL_TRUE;}
#else
#define SW_SPAN_SET_FLAG(flag) ;
#define SW_SPAN_RESET(span) {(span).start = 0;(span).writeAll = GL_TRUE;}
#endif
struct swrast_device_driver; struct swrast_device_driver;