More span improvements. Removed _mesa_write_monocolor_span().
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 28 Jan 2002 03:42:28 +0000 (03:42 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 28 Jan 2002 03:42:28 +0000 (03:42 +0000)
Removed last of span.filled* flags and Klaus's macros.
More simplification of triangle functions.

src/mesa/swrast/s_aatritemp.h
src/mesa/swrast/s_copypix.c
src/mesa/swrast/s_fog.c
src/mesa/swrast/s_span.c
src/mesa/swrast/s_span.h
src/mesa/swrast/s_triangle.c
src/mesa/swrast/s_tritemp.h
src/mesa/swrast/s_zoom.c
src/mesa/swrast/swrast.h

index e142c6f..90b8fe7 100644 (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
          GLint ix, startX = (GLint) (x - xAdj);
          GLuint count;
          GLfloat coverage = 0.0F;
-         SW_SPAN_RESET(span);
 
          /* skip over fragments with zero coverage */
          while (startX < MAX_WIDTH) {
index d418eb5..718a082 100644 (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
@@ -333,23 +333,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
    overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
                                  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)
       _mesa_span_default_z(ctx, &span);
    if (ctx->Fog.Enabled)
index e123ff5..2c3b787 100644 (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
@@ -87,7 +87,7 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
 
    ASSERT(ctx->Fog.Enabled);
    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(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(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(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(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++) {
       const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F);
index 489a494..87b6aa4 100644 (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
@@ -491,10 +491,7 @@ multi_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
          if (ctx->Color.IndexLogicOpEnabled) {
             _mesa_logicop_ci_span( ctx, n, x, y, indexTmp, mask );
          }
-         if (ctx->Color.IndexMask == 0) {
-            break;
-         }
-         else if (ctx->Color.IndexMask != 0xffffffff) {
+         if (ctx->Color.IndexMask != 0xffffffff) {
             _mesa_mask_index_span( ctx, n, x, y, indexTmp );
          }
          (*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.
- * Stenciling, Depth-testing, etc. are done as needed.
- * Input:  primitive - either GL_POINT, GL_LINE, GL_POLYGON, or GL_BITMAP
+ * This function may modify any of the array values in the span.
+ * span->interpMask and span->arrayMask may be changed but will be restored
+ * to their original values before returning.
  */
 void
 _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
                        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);
+   const GLuint origInterpMask = span->interpMask;
    const GLuint origArrayMask = span->arrayMask;
 
+   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 (clip_span(ctx,span) == GL_FALSE) {
          return;
       }
    }
 
-   if ((primitive==GL_BITMAP && (swrast->_RasterMask & modBits))
-       || (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 */
+   /* Scissor test */
    if (ctx->Scissor.Enabled) {
       if (_mesa_scissor_span( ctx, span ) == GL_FALSE) {
          return;
@@ -622,51 +610,58 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *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 (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) {
-         span->arrayMask = origArrayMask;
-        return;
+      if (ctx->Stencil.Enabled) {
+         if (_mesa_stencil_and_ztest_span(ctx, span) == GL_FALSE) {
+            span->arrayMask = origArrayMask;
+            return;
+         }
       }
-   }
-   else if (ctx->Depth.Test) {
-      /* regular depth testing */
-      if (_mesa_depth_test_span(ctx, span) == 0) {
-         span->arrayMask = origArrayMask;
-         return;
+      else {
+         ASSERT(ctx->Depth.Test);
+         if (_mesa_depth_test_span(ctx, span) == 0) {
+            span->arrayMask = origArrayMask;
+            return;
+         }
       }
    }
 
    /* if we get here, something passed the depth test */
    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 */
       span->arrayMask = origArrayMask;
       return;
    }
 
-   if (span->interpMask & SPAN_INDEX)
+   /* Interpolate the color indexes if needed */
+   if (span->interpMask & SPAN_INDEX) {
       interpolate_indexes(ctx, span);
+      /* clear the bit - this allows the WriteMonoCISpan optimization below */
+      span->interpMask &= ~SPAN_INDEX;
+   }
 
+   /* Fog */
    if (ctx->Fog.Enabled) {
       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)
-         _mesa_fog_ci_pixels( ctx, span, index);
+         _mesa_fog_ci_pixels( ctx, span, span->color.index);
       else
-         _mesa_depth_fog_ci_pixels( ctx, span, index);
+         _mesa_depth_fog_ci_pixels( ctx, span, span->color.index);
    }
 
    /* Antialias coverage application */
    if (span->arrayMask & SPAN_COVERAGE) {
       GLuint i;
+      GLuint *index = span->color.index;
       for (i = 0; i < span->end; i++) {
          ASSERT(span->coverage[i] < 16);
          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) {
       /* draw to zero or two or more buffers */
       multi_write_index_span( ctx, span->end, span->x, span->y,
-                             index, span->mask );
+                             span->color.index, span->mask );
    }
    else {
       /* normal situation: draw to exactly one buffer */
       if (ctx->Color.IndexLogicOpEnabled) {
          _mesa_logicop_ci_span( ctx, span->end, span->x, span->y,
-                               index, span->mask );
+                               span->color.index, span->mask );
       }
 
-      if (ctx->Color.IndexMask == 0) {
-         return;
-      }
-      else if (ctx->Color.IndexMask != 0xffffffff) {
-         _mesa_mask_index_span( ctx, span->end, span->x, span->y, index );
+      if (ctx->Color.IndexMask != 0xffffffff) {
+         _mesa_mask_index_span( ctx, span->end, span->x, span->y,
+                                span->color.index );
       }
 
       /* write pixels */
-      (*swrast->Driver.WriteCI32Span)( ctx, span->end, span->x,
-                                      span->y, index, span->mask );
+      if ((span->interpMask & SPAN_INDEX) && span->indexStep == 0) {
+         /* 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;
 }
 
 
-
 /*
- * Apply fragment processing to a span of RGBA fragments.
- * Input:
+ * This function may modify any of the array values in the span.
+ * span->interpMask and span->arrayMask may be changed but will be restored
+ * to their original values before returning.
  */
 void
 _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
                       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);
+   const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
+   const GLuint origInterpMask = span->interpMask;
    const GLuint origArrayMask = span->arrayMask;
+   GLboolean monoColor;
+
+   ASSERT((span->interpMask & span->arrayMask) == 0);
 
    MEMSET(span->mask, 1, span->end);
+   span->writeAll = GL_TRUE;
 
-   if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
-      if (clip_span( ctx,span ) == GL_FALSE) {
+   /* Determine if we have mono-chromatic colors */
+   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;
       }
    }
 
-   /* Do the scissor test */
+   /* Scissor test */
    if (ctx->Scissor.Enabled) {
-      if (_mesa_scissor_span( ctx, span ) == GL_FALSE) {
+      if (!_mesa_scissor_span(ctx, span)) {
          return;
       }
    }
 
    /* Polygon Stippling */
-   if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
-      stipple_polygon_span( ctx, span);
+   if (ctx->Polygon.StippleFlag && primitive == GL_POLYGON) {
+      stipple_polygon_span(ctx, span);
    }
 
+   /* Now we may need to interpolate the colors */
    if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0) {
       interpolate_colors(ctx, span);
-   }
-
-   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;
+      /* clear the bit - this allows the WriteMonoCISpan optimization below */
+      span->interpMask &= ~SPAN_RGBA;
    }
 
    /* Do the alpha test */
    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;
         return;
       }
@@ -766,6 +771,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
 
       if (ctx->Stencil.Enabled) {
          if (!_mesa_stencil_and_ztest_span(ctx, span)) {
+            span->interpMask = origInterpMask;
             span->arrayMask = origArrayMask;
             return;
          }
@@ -775,6 +781,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
          ASSERT(span->arrayMask & SPAN_Z);
          /* regular depth testing */
          if (!_mesa_depth_test_span(ctx, span)) {
+            span->interpMask = origInterpMask;
             span->arrayMask = origArrayMask;
             return;
          }
@@ -784,227 +791,90 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
    /* if we get here, something passed the depth test */
    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 */
    if (ctx->Fog.Enabled) {
-      if ((span->arrayMask & SPAN_FOG)  &&  !swrast->_PreferPixelFog)
-        _mesa_fog_rgba_pixels_with_array( ctx, span, span->fogArray, rgba);
-      else if ((span->interpMask & SPAN_FOG)  &&  !swrast->_PreferPixelFog)
-         _mesa_fog_rgba_pixels( ctx, span, rgba );
+      if ((span->arrayMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+        _mesa_fog_rgba_pixels_with_array(ctx, span, span->fogArray,
+                                          span->color.rgba);
+      else if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+         _mesa_fog_rgba_pixels(ctx, span, span->color.rgba);
       else {
          if ((span->interpMask & SPAN_Z) && (span->arrayMask & SPAN_Z) == 0)
             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 */
    if (span->arrayMask & SPAN_COVERAGE) {
+      GLchan (*rgba)[4] = span->color.rgba;
       GLuint i;
       for (i = 0; i < span->end; i++) {
          rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
       }
+      monoColor = GL_FALSE;
    }
 
    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 {
       /* normal: write to exactly one buffer */
-      /* logic op or blending */
-      const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
-
       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) {
-         _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 */
-      if (colorMask == 0x0) {
-         span->arrayMask = origArrayMask;
-         return;
-      }
-      else if (colorMask != 0xffffffff) {
-         _mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
+      if (colorMask != 0xffffffff) {
+         _mesa_mask_rgba_span( ctx, span->end, span->x, span->y,
+                               span->color.rgba );
+         monoColor = GL_FALSE;
       }
 
       /* 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 );
-      }
-   }
-
-   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 );
+      if (monoColor) {
+         /* all pixels have same color */
+         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 {
-         /* 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 );
-         }
+                      (const GLchan (*)[4]) span->color.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 );
-         }
+      if (swrast->_RasterMask & ALPHABUF_BIT) {
+         _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
+                      (const GLchan (*)[4]) span->color.rgba,
+                      span->writeAll ? ((const GLubyte *) NULL) : span->mask );
       }
    }
-}
 
+   span->interpMask = origInterpMask;
+   span->arrayMask = origArrayMask;
+}
 
 
 /*
@@ -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.
- * span->arrayMask, however, will not be modified (or we'll
- * restore it to the original incoming value before returning.
+ * span->interpMask and span->arrayMask may be changed but will be restored
+ * to their original values before returning.
  */
 void
 _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);
    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);*/
 
    ASSERT(ctx->Texture._ReallyEnabled);
 
    MEMSET(span->mask, 1, span->end);
+   span->writeAll = GL_TRUE;
 
    /* clip against window bounds */
    if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
index bceef2e..0f09c03 100644 (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
@@ -52,13 +52,10 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
                        GLenum primitive);
 
 extern void
-_mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
-                            const GLchan color[4], GLenum primitive );
-
-extern void
 _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
                          GLenum primitive );
 
+
 extern void
 _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
                       GLuint n, GLint x, GLint y, GLchan rgba[][4] );
index 37e6d12..ce0b127 100644 (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
@@ -106,12 +106,6 @@ static void smooth_ci_triangle( GLcontext *ctx,
 #define INTERP_INDEX 1
 
 #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);
 
 #include "s_tritemp.h"
@@ -132,6 +126,8 @@ static void flat_rgba_triangle( GLcontext *ctx,
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
 
 #define SETUP_CODE                             \
+   ASSERT(!ctx->Texture._ReallyEnabled);       \
+   ASSERT(ctx->Light.ShadeModel==GL_FLAT);     \
    span.interpMask |= SPAN_RGBA;               \
    span.red = ChanToFixed(v2->color[0]);       \
    span.green = ChanToFixed(v2->color[1]);     \
@@ -142,13 +138,10 @@ static void flat_rgba_triangle( GLcontext *ctx,
    span.blueStep = 0;                          \
    span.alphaStep = 0;
 
-#define RENDER_SPAN( span )                                            \
-   _mesa_write_monocolor_span(ctx, &span, v2->color, GL_POLYGON );
+#define RENDER_SPAN( span )                            \
+   _mesa_write_rgba_span(ctx, &span, GL_POLYGON );
 
 #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 RENDER_SPAN( span )                                    \
-   GLuint i;                                                   \
-   SW_SPAN_SET_FLAG(span.filledColor);                         \
-   SW_SPAN_SET_FLAG(span.filledAlpha);                         \
    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);
 
 #include "s_tritemp.h"
@@ -225,7 +204,6 @@ static void simple_textured_triangle( GLcontext *ctx,
 
 #define RENDER_SPAN( span  )                                           \
    GLuint i;                                                           \
-   SW_SPAN_SET_FLAG(span.filledColor);                                 \
    span.intTex[0] -= FIXED_HALF; /* off-by-one error? */               \
    span.intTex[1] -= FIXED_HALF;                                       \
    for (i = 0; i < span.end; i++) {                                    \
@@ -284,7 +262,6 @@ static void simple_z_textured_triangle( GLcontext *ctx,
    GLuint i;                                                           \
    span.intTex[0] -= FIXED_HALF; /* off-by-one error? */               \
    span.intTex[1] -= FIXED_HALF;                                       \
-   SW_SPAN_SET_FLAG(span.filledColor);                                 \
    for (i = 0; i < span.end; i++) {                                    \
       const GLdepth z = FixedToDepth(span.z);                          \
       if (z < zRow[i]) {                                               \
@@ -477,9 +454,6 @@ affine_span(GLcontext *ctx, struct sw_span *span,
    GLuint i;
    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[1] -= FIXED_HALF;
    switch (info->filter) {
@@ -747,9 +721,6 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
    GLfloat tex_coord[3], tex_step[3];
    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_step[0] = span->texStep[0][0] * (info->smask + 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;
    }
    
-   ASSERT(span->interpMask & SPAN_RGBA);
    ASSERT(span->arrayMask & SPAN_RGBA);
    _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.filter = obj->MinFilter;                                       \
    info.envmode = unit->EnvMode;                                       \
-   span.arrayMask |= SPAN_RGBA;                                                \
                                                                        \
    if (info.envmode == GL_BLEND) {                                     \
       /* 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;
 
-#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"
 
index fe2caad..7f98099 100644 (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
                /* initialize the span interpolants to the leftmost value */
                /* ff = fixed-pt fragment */
                const GLint right = FixedToInt(fxRightEdge);
-              /*INIT_SPAN(span);*/
-              SW_SPAN_RESET(span);
+
                span.x = FixedToInt(fxLeftEdge);
 
                if (right <= span.x)
index 749730c..516a5bb 100644 (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
@@ -83,11 +83,11 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
 {
    GLint r0, r1, row;
    GLint i, j;
-   struct sw_span zoomed;
    const GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+   struct sw_span zoomed;
 
-   SW_SPAN_RESET(zoomed);
    INIT_SPAN(zoomed);
+   zoomed.arrayMask |= SPAN_RGBA;
 
    /* compute width of output row */
    zoomed.end = (GLint) ABSF( n * ctx->Pixel.ZoomX );
@@ -148,8 +148,6 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
 
    /* zoom the span horizontally */
    if (ctx->Pixel.ZoomX==-1.0F) {
-      SW_SPAN_SET_FLAG(zoomed.filledColor);
-      SW_SPAN_SET_FLAG(zoomed.filledAlpha);
       /* n==m */
       for (j=zoomed.start; j<zoomed.end; j++) {
          i = n - j - 1;
@@ -165,8 +163,6 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
    }
    else {
       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++) {
          i = (GLint) (j * xscale);
          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;
    if (fog)
       zoomed.arrayMask |= SPAN_FOG;
@@ -334,7 +329,6 @@ _mesa_write_zoomed_index_span( GLcontext *ctx,
    GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
    struct sw_span zoomed;
 
-   SW_SPAN_RESET(zoomed);
    INIT_SPAN(zoomed);
    zoomed.arrayMask |= SPAN_INDEX;
 
index 02b2386..9a20370 100644 (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
@@ -160,10 +160,6 @@ struct sw_span {
 
    /* This mask indicates if fragment is alive or culled */
    GLubyte mask[MAX_WIDTH];
-
-#ifdef DEBUG
-   GLboolean filledAlpha, filledColor;
-#endif
 };
 
 
@@ -175,15 +171,6 @@ do {                       \
 } 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;