summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_aatriangle.c3
-rw-r--r--src/mesa/swrast/s_aatritemp.h176
-rw-r--r--src/mesa/swrast/s_alpha.c12
-rw-r--r--src/mesa/swrast/s_copypix.c262
-rw-r--r--src/mesa/swrast/s_depth.c14
-rw-r--r--src/mesa/swrast/s_drawpix.c190
-rw-r--r--src/mesa/swrast/s_fog.c37
-rw-r--r--src/mesa/swrast/s_pixeltex.c48
-rw-r--r--src/mesa/swrast/s_pixeltex.h6
-rw-r--r--src/mesa/swrast/s_span.c1380
-rw-r--r--src/mesa/swrast/s_span.h36
-rw-r--r--src/mesa/swrast/s_stencil.c13
-rw-r--r--src/mesa/swrast/s_texture.c75
-rw-r--r--src/mesa/swrast/s_texture.h6
-rw-r--r--src/mesa/swrast/s_triangle.c45
-rw-r--r--src/mesa/swrast/s_tritemp.h34
-rw-r--r--src/mesa/swrast/s_zoom.c156
-rw-r--r--src/mesa/swrast/swrast.h39
18 files changed, 1095 insertions, 1437 deletions
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index dde2c89f76..0162319a66 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.21 2001/12/17 04:54:35 brianp Exp $ */
+/* $Id: s_aatriangle.c,v 1.22 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,6 +30,7 @@
*/
+#include "macros.h"
#include "mem.h"
#include "mmath.h"
#include "s_aatriangle.h"
diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h
index 3ca9893735..91571cb374 100644
--- a/src/mesa/swrast/s_aatritemp.h
+++ b/src/mesa/swrast/s_aatritemp.h
@@ -1,10 +1,10 @@
-/* $Id: s_aatritemp.h,v 1.23 2001/12/17 04:54:35 brianp Exp $ */
+/* $Id: s_aatritemp.h,v 1.24 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -57,11 +57,9 @@
#ifdef DO_Z
GLfloat zPlane[4];
- GLdepth z[MAX_WIDTH];
#endif
#ifdef DO_FOG
GLfloat fogPlane[4];
- GLfloat fog[MAX_WIDTH];
#else
GLfloat *fog = NULL;
#endif
@@ -70,9 +68,6 @@
#endif
#ifdef DO_INDEX
GLfloat iPlane[4];
- GLint icoverageSpan[MAX_WIDTH];
-#else
- GLfloat coverageSpan[MAX_WIDTH];
#endif
#ifdef DO_SPEC
GLfloat srPlane[4], sgPlane[4], sbPlane[4];
@@ -90,6 +85,9 @@
GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign;
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_COVERAGE;
+
/* determine bottom to top order of vertices */
{
GLfloat y0 = v0->win[1];
@@ -143,9 +141,11 @@
*/
#ifdef DO_Z
compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane);
+ span.arrayMask |= SPAN_Z;
#endif
#ifdef DO_FOG
compute_plane(p0, p1, p2, v0->fog, v1->fog, v2->fog, fogPlane);
+ span.arrayMask |= SPAN_FOG;
#endif
#ifdef DO_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
@@ -160,6 +160,7 @@
constant_plane(v2->color[BCOMP], bPlane);
constant_plane(v2->color[ACOMP], aPlane);
}
+ span.arrayMask |= SPAN_RGBA;
#endif
#ifdef DO_INDEX
if (ctx->Light.ShadeModel == GL_SMOOTH) {
@@ -169,6 +170,7 @@
else {
constant_plane((GLfloat) v2->index, iPlane);
}
+ span.arrayMask |= SPAN_INDEX;
#endif
#ifdef DO_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
@@ -181,6 +183,7 @@
constant_plane(v2->specular[GCOMP], sgPlane);
constant_plane(v2->specular[BCOMP], sbPlane);
}
+ span.arrayMask |= SPAN_SPEC;
#endif
#ifdef DO_TEX
{
@@ -208,6 +211,7 @@
texWidth = (GLfloat) texImage->Width;
texHeight = (GLfloat) texImage->Height;
}
+ span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
#elif defined(DO_MULTITEX)
{
GLuint u;
@@ -239,6 +243,7 @@
}
}
}
+ span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
#endif
/* Begin bottom-to-top scan over the triangle.
@@ -282,15 +287,15 @@
/* (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);
+ span.coverage[count] = (GLfloat) compute_coveragei(pMin, pMid, pMax, ix, iy);
#else
- coverageSpan[count] = coverage;
+ span.coverage[count] = coverage;
#endif
#ifdef DO_Z
- z[count] = (GLdepth) solve_plane(cx, cy, zPlane);
+ span.zArray[count] = (GLdepth) solve_plane(cx, cy, zPlane);
#endif
#ifdef DO_FOG
- fog[count] = solve_plane(cx, cy, fogPlane);
+ span.fogArray[count] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
span.color.rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
@@ -302,9 +307,9 @@
span.color.index[count] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
- span.specular[count][RCOMP] = solve_plane_chan(cx, cy, srPlane);
- span.specular[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
- span.specular[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
+ span.specArray[count][RCOMP] = solve_plane_chan(cx, cy, srPlane);
+ span.specArray[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
+ span.specArray[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
#endif
#ifdef DO_TEX
{
@@ -342,38 +347,39 @@
#ifdef DO_MULTITEX
# ifdef DO_SPEC
- _old_write_multitexture_span(ctx, n, startX, iy, z, fog,
+ _old_write_multitexture_span(ctx, n, startX, iy, span.zArray,
+ span.fogArray,
span.texcoords,
span.lambda, span.color.rgba,
- span.specular,
- coverageSpan, GL_POLYGON);
+ span.specArray,
+ span.coverage, GL_POLYGON);
# else
- _old_write_multitexture_span(ctx, n, startX, iy, z, fog,
+ _old_write_multitexture_span(ctx, n, startX, iy, span.zArray,
+ span.fogArray,
span.texcoords,
span.lambda, span.color.rgba,
- NULL, coverageSpan,
+ NULL, span.coverage,
GL_POLYGON);
# endif
#elif defined(DO_TEX)
-# ifdef DO_SPEC
- _old_write_texture_span(ctx, n, startX, iy, z, fog,
- span.texcoords[0],
- span.lambda[0], span.color.rgba,
- span.specular,
- coverageSpan, GL_POLYGON);
-# else
- _old_write_texture_span(ctx, n, startX, iy, z, fog,
- span.texcoords[0],
- span.lambda[0],
- span.color.rgba, NULL,
- coverageSpan, GL_POLYGON);
-# endif
+
+ span.x = startX;
+ span.y = iy;
+ span.end = n;
+ _mesa_write_texture_span(ctx, &span, GL_POLYGON);
+
#elif defined(DO_RGBA)
- _old_write_rgba_span(ctx, n, startX, iy, z, fog, span.color.rgba,
- coverageSpan, GL_POLYGON);
+ span.x = startX;
+ span.y = iy;
+ span.end = n;
+ ASSERT(span.interpMask == 0);
+ _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
#elif defined(DO_INDEX)
- _old_write_index_span(ctx, n, startX, iy, z, fog, span.color.index,
- icoverageSpan, GL_POLYGON);
+ span.x = startX;
+ span.y = iy;
+ span.end = n;
+ ASSERT(span.interpMask == 0);
+ _mesa_write_index_span(ctx, &span, GL_POLYGON);
#endif
}
}
@@ -411,15 +417,15 @@
/* (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);
+ span.coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy);
#else
- coverageSpan[ix] = coverage;
+ span.coverage[ix] = coverage;
#endif
#ifdef DO_Z
- z[ix] = (GLdepth) solve_plane(cx, cy, zPlane);
+ span.zArray[ix] = (GLdepth) solve_plane(cx, cy, zPlane);
#endif
#ifdef DO_FOG
- fog[ix] = solve_plane(cx, cy, fogPlane);
+ span.fogArray[ix] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
span.color.rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
@@ -431,9 +437,9 @@
span.color.index[ix] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
- span.specular[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane);
- span.specular[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
- span.specular[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
+ span.specArray[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane);
+ span.specArray[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
+ span.specArray[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
#endif
#ifdef DO_TEX
{
@@ -489,46 +495,76 @@
}
}
# ifdef DO_SPEC
- _old_write_multitexture_span(ctx, n, left, iy, z + left, fog + left,
+ _old_write_multitexture_span(ctx, n, left, iy, span.zArray + left,
+ span.fogArray + left,
span.texcoords, span.lambda,
span.color.rgba + left,
- span.specular + left,
- coverageSpan + left,
+ span.specArray + left,
+ span.coverage + left,
GL_POLYGON);
# else
- _old_write_multitexture_span(ctx, n, left, iy, z + left, fog + left,
+ _old_write_multitexture_span(ctx, n, left, iy, span.zArray + left,
+ span.fogArray + left,
span.texcoords, span.lambda,
span.color.rgba + left, NULL,
- coverageSpan + left,
+ span.coverage + left,
GL_POLYGON);
# endif
#elif defined(DO_TEX)
-# ifdef DO_SPEC
- _old_write_texture_span(ctx, n, left, iy, z + left, fog + left,
- span.texcoords[0] + left,
- span.lambda[0] + left,
- span.color.rgba + left,
- span.specular + left, coverageSpan + left,
- GL_POLYGON);
-# else
- _old_write_texture_span(ctx, n, left, iy, z + left, fog + left,
- span.texcoords[0] + left,
- span.lambda[0] + left,
- span.color.rgba + left, NULL,
- coverageSpan + left, GL_POLYGON);
-# endif
+
+ /* XXX this is temporary */
+ {
+ GLint j;
+ for (j = 0; j < (GLint) n; j++) {
+ span.fogArray[j] = span.fogArray[j + left];
+ span.zArray[j] = span.zArray[j + left];
+ COPY_4V(span.color.rgba[j], span.color.rgba[j + left]);
+ COPY_4V(span.specArray[j], span.specArray[j + left]);
+ COPY_4V(span.texcoords[0][j], span.texcoords[0][j + left]);
+ span.lambda[0][j] = span.lambda[0][j + left];
+ span.coverage[j] = span.coverage[j + left];
+ }
+ }
+ span.x = left;
+ span.y = iy;
+ span.end = n;
+ _mesa_write_texture_span(ctx, &span, GL_POLYGON);
+
#elif defined(DO_RGBA)
- _old_write_rgba_span(ctx, n, left, iy, z + left, fog + left,
- span.color.rgba + left, coverageSpan + left, GL_POLYGON);
+ /* XXX this is temporary */
+ {
+ GLint j;
+ for (j = 0; j < (GLint) n; j++) {
+ span.fogArray[j] = span.fogArray[j + left];
+ span.zArray[j] = span.zArray[j + left];
+ COPY_4V(span.color.rgba[j], span.color.rgba[j + left]);
+ span.coverage[j] = span.coverage[j + left];
+ }
+ }
+ span.x = left;
+ span.y = iy;
+ span.end = n;
+ ASSERT(span.interpMask == 0);
+ _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
#elif defined(DO_INDEX)
- _old_write_index_span(ctx, n, left, iy, z + left, fog + left,
- span.color.index + left,
- icoverageSpan + left, GL_POLYGON);
+ /* XXX this is temporary */
+ {
+ GLint j;
+ for (j = 0; j < (GLint) n; j++) {
+ span.fogArray[j] = span.fogArray[j + left];
+ span.zArray[j] = span.zArray[j + left];
+ span.color.index[j] = span.color.index[j + left];
+ span.coverage[j] = span.coverage[j + left];
+ }
+ }
+ span.x = left;
+ span.y = iy;
+ span.end = n;
+ ASSERT(span.interpMask == 0);
+ _mesa_write_index_span(ctx, &span, GL_POLYGON);
#endif
}
}
-
-
}
diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c
index 7aa47f230f..ca34c120b4 100644
--- a/src/mesa/swrast/s_alpha.c
+++ b/src/mesa/swrast/s_alpha.c
@@ -1,4 +1,4 @@
-/* $Id: s_alpha.c,v 1.5 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_alpha.c,v 1.6 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,11 +49,7 @@ _mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
const GLchan ref = ctx->Color.AlphaRef;
GLubyte *mask = span->mask;
- ASSERT (span->filledMask == GL_TRUE);
- ASSERT (span->filledAlpha == GL_TRUE);
-
- SW_SPAN_SET_FLAG(span->testedAlpha);
-
+ ASSERT (span->filledAlpha == GL_TRUE || (span->arrayMask & SPAN_RGBA));
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Color.AlphaFunc) {
@@ -97,6 +93,8 @@ _mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
return 0;
}
+#if 0
+ /* XXXX This causes conformance failures!!!! */
while ((span->start <= span->end) &&
(mask[span->start] == 0))
span->start ++;
@@ -104,7 +102,7 @@ _mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
while ((span->end >= span->start) &&
(mask[span->end] == 0))
span->end --;
-
+#endif
span->writeAll = GL_FALSE;
if (span->start >= span->end)
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index 7ed59ab7d4..d418eb5410 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.28 2002/01/16 16:04:50 brianp Exp $ */
+/* $Id: s_copypix.c,v 1.29 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -101,8 +101,6 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLdepth zspan[MAX_WIDTH];
- GLfloat fogSpan[MAX_WIDTH];
GLboolean quick_draw;
GLint row;
GLboolean changeBuffer;
@@ -110,23 +108,16 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
const GLuint transferOps = ctx->_ImageTransferState;
GLfloat *dest, *tmpImage, *convImage;
+ struct sw_span span;
- if (ctx->Depth.Test || ctx->Fog.Enabled) {
- /* fill in array of z values */
- GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax);
- GLfloat fog;
- GLint i;
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_RGBA;
- 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);
+ if (ctx->Depth.Test)
+ _mesa_span_default_z(ctx, &span);
+ if (ctx->Fog.Enabled)
+ _mesa_span_default_fog(ctx, &span);
- for (i = 0; i < width; i++) {
- zspan[i] = z;
- fogSpan[i] = fog;
- }
- }
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
&& !zoom
@@ -254,7 +245,6 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
for (row = 0; row < height; row++) {
const GLfloat *src = convImage + row * width * 4;
- GLchan rgba[MAX_WIDTH][4];
GLint i, dy;
/* clamp to [0,1] and convert float back to chan */
@@ -263,30 +253,15 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint g = (GLint) (src[i * 4 + GCOMP] * CHAN_MAXF);
GLint b = (GLint) (src[i * 4 + BCOMP] * CHAN_MAXF);
GLint a = (GLint) (src[i * 4 + ACOMP] * CHAN_MAXF);
- rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
- rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
- rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
- rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+ span.color.rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
+ span.color.rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
+ span.color.rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
+ span.color.rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
- if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
- GLchan primary_rgba[MAX_WIDTH][4];
- GLuint unit;
- DEFMARRAY(GLfloat, texcoord, MAX_WIDTH, 4); /* mac 32k limitation */
- CHECKARRAY(texcoord, return); /* mac 32k limitation */
-
- /* XXX not sure how multitexture is supposed to work here */
-
- MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
-
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
- texcoord);
- _old_swrast_texture_fragments( ctx, unit, width, texcoord, NULL,
- (CONST GLchan (*)[4]) primary_rgba,
- rgba);
- }
- UNDEFARRAY(texcoord); /* mac 32k limitation */
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ span.end = width;
+ _swrast_pixel_texture(ctx, &span);
}
/* write row to framebuffer */
@@ -294,15 +269,19 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
dy = desty + row;
if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) {
(*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy,
- (const GLchan (*)[4])rgba, NULL );
+ (const GLchan (*)[4])span.color.rgba, NULL );
}
else if (zoom) {
- _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, fogSpan,
- (const GLchan (*)[4])rgba, desty);
+ _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, span.zArray,
+ span.fogArray,
+ (const GLchan (*)[4])span.color.rgba,
+ desty);
}
else {
- _old_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba,
- NULL, GL_BITMAP );
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
@@ -318,9 +297,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLdepth zspan[MAX_WIDTH];
- GLfloat fogSpan[MAX_WIDTH];
- GLchan rgba[MAX_WIDTH][4];
GLchan *tmpImage,*p;
GLboolean quick_draw;
GLint sy, dy, stepy;
@@ -330,6 +306,10 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
const GLuint transferOps = ctx->_ImageTransferState;
+ struct sw_span span;
+
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_RGBA;
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
@@ -364,11 +344,17 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
for (i=0;i<width;i++) {
- zspan[i] = z;
- fogSpan[i] = fog;
+ 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)
+ _mesa_span_default_fog(ctx, &span);
+
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
&& !zoom
&& destx >= 0
@@ -423,7 +409,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* Get source pixels */
if (overlapping) {
/* get from buffered image */
- MEMCPY(rgba, p, width * sizeof(GLchan) * 4);
+ MEMCPY(span.color.rgba, p, width * sizeof(GLchan) * 4);
p += (width * sizeof(GLchan) * 4);
}
else {
@@ -444,7 +430,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha;
}
}
- _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, rgba );
+ _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, span.color.rgba );
}
if (changeBuffer) {
@@ -462,10 +448,10 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* convert chan to float */
for (k = 0; k < width; k++) {
- rgbaFloat[k][RCOMP] = (GLfloat) rgba[k][RCOMP] * scale;
- rgbaFloat[k][GCOMP] = (GLfloat) rgba[k][GCOMP] * scale;
- rgbaFloat[k][BCOMP] = (GLfloat) rgba[k][BCOMP] * scale;
- rgbaFloat[k][ACOMP] = (GLfloat) rgba[k][ACOMP] * scale;
+ rgbaFloat[k][RCOMP] = (GLfloat) span.color.rgba[k][RCOMP] * scale;
+ rgbaFloat[k][GCOMP] = (GLfloat) span.color.rgba[k][GCOMP] * scale;
+ rgbaFloat[k][BCOMP] = (GLfloat) span.color.rgba[k][BCOMP] * scale;
+ rgbaFloat[k][ACOMP] = (GLfloat) span.color.rgba[k][ACOMP] * scale;
}
/* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) {
@@ -485,7 +471,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
/* convolution */
if (transferOps & IMAGE_CONVOLUTION_BIT) {
- /* XXX to do */
+ abort(); /* should never get here; caught at top of function */
}
/* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */
if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) {
@@ -525,45 +511,34 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint g = (GLint) (rgbaFloat[k][GCOMP] * CHAN_MAXF);
GLint b = (GLint) (rgbaFloat[k][BCOMP] * CHAN_MAXF);
GLint a = (GLint) (rgbaFloat[k][ACOMP] * CHAN_MAXF);
- rgba[k][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
- rgba[k][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
- rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
- rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+ span.color.rgba[k][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
+ span.color.rgba[k][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
+ span.color.rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
+ span.color.rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
UNDEFARRAY(rgbaFloat); /* mac 32k limitation */
}
- if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
- GLuint unit;
- GLchan primary_rgba[MAX_WIDTH][4];
- DEFMARRAY(GLfloat, texcoord, MAX_WIDTH, 4); /* mac 32k limitation */
- CHECKARRAY(texcoord, return); /* mac 32k limitation */
-
- /* XXX not sure how multitexture is supposed to work here */
- MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
-
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
- texcoord);
- _old_swrast_texture_fragments( ctx, unit, width, texcoord, NULL,
- (CONST GLchan (*)[4]) primary_rgba,
- rgba);
- }
-
- UNDEFARRAY(texcoord); /* mac 32k limitation */
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ span.end = width;
+ _swrast_pixel_texture(ctx, &span);
}
if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) {
(*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy,
- (const GLchan (*)[4])rgba, NULL );
+ (const GLchan (*)[4])span.color.rgba, NULL );
}
else if (zoom) {
- _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, fogSpan,
- (const GLchan (*)[4])rgba, desty);
+ _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, span.zArray,
+ span.fogArray,
+ (const GLchan (*)[4]) span.color.rgba,
+ desty);
}
else {
- _old_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba,
- NULL, GL_BITMAP );
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
@@ -581,15 +556,17 @@ static void copy_ci_pixels( GLcontext *ctx,
GLint destx, GLint desty )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLdepth zspan[MAX_WIDTH];
- GLfloat fogSpan[MAX_WIDTH];
GLuint *tmpImage,*p;
GLint sy, dy, stepy;
- GLint i, j;
+ GLint j;
GLboolean changeBuffer;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
GLint overlapping;
+ struct sw_span span;
+
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_INDEX;
/* Determine if copy should be bottom-to-top or top-to-bottom */
if (srcy<desty) {
@@ -608,21 +585,10 @@ static void copy_ci_pixels( GLcontext *ctx,
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++) {
- zspan[i] = z;
- fogSpan[i] = fog;
- }
- }
+ if (ctx->Depth.Test)
+ _mesa_span_default_z(ctx, &span);
+ if (ctx->Fog.Enabled)
+ _mesa_span_default_fog(ctx, &span);
/* If read and draw buffer are different we must do buffer switching */
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
@@ -655,9 +621,8 @@ static void copy_ci_pixels( GLcontext *ctx,
}
for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
- GLuint indexes[MAX_WIDTH];
if (overlapping) {
- MEMCPY(indexes, p, width * sizeof(GLuint));
+ MEMCPY(span.color.index, p, width * sizeof(GLuint));
p += width;
}
else {
@@ -665,7 +630,8 @@ static void copy_ci_pixels( GLcontext *ctx,
(*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
}
- _mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy, indexes );
+ _mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy,
+ span.color.index );
}
if (changeBuffer) {
@@ -675,19 +641,22 @@ static void copy_ci_pixels( GLcontext *ctx,
}
if (shift_or_offset) {
- _mesa_shift_and_offset_ci( ctx, width, indexes );
+ _mesa_shift_and_offset_ci( ctx, width, span.color.index );
}
if (ctx->Pixel.MapColorFlag) {
- _mesa_map_ci( ctx, width, indexes );
+ _mesa_map_ci( ctx, width, span.color.index );
}
if (zoom) {
- _mesa_write_zoomed_index_span(ctx, width, destx, dy, zspan, fogSpan,
- indexes, desty );
+ _mesa_write_zoomed_index_span(ctx, width, destx, dy,
+ span.zArray, span.fogArray,
+ span.color.index, desty );
}
else {
- _old_write_index_span(ctx, width, destx, dy, zspan, fogSpan, indexes,
- NULL, GL_BITMAP);
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _mesa_write_index_span(ctx, &span, GL_BITMAP);
}
}
@@ -709,20 +678,18 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint destx, GLint desty )
{
GLfloat depth[MAX_WIDTH];
- GLdepth zspan[MAX_WIDTH];
- GLfloat fogSpan[MAX_WIDTH];
GLfloat *p, *tmpImage;
- GLuint indexes[MAX_WIDTH];
GLint sy, dy, stepy;
GLint i, j;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
- DEFMARRAY(GLchan, rgba, MAX_WIDTH, 4); /* mac 32k limitation */
- CHECKARRAY(rgba, return); /* mac 32k limitation */
+ struct sw_span span;
+
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_Z;
if (!ctx->Visual.depthBits) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
- UNDEFARRAY(rgba); /* mac 32k limitation */
return;
}
@@ -743,45 +710,15 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
- /* setup colors or indexes */
- if (ctx->Visual.rgbMode) {
- GLchan r, g, b, a;
- UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]);
- UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]);
- UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]);
- UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]);
- for (i = 0; i < width; i++) {
- rgba[i][RCOMP] = r;
- rgba[i][GCOMP] = g;
- rgba[i][BCOMP] = b;
- rgba[i][ACOMP] = a;
- }
- }
- else {
- for (i = 0; i < width; i++) {
- indexes[i] = ctx->Current.Index;
- }
- }
-
- if (ctx->Fog.Enabled) {
- 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++) {
- fogSpan[i] = fog;
- }
- }
+ _mesa_span_default_color(ctx, &span);
+ if (ctx->Fog.Enabled)
+ _mesa_span_default_fog(ctx, &span);
if (overlapping) {
GLint ssy = sy;
tmpImage = (GLfloat *) MALLOC(width * height * sizeof(GLfloat));
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
- UNDEFARRAY(rgba); /* mac 32k limitation */
return;
}
p = tmpImage;
@@ -807,33 +744,38 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
for (i = 0; i < width; i++) {
GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
- zspan[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->DepthMax);
+ span.zArray[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->DepthMax);
}
if (ctx->Visual.rgbMode) {
if (zoom) {
- _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan,
- fogSpan, (const GLchan (*)[4])rgba, desty );
+ _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, span.zArray,
+ span.fogArray,
+ (const GLchan (*)[4])span.color.rgba,
+ desty );
}
else {
- _old_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan,
- (GLchan (*)[4])rgba, NULL, GL_BITMAP);
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
else {
if (zoom) {
_mesa_write_zoomed_index_span( ctx, width, destx, dy,
- zspan, fogSpan, indexes, desty );
+ span.zArray, span.fogArray,
+ span.color.index, desty );
}
else {
- _old_write_index_span( ctx, width, destx, dy,
- zspan, fogSpan, indexes, NULL, GL_BITMAP );
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _mesa_write_index_span(ctx, &span, GL_BITMAP);
}
}
}
- UNDEFARRAY(rgba); /* mac 32k limitation */
-
if (overlapping)
FREE(tmpImage);
}
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 5a7fc4b4ed..3a3f1904d0 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,4 +1,4 @@
-/* $Id: s_depth.c,v 1.11 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_depth.c,v 1.12 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -572,10 +572,8 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- ASSERT(span->activeMask & SPAN_Z);
- ASSERT(span->filledMask == GL_TRUE);
- ASSERT(span->filledDepth == GL_TRUE);
- SW_SPAN_SET_FLAG(span->testedDepth);
+ ASSERT((span->interpMask & SPAN_Z) || (span->arrayMask & SPAN_Z));
+ ASSERT((span->filledDepth == GL_TRUE) || (span->arrayMask & SPAN_Z));
if (swrast->Driver.ReadDepthSpan) {
/* hardware-based depth buffer */
@@ -583,7 +581,7 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
GLuint passed;
(*swrast->Driver.ReadDepthSpan)(ctx, span->end, span->x, span->y, zbuffer);
passed = depth_test_span32(ctx, span->end, span->x, span->y,
- zbuffer, span->depth, span->mask);
+ zbuffer, span->zArray, span->mask);
ASSERT(swrast->Driver.WriteDepthSpan);
(*swrast->Driver.WriteDepthSpan)(ctx, span->end, span->x, span->y, zbuffer, span->mask);
if (passed < span->end)
@@ -595,11 +593,11 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
/* software depth buffer */
if (ctx->Visual.depthBits <= 16) {
GLushort *zptr = (GLushort *) Z_ADDRESS16(ctx, span->x, span->y);
- passed = depth_test_span16(ctx, span->end, span->x, span->y, zptr, span->depth, span->mask);
+ passed = depth_test_span16(ctx, span->end, span->x, span->y, zptr, span->zArray, span->mask);
}
else {
GLuint *zptr = (GLuint *) Z_ADDRESS32(ctx, span->x, span->y);
- passed = depth_test_span32(ctx, span->end, span->x, span->y, zptr, span->depth, span->mask);
+ passed = depth_test_span32(ctx, span->end, span->x, span->y, zptr, span->zArray, span->mask);
}
if (passed < span->end)
span->writeAll = GL_FALSE;
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index dfe7166880..4be186bb91 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.25 2002/01/15 21:49:58 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.26 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -489,46 +489,37 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
{
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
- GLint row, drawWidth;
- GLdepth zspan[MAX_WIDTH];
- GLfloat fogSpan[MAX_WIDTH];
+ GLint row, drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+ struct sw_span span;
- drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_INDEX;
- /* Fragment depth values */
- if (ctx->Depth.Test || ctx->Fog.Enabled) {
- GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMaxF);
- GLfloat fog;
- GLint i;
-
- 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 < drawWidth; i++) {
- zspan[i] = zval;
- fogSpan[i] = fog;
- }
- }
+ if (ctx->Depth.Test)
+ _mesa_span_default_z(ctx, &span);
+ if (ctx->Fog.Enabled)
+ _mesa_span_default_fog(ctx, &span);
/*
* General solution
*/
for (row = 0; row < height; row++, y++) {
- GLuint indexes[MAX_WIDTH];
const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
- _mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes,
+ _mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT,
+ span.color.index,
type, source, &ctx->Unpack,
ctx->_ImageTransferState);
if (zoom) {
- _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, fogSpan,
- indexes, desty);
+ _mesa_write_zoomed_index_span(ctx, drawWidth, x, y,
+ span.zArray, span.fogArray,
+ span.color.index, desty);
}
else {
- _old_write_index_span(ctx, drawWidth, x, y, zspan, fogSpan, indexes,
- NULL, GL_BITMAP);
+ span.x = x;
+ span.y = y;
+ span.end = drawWidth;
+ _mesa_write_index_span(ctx, &span, GL_BITMAP);
}
}
}
@@ -594,7 +585,6 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
}
-
/*
* Do a glDrawPixels of depth values.
*/
@@ -606,9 +596,12 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
- GLchan rgba[MAX_WIDTH][4];
- GLuint ispan[MAX_WIDTH];
GLint drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+ struct sw_span span;
+
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_Z;
+ span.end = drawWidth;
if (type != GL_BYTE
&& type != GL_UNSIGNED_BYTE
@@ -621,42 +614,28 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
return;
}
- /* Colors or indexes */
- if (ctx->Visual.rgbMode) {
- GLint i;
- GLint r, g, b, a;
- UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
- UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]);
- UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]);
- UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]);
- for (i = 0; i < drawWidth; i++) {
- rgba[i][RCOMP] = r;
- rgba[i][GCOMP] = g;
- rgba[i][BCOMP] = b;
- rgba[i][ACOMP] = a;
- }
- }
- else {
- GLint i;
- for (i = 0; i < drawWidth; i++) {
- ispan[i] = ctx->Current.RasterIndex;
- }
- }
+ _mesa_span_default_color(ctx, &span);
+
+ if (ctx->Fog.Enabled)
+ _mesa_span_default_fog(ctx, &span);
if (type==GL_UNSIGNED_SHORT && sizeof(GLdepth)==sizeof(GLushort)
&& !bias_or_scale && !zoom && ctx->Visual.rgbMode) {
/* Special case: directly write 16-bit depth values */
GLint row;
for (row = 0; row < height; row++, y++) {
- GLdepth zspan[MAX_WIDTH];
const GLushort *zptr = (const GLushort *)
_mesa_image_address(&ctx->Unpack, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, row, 0);
GLint i;
- for (i = 0; i < width; i++)
- zspan[i] = zptr[i];
- _old_write_rgba_span(ctx, width, x, y, zspan, 0, rgba,
- NULL, GL_BITMAP);
+ for (i = 0; i < drawWidth; i++)
+ span.zArray[i] = zptr[i];
+
+ span.x = x;
+ span.y = y;
+ span.end = drawWidth;
+ span.filledDepth = GL_TRUE; /* XXX temporary */
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
else if (type==GL_UNSIGNED_INT && ctx->Visual.depthBits == 32
@@ -667,8 +646,15 @@ 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);
- _old_write_rgba_span(ctx, width, x, y, zptr, 0, rgba,
- NULL, GL_BITMAP);
+
+ /* XXX get rid of this loop. use zArray pointer in span */
+ GLint i;
+ for (i = 0; i < drawWidth; i++)
+ span.zArray[i] = zptr[i];
+ span.x = x;
+ span.y = y;
+ span.end = drawWidth;
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
else {
@@ -676,7 +662,6 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row = 0; row < height; row++, y++) {
GLfloat fspan[MAX_WIDTH];
- GLdepth zspan[MAX_WIDTH];
const GLvoid *src = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
_mesa_unpack_depth_span( ctx, drawWidth, fspan, type, src,
@@ -686,31 +671,35 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const GLfloat zs = ctx->DepthMaxF;
GLint i;
for (i = 0; i < drawWidth; i++) {
- zspan[i] = (GLdepth) (fspan[i] * zs);
+ span.zArray[i] = (GLdepth) (fspan[i] * zs);
}
}
if (ctx->Visual.rgbMode) {
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, span.zArray, 0,
+ (const GLchan (*)[4]) span.color.rgba, desty);
}
else {
- _old_write_rgba_span(ctx, width, x, y, zspan, 0,
- rgba, NULL, GL_BITMAP);
+ span.x = x;
+ span.y = y;
+ span.end = drawWidth;
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
else {
if (zoom) {
- _mesa_write_zoomed_index_span(ctx, width, x, y, zspan, 0,
- ispan, GL_BITMAP);
+ _mesa_write_zoomed_index_span(ctx, drawWidth, x, y,
+ span.zArray, 0,
+ span.color.index, GL_BITMAP);
}
else {
- _old_write_index_span(ctx, width, x, y, zspan, 0,
- ispan, NULL, GL_BITMAP);
+ span.x = x;
+ span.y = y;
+ span.end = drawWidth;
+ _mesa_write_index_span(ctx, &span, GL_BITMAP);
}
}
-
}
}
}
@@ -728,11 +717,13 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
- GLdepth zspan[MAX_WIDTH];
- GLfloat fogSpan[MAX_WIDTH];
GLboolean quickDraw;
GLfloat *convImage = NULL;
GLuint transferOps = ctx->_ImageTransferState;
+ struct sw_span span;
+
+ INIT_SPAN(span);
+ span.arrayMask |= SPAN_RGBA;
if (!_mesa_is_legal_format_and_type(format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)");
@@ -756,11 +747,14 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
for (i=0;i<width;i++) {
- zspan[i] = z;
- fogSpan[i] = fog;
+ span.zArray[i] = z;
+ span.fogArray[i] = fog;
}
}
+ if (ctx->Fog.Enabled)
+ _mesa_span_default_fog(ctx, &span);
+ span.arrayMask |= SPAN_Z;
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom && x >= 0 && y >= 0
&& x + width <= ctx->DrawBuffer->Width
@@ -827,54 +821,47 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
* General solution
*/
{
- GLchan rgba[MAX_WIDTH][4];
GLint row;
if (width > MAX_WIDTH)
width = MAX_WIDTH;
for (row = 0; row < height; row++, y++) {
const GLvoid *source = _mesa_image_address(unpack,
pixels, width, height, format, type, 0, row, 0);
- _mesa_unpack_chan_color_span(ctx, width, GL_RGBA, (GLchan *) rgba,
+ /* printf("Unpack f=0x%x t=0x%x\n", format, type);*/
+ _mesa_unpack_chan_color_span(ctx, width, GL_RGBA,
+ (GLchan *) span.color.rgba,
format, type, source, unpack,
transferOps);
+ if (0){
+ int k;
+ for (k = 0; k < width; k++)
+ printf("%02x ", span.color.rgba[k][3]);
+ printf("\n");
+ }
+
if ((ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) ||
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
- if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
- GLchan primary_rgba[MAX_WIDTH][4];
- GLuint unit;
-
- DEFMARRAY(GLfloat, texcoord, MAX_WIDTH, 4);/* mac 32k limitation */
- CHECKARRAY(texcoord, return); /* mac 32k limitation */
-
- /* XXX not sure how multitexture is supposed to work here */
- MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
-
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
- texcoord);
- _old_swrast_texture_fragments( ctx, unit, width,
- texcoord, NULL,
- (CONST GLchan (*)[4]) primary_rgba,
- rgba);
- }
- }
- UNDEFARRAY(texcoord); /* mac 32k limitation */
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ span.end = width;
+ _swrast_pixel_texture(ctx, &span);
}
if (quickDraw) {
(*swrast->Driver.WriteRGBASpan)(ctx, width, x, y,
- (CONST GLchan (*)[4]) rgba, NULL);
+ (CONST GLchan (*)[4]) span.color.rgba, NULL);
}
else if (zoom) {
- _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, fogSpan,
- (CONST GLchan (*)[4]) rgba, desty);
+ _mesa_write_zoomed_rgba_span(ctx, width, x, y, span.zArray,
+ span.fogArray,
+ (CONST GLchan (*)[4]) span.color.rgba, desty);
}
else {
- _old_write_rgba_span(ctx, (GLuint) width, x, y, zspan, fogSpan,
- rgba, NULL, GL_BITMAP);
+ span.x = x;
+ span.y = y;
+ span.end = width;
+ _mesa_write_rgba_span(ctx, &span, GL_BITMAP);
}
}
}
@@ -905,7 +892,6 @@ _swrast_DrawPixels( GLcontext *ctx,
_swrast_validate_derived( ctx );
RENDER_START(swrast,ctx);
-
switch (format) {
case GL_STENCIL_INDEX:
draw_stencil_pixels( ctx, x, y, width, height, type, pixels );
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 5a8ac878cd..4d9af9bb52 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -1,4 +1,4 @@
-/* $Id: s_fog.c,v 1.17 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_fog.c,v 1.18 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -85,9 +85,10 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
GLfloat fog = span->fog, Dfog = span->fogStep;
GLchan rFog, gFog, bFog;
+ /* printf("%s\n", __FUNCTION__);*/
ASSERT(ctx->Fog.Enabled);
- ASSERT(span->activeMask & SPAN_FOG);
- ASSERT(span->filledColor == GL_TRUE);
+ ASSERT(span->interpMask & SPAN_FOG);
+ ASSERT(span->filledColor == GL_TRUE || (span->arrayMask & SPAN_RGBA));
UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
@@ -118,9 +119,10 @@ _mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
GLuint i;
GLchan rFog, gFog, bFog;
+ /* printf("%s\n", __FUNCTION__);*/
ASSERT(fog != NULL);
ASSERT(ctx->Fog.Enabled);
- ASSERT(span->filledColor == GL_TRUE);
+ ASSERT(span->filledColor == GL_TRUE || (span->arrayMask & SPAN_RGBA));
UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
@@ -151,6 +153,7 @@ _old_fog_rgba_pixels( const GLcontext *ctx,
GLuint i;
GLchan rFog, gFog, bFog;
+ /* printf("%s\n", __FUNCTION__);*/
UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(bFog, ctx->Fog.Color[BCOMP]);
@@ -181,8 +184,8 @@ _mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
GLfloat fog = span->fog, Dfog = span->fogStep;
ASSERT(ctx->Fog.Enabled);
- ASSERT(span->activeMask & SPAN_FOG);
- ASSERT(span->filledColor == GL_TRUE);
+ ASSERT(span->interpMask & SPAN_FOG);
+ ASSERT(span->interpMask & SPAN_INDEX);
for (i = 0; i < span->end; i++) {
const GLfloat f = CLAMP(fog, 0.0F, 1.0F);
@@ -209,7 +212,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);
+ ASSERT((span->filledColor == GL_TRUE) || (span->arrayMask & SPAN_INDEX));
for (i = span->start; i < span->end; i++) {
const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F);
@@ -383,7 +386,7 @@ compute_fog_factors_from_z( const GLcontext *ctx,
/**
* Apply fog to a span of RGBA pixels.
* Input: ctx -
- * span - where span->depth has to be filled.
+ * span - where span->zArray has to be filled.
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*/
@@ -393,13 +396,13 @@ _mesa_depth_fog_rgba_pixels(const GLcontext *ctx, struct sw_span *span,
{
GLfloat fogFact[PB_SIZE];
+ /* printf("%s\n", __FUNCTION__);*/
ASSERT(ctx->Fog.Enabled);
- ASSERT(span->activeMask & SPAN_Z);
+ ASSERT(span->arrayMask & SPAN_Z);
ASSERT(span->end <= PB_SIZE);
- ASSERT(span->filledDepth == GL_TRUE);
- ASSERT(span->filledColor == GL_TRUE);
+ ASSERT((span->filledDepth) == GL_TRUE || (span->arrayMask & SPAN_Z));
- compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact );
+ compute_fog_factors_from_z(ctx, span->end, span->zArray, fogFact );
_mesa_fog_rgba_pixels_with_array( ctx, span, fogFact, rgba );
}
@@ -417,6 +420,7 @@ _old_depth_fog_rgba_pixels( const GLcontext *ctx,
{
GLfloat fogFact[PB_SIZE];
ASSERT(n <= PB_SIZE);
+ /* printf("%s\n", __FUNCTION__);*/
compute_fog_factors_from_z( ctx, n, z, fogFact );
_old_fog_rgba_pixels( ctx, n, fogFact, rgba );
}
@@ -425,7 +429,7 @@ _old_depth_fog_rgba_pixels( const GLcontext *ctx,
/**
* Apply fog to a span of color index pixels.
* Input: ctx -
- * span - where span->depth has to be filled.
+ * span - where span->zArray has to be filled.
* index - pixel color indexes
* Output: index - fogged pixel color indexes
*/
@@ -436,12 +440,11 @@ _mesa_depth_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
GLfloat fogFact[PB_SIZE];
ASSERT(ctx->Fog.Enabled);
- ASSERT(span->activeMask & SPAN_Z);
+ ASSERT(span->arrayMask & SPAN_Z);
ASSERT(span->end <= PB_SIZE);
- ASSERT(span->filledDepth == GL_TRUE);
- ASSERT(span->filledColor == GL_TRUE);
+ ASSERT((span->filledDepth == GL_TRUE) || (span->arrayMask & SPAN_Z));
- compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact );
+ compute_fog_factors_from_z(ctx, span->end, span->zArray, fogFact );
_mesa_fog_ci_pixels_with_array( ctx, span, fogFact, index );
}
diff --git a/src/mesa/swrast/s_pixeltex.c b/src/mesa/swrast/s_pixeltex.c
index 88a20e596b..cbebeaf407 100644
--- a/src/mesa/swrast/s_pixeltex.c
+++ b/src/mesa/swrast/s_pixeltex.c
@@ -1,4 +1,4 @@
-/* $Id: s_pixeltex.c,v 1.4 2002/01/10 16:54:29 brianp Exp $ */
+/* $Id: s_pixeltex.c,v 1.5 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,17 +35,19 @@
#include "glheader.h"
#include "colormac.h"
+#include "mem.h"
#include "s_context.h"
#include "s_pixeltex.h"
+#include "s_texture.h"
/*
* Convert RGBA values into strq texture coordinates.
*/
-void
-_mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
- GLfloat texcoord[][4])
+static void
+pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
+ GLfloat texcoord[][4])
{
if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_COLOR) {
GLuint i;
@@ -79,3 +81,41 @@ _mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
}
}
}
+
+
+
+/*
+ * Used byglDraw/CopyPixels: the incoming image colors are treated
+ * as texture coordinates. Use those coords to texture the image.
+ * This is for GL_SGIS_pixel_texture / GL_SGIX_pixel_texture.
+ */
+void
+_swrast_pixel_texture(GLcontext *ctx, struct sw_span *span)
+{
+ if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
+ /* multitexture! */
+ GLchan rgbaOut[MAX_WIDTH][4];
+ GLuint unit;
+
+ MEMCPY(rgbaOut, span->color.rgba, 4 * span->end * sizeof(GLchan));
+
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ pixeltexgen(ctx, span->end,
+ (const GLchan (*)[4]) span->color.rgba,
+ span->texcoords[unit]);
+ _swrast_texture_fragments(ctx, unit, span, rgbaOut);
+ }
+ }
+
+ MEMCPY(span->color.rgba, rgbaOut, 4 * span->end * sizeof(GLchan));
+ }
+ else {
+ /* single texture, unit 0 */
+ ASSERT(ctx->Texture._ReallyEnabled & TEXTURE0_ANY);
+ pixeltexgen(ctx, span->end,
+ (const GLchan (*)[4]) span->color.rgba,
+ span->texcoords[0]);
+ _swrast_texture_fragments(ctx, 0, span, span->color.rgba);
+ }
+}
diff --git a/src/mesa/swrast/s_pixeltex.h b/src/mesa/swrast/s_pixeltex.h
index 73aebe22d1..73b09da7f5 100644
--- a/src/mesa/swrast/s_pixeltex.h
+++ b/src/mesa/swrast/s_pixeltex.h
@@ -1,4 +1,4 @@
-/* $Id: s_pixeltex.h,v 1.4 2002/01/10 16:54:29 brianp Exp $ */
+/* $Id: s_pixeltex.h,v 1.5 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,9 +31,9 @@
#include "mtypes.h"
#include "swrast.h"
+
extern void
-_mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
- GLfloat texcoord[][4]);
+_swrast_pixel_texture(GLcontext *ctx, struct sw_span *span);
#endif
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index fce8d33c97..4e4bdf298f 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.23 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_span.c,v 1.24 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -50,11 +50,356 @@
#include "s_stencil.h"
#include "s_texture.h"
-INLINE
-static void SET_MASK_TO_ONE(struct sw_span *span) {
- SW_SPAN_SET_FLAG(span->filledMask);
- /* init mask to 1's (all pixels are to be written) */
- MEMSET(span->mask, 1, span->end);
+
+/*
+ * Init span's Z interpolation values to the RasterPos Z.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_mesa_span_default_z( GLcontext *ctx, struct sw_span *span )
+{
+ if (ctx->Visual.depthBits <= 16)
+ span->z = FloatToFixed(ctx->Current.RasterPos[2] * ctx->DepthMax);
+ else
+ span->z = (GLint) (ctx->Current.RasterPos[2] * ctx->DepthMax);
+ span->zStep = 0;
+ span->interpMask |= SPAN_Z;
+}
+
+
+/*
+ * Init span's fog interpolation values to the RasterPos fog.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_mesa_span_default_fog( GLcontext *ctx, struct sw_span *span )
+{
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ span->fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+ else
+ span->fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+ span->fogStep = 0;
+ span->interpMask |= SPAN_FOG;
+}
+
+
+/*
+ * Init span's color or index interpolation values to the RasterPos color.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_mesa_span_default_color( GLcontext *ctx, struct sw_span *span )
+{
+ if (ctx->Visual.rgbMode) {
+ GLchan r, g, b, a;
+ UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]);
+#if CHAN_TYPE == GL_FLOAT
+ span->red = r;
+ span->green = g;
+ span->blue = b;
+ span->alpha = a;
+#else
+ span->red = IntToFixed(r);
+ span->green = IntToFixed(g);
+ span->blue = IntToFixed(b);
+ span->alpha = IntToFixed(a);
+#endif
+ span->redStep = 0;
+ span->greenStep = 0;
+ span->blueStep = 0;
+ span->alphaStep = 0;
+ span->interpMask |= SPAN_RGBA;
+ }
+ else {
+ span->index = IntToFixed(ctx->Current.RasterIndex);
+ span->indexStep = 0;
+ span->interpMask |= SPAN_INDEX;
+ }
+}
+
+
+/* Fill in the span.color.rgba array from the interpolation values */
+static void
+interpolate_colors(GLcontext *ctx, struct sw_span *span)
+{
+ GLfixed r = span->red;
+ GLfixed g = span->green;
+ GLfixed b = span->blue;
+ GLfixed a = span->alpha;
+ const GLint dr = span->redStep;
+ const GLint dg = span->greenStep;
+ const GLint db = span->blueStep;
+ const GLint da = span->alphaStep;
+ const GLuint n = span->end;
+ GLchan (*rgba)[4] = span->color.rgba;
+ GLuint i;
+
+ ASSERT(span->interpMask & SPAN_RGBA);
+
+ /*
+ SW_SPAN_SET_FLAG(span->filledColor);
+ SW_SPAN_SET_FLAG(span->filledAlpha);
+ */
+
+ if (span->interpMask & SPAN_FLAT) {
+ /* constant color */
+ GLchan color[4];
+ color[RCOMP] = FixedToChan(r);
+ color[GCOMP] = FixedToChan(g);
+ color[BCOMP] = FixedToChan(b);
+ color[ACOMP] = FixedToChan(a);
+ for (i = 0; i < n; i++) {
+ COPY_CHAN4(span->color.rgba[i], color);
+ }
+ }
+ else {
+ /* interpolate */
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = FixedToChan(r);
+ rgba[i][GCOMP] = FixedToChan(g);
+ rgba[i][BCOMP] = FixedToChan(b);
+ rgba[i][ACOMP] = FixedToChan(a);
+ r += dr;
+ g += dg;
+ b += db;
+ a += da;
+ }
+ }
+ span->arrayMask |= SPAN_RGBA;
+}
+
+
+/* Fill in the span.color.index array from the interpolation values */
+static void
+interpolate_indexes(GLcontext *ctx, struct sw_span *span)
+{
+ GLfixed index = span->index;
+ const GLint indexStep = span->indexStep;
+ const GLuint n = span->end;
+ GLuint *indexes = span->color.index;
+ GLuint i;
+ ASSERT(span->interpMask & SPAN_INDEX);
+
+ if ((span->interpMask & SPAN_FLAT) || (indexStep == 0)) {
+ /* constant color */
+ index = FixedToInt(index);
+ for (i = 0; i < n; i++) {
+ indexes[i] = index;
+ }
+ }
+ else {
+ /* interpolate */
+ for (i = 0; i < n; i++) {
+ indexes[i] = FixedToInt(index);
+ index += indexStep;
+ }
+ }
+ span->arrayMask |= SPAN_INDEX;
+}
+
+
+/* Fill in the span.specArray array from the interpolation values */
+static void
+interpolate_specular(GLcontext *ctx, struct sw_span *span)
+{
+ if (span->interpMask & SPAN_FLAT) {
+ /* constant color */
+ const GLchan r = FixedToChan(span->specRed);
+ const GLchan g = FixedToChan(span->specGreen);
+ const GLchan b = FixedToChan(span->specBlue);
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ span->specArray[i][RCOMP] = r;
+ span->specArray[i][GCOMP] = g;
+ span->specArray[i][BCOMP] = b;
+ }
+ }
+ else {
+ /* interpolate */
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat r = span->specRed;
+ GLfloat g = span->specGreen;
+ GLfloat b = span->specBlue;
+#else
+ GLfixed r = span->specRed;
+ GLfixed g = span->specGreen;
+ GLfixed b = span->specBlue;
+#endif
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ span->specArray[i][RCOMP] = FixedToChan(r);
+ span->specArray[i][GCOMP] = FixedToChan(g);
+ span->specArray[i][BCOMP] = FixedToChan(b);
+ r += span->specRedStep;
+ g += span->specGreenStep;
+ b += span->specBlueStep;
+ }
+ }
+ span->arrayMask |= SPAN_SPEC;
+}
+
+
+/* Fill in the span.zArray array from the interpolation values */
+static void
+interpolate_z(GLcontext *ctx, struct sw_span *span)
+{
+ const GLuint n = span->end;
+ GLuint i;
+
+ ASSERT(span->interpMask & SPAN_Z);
+
+ /* SW_SPAN_SET_FLAG(span->filledDepth);*/
+
+ if (ctx->Visual.depthBits <= 16) {
+ GLfixed zval = span->z;
+ for (i = 0; i < n; i++) {
+ span->zArray[i] = FixedToInt(zval);
+ zval += span->zStep;
+ }
+ }
+ else {
+ /* Deep Z buffer, no fixed->int shift */
+ GLfixed zval = span->z;
+ for (i = 0; i < n; i++) {
+ span->zArray[i] = zval;
+ zval += span->zStep;
+ }
+ }
+ span->arrayMask |= SPAN_Z;
+}
+
+
+
+/* Fill in the span.texcoords array from the interpolation values */
+static void
+interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
+{
+ ASSERT(span->interpMask & SPAN_TEXTURE);
+
+ if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
+ if (span->interpMask & SPAN_LAMBDA) {
+ /* multitexture, lambda */
+ GLuint u;
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ const GLfloat ds = span->texStep[u][0];
+ const GLfloat dt = span->texStep[u][1];
+ const GLfloat dr = span->texStep[u][2];
+ const GLfloat dq = span->texStep[u][3];
+ GLfloat s = span->tex[u][0];
+ GLfloat t = span->tex[u][1];
+ GLfloat r = span->tex[u][2];
+ GLfloat q = span->tex[u][3];
+ GLuint i;
+ SW_SPAN_SET_FLAG(span->filledLambda[u]);
+ SW_SPAN_SET_FLAG(span->filledTex[u]);
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ span->texcoords[u][i][0] = s * invQ;
+ span->texcoords[u][i][1] = t * invQ;
+ span->texcoords[u][i][2] = r * invQ;
+ span->lambda[u][i] = (GLfloat)
+ (log(span->rho[u] * invQ * invQ) * 1.442695F * 0.5F);
+ s += ds;
+ t += dt;
+ r += dr;
+ q += dq;
+ }
+ }
+ }
+ span->arrayMask |= SPAN_LAMBDA;
+ }
+ else {
+ /* multitexture, no lambda */
+ GLuint u;
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ const GLfloat ds = span->texStep[u][0];
+ const GLfloat dt = span->texStep[u][1];
+ const GLfloat dr = span->texStep[u][2];
+ const GLfloat dq = span->texStep[u][3];
+ GLfloat s = span->tex[u][0];
+ GLfloat t = span->tex[u][1];
+ GLfloat r = span->tex[u][2];
+ GLfloat q = span->tex[u][3];
+ GLuint i;
+ SW_SPAN_SET_FLAG(span->filledTex[u]);
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ span->texcoords[u][i][0] = s * invQ;
+ span->texcoords[u][i][1] = t * invQ;
+ span->texcoords[u][i][2] = r * invQ;
+ s += ds;
+ t += dt;
+ r += dr;
+ q += dq;
+ }
+ }
+ }
+ }
+ }
+ else {
+#ifdef DEBUG
+ {GLint i;
+ for (i=0; i<ctx->Const.MaxTextureUnits; i++) {
+ ASSERT(span->filledTex[i] == GL_FALSE &&
+ span->filledLambda[i] == GL_FALSE);
+ }}
+#endif
+ if (span->interpMask & SPAN_LAMBDA) {
+ /* just texture unit 0, with lambda */
+ const GLfloat ds = span->texStep[0][0];
+ const GLfloat dt = span->texStep[0][1];
+ const GLfloat dr = span->texStep[0][2];
+ const GLfloat dq = span->texStep[0][3];
+ GLfloat s = span->tex[0][0];
+ GLfloat t = span->tex[0][1];
+ GLfloat r = span->tex[0][2];
+ GLfloat q = span->tex[0][3];
+ GLuint i;
+ SW_SPAN_SET_FLAG(span->filledLambda[0]);
+ SW_SPAN_SET_FLAG(span->filledTex[0]);
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ span->texcoords[0][i][0] = s * invQ;
+ span->texcoords[0][i][1] = t * invQ;
+ span->texcoords[0][i][2] = r * invQ;
+ span->lambda[0][i] = (GLfloat)
+ (log(span->rho[0] * invQ * invQ) * 1.442695F * 0.5F);
+ s += ds;
+ t += dt;
+ r += dr;
+ q += dq;
+ }
+ span->arrayMask |= SPAN_LAMBDA;
+ }
+ else {
+ /* just texture 0, witout lambda */
+ const GLfloat ds = span->texStep[0][0];
+ const GLfloat dt = span->texStep[0][1];
+ const GLfloat dr = span->texStep[0][2];
+ const GLfloat dq = span->texStep[0][3];
+ GLfloat s = span->tex[0][0];
+ GLfloat t = span->tex[0][1];
+ GLfloat r = span->tex[0][2];
+ GLfloat q = span->tex[0][3];
+ GLuint i;
+ SW_SPAN_SET_FLAG(span->filledTex[0]);
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ span->texcoords[0][i][0] = s * invQ;
+ span->texcoords[0][i][1] = t * invQ;
+ span->texcoords[0][i][2] = r * invQ;
+ s += ds;
+ t += dt;
+ r += dr;
+ q += dq;
+ }
+ }
+ }
}
@@ -82,6 +427,7 @@ old_stipple_polygon_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
}
}
+
/*
* Apply the current polygon stipple pattern to a span of pixels.
*/
@@ -91,8 +437,6 @@ stipple_polygon_span( GLcontext *ctx, struct sw_span *span)
const GLuint highbit = 0x80000000;
GLuint i, m, stipple;
- ASSERT (span->filledMask == GL_TRUE);
-
stipple = ctx->PolygonStipple[span->y % 32];
m = highbit >> (GLuint) (span->x % 32);
@@ -162,8 +506,6 @@ clip_span( GLcontext *ctx, struct sw_span *span)
{
GLint x = span->x, y = span->y, n = span->end;
- ASSERT (span->filledMask == GL_TRUE);
-
/* Clip to top and bottom */
if (y < 0 || y >= ctx->DrawBuffer->Height) {
span->end = 0;
@@ -323,267 +665,19 @@ 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: n - number of pixels in the span
- * x, y - location of leftmost pixel in the span
- * z - array of [n] z-values
- * fog - array of fog factor values in [0,1]
- * index - array of [n] color indexes
- * primitive - either GL_POINT, GL_LINE, GL_POLYGON, or GL_BITMAP
- */
-void
-_old_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];
- GLuint indexBackup[MAX_WIDTH];
- GLuint *index; /* points to indexIn or indexBackup */
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- /* init mask to 1's (all pixels are to be written) */
- MEMSET(mask, 1, n);
-
- if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
- if ((n = old_clip_span(ctx,n,x,y,mask)) == 0) {
- return;
- }
- }
-
- if ((primitive==GL_BITMAP && (swrast->_RasterMask & modBits))
- || (swrast->_RasterMask & MULTI_DRAW_BIT)) {
- /* Make copy of color indexes */
- MEMCPY( indexBackup, indexIn, n * sizeof(GLuint) );
- index = indexBackup;
- }
- else {
- index = indexIn;
- }
-
-
- /* Do the scissor test */
- if (ctx->Scissor.Enabled) {
- if ((n = _old_scissor_span( ctx, n, x, y, mask )) == 0) {
- return;
- }
- }
-
- /* Polygon Stippling */
- if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
- old_stipple_polygon_span( ctx, n, x, y, mask );
- }
-
- if (ctx->Stencil.Enabled) {
- /* first stencil test */
- if (_old_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) {
- return;
- }
- }
- else if (ctx->Depth.Test) {
- /* regular depth testing */
- if (_old_depth_test_span( ctx, n, x, y, z, mask ) == 0)
- return;
- }
-
- /* if we get here, something passed the depth test */
- ctx->OcclusionResult = GL_TRUE;
-
- /* Per-pixel fog */
- if (ctx->Fog.Enabled) {
- if (fog && !swrast->_PreferPixelFog)
- _old_fog_ci_pixels( ctx, n, fog, index );
- else
- _old_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 );
- }
- else {
- /* normal situation: draw to exactly one buffer */
- if (ctx->Color.IndexLogicOpEnabled) {
- _mesa_logicop_ci_span( ctx, n, x, y, index, mask );
- }
-
- if (ctx->Color.IndexMask == 0) {
- return;
- }
- else if (ctx->Color.IndexMask != 0xffffffff) {
- _mesa_mask_index_span( ctx, n, x, y, index );
- }
-
- /* write pixels */
- (*swrast->Driver.WriteCI32Span)( ctx, n, x, y, index, mask );
- }
-}
-
-
-/*
- * Apply fragment processing to a span of RGBA fragments.
- * Input:
- * n - number of fragments in the span
- * x,y - location of first (left) fragment
- * fog - array of fog factor values in [0,1]
- */
-void
-_old_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;
- GLubyte mask[MAX_WIDTH];
- GLboolean write_all = GL_TRUE;
- GLchan rgbaBackup[MAX_WIDTH][4];
- GLchan (*rgba)[4];
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- /* init mask to 1's (all pixels are to be written) */
- MEMSET(mask, 1, n);
-
- if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
- if ((n = old_clip_span( ctx,n,x,y,mask)) == 0) {
- return;
- }
- if (mask[0] == 0)
- write_all = GL_FALSE;
- }
-
- 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, rgbaIn, 4 * n * sizeof(GLchan) );
- rgba = rgbaBackup;
- }
- else {
- rgba = rgbaIn;
- }
-
- /* Do the scissor test */
- if (ctx->Scissor.Enabled) {
- if ((n = _old_scissor_span( ctx, n, x, y, mask )) == 0) {
- return;
- }
- if (mask[0] == 0)
- write_all = GL_FALSE;
- }
-
- /* Polygon Stippling */
- if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
- old_stipple_polygon_span( ctx, n, x, y, mask );
- write_all = GL_FALSE;
- }
-
- /* Do the alpha test */
- if (ctx->Color.AlphaEnabled) {
- if (_old_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
- return;
- }
- write_all = GL_FALSE;
- }
-
- if (ctx->Stencil.Enabled) {
- /* first stencil test */
- if (_old_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) {
- return;
- }
- write_all = GL_FALSE;
- }
- else if (ctx->Depth.Test) {
- /* regular depth testing */
- GLuint m = _old_depth_test_span( ctx, n, x, y, z, mask );
- if (m == 0) {
- return;
- }
- if (m < n) {
- write_all = GL_FALSE;
- }
- }
-
- /* if we get here, something passed the depth test */
- ctx->OcclusionResult = GL_TRUE;
-
- /* Per-pixel fog */
- if (ctx->Fog.Enabled) {
- if (fog && !swrast->_PreferPixelFog)
- _old_fog_rgba_pixels( ctx, n, fog, rgba );
- else
- _old_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 );
- }
- 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, n, x, y, rgba, mask );
- }
- else if (ctx->Color.BlendEnabled) {
- _mesa_blend_span( ctx, n, x, y, rgba, mask );
- }
-
- /* Color component masking */
- if (colorMask == 0x0) {
- return;
- }
- else if (colorMask != 0xffffffff) {
- _mesa_mask_rgba_span( ctx, n, x, y, rgba );
- }
-
- /* write pixels */
- (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y,
- (const GLchan (*)[4]) rgba,
- write_all ? ((const GLubyte *) NULL) : mask );
-
- if (swrast->_RasterMask & ALPHABUF_BIT) {
- _mesa_write_alpha_span( ctx, n, x, y,
- (const GLchan (*)[4]) rgba,
- write_all ? ((const GLubyte *) NULL) : mask );
- }
- }
-}
-
-
-/*
- * 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
*/
void
-_mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[MAX_WIDTH], GLenum primitive)
+_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 indexIn or indexBackup */
+ GLuint *index; /* points to span->color.index or indexBackup */
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLuint origArrayMask = span->arrayMask;
-
- SET_MASK_TO_ONE(span);
+ MEMSET(span->mask, 1, span->end);
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx,span) == GL_FALSE) {
@@ -616,38 +710,23 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
/* I have to think where to put this!! */
- if (span->activeMask & SPAN_Z) {
- SW_SPAN_SET_FLAG(span->filledDepth);
-
- if (ctx->Visual.depthBits <= 16) {
- GLuint i;
- GLfixed zval = span->z;
- for (i = 0; i < span->end; i++) {
- span->depth[i] = FixedToInt(zval);
- zval += span->zStep;
- }
- }
- else {
- /* Deep Z buffer, no fixed->int shift */
- GLuint i;
- GLfixed zval = span->z;
- for (i = 0; i < span->end; i++) {
- span->depth[i] = zval;
- zval += span->zStep;
- }
- }
- }
+ 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)
+ 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)
+ if (_mesa_depth_test_span(ctx, span) == 0) {
+ span->arrayMask = origArrayMask;
return;
+ }
}
/* if we get here, something passed the depth test */
@@ -655,28 +734,30 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
if (ctx->Color.DrawBuffer == GL_NONE) {
/* write no pixels */
+ span->arrayMask = origArrayMask;
return;
}
+ if (span->interpMask & SPAN_INDEX)
+ interpolate_indexes(ctx, span);
+
if (ctx->Fog.Enabled) {
- if (fog != NULL && !swrast->_PreferPixelFog)
- _mesa_fog_ci_pixels_with_array( ctx, span, fog, index);
- else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
- _mesa_fog_ci_pixels( ctx, span, index);
- else
- _mesa_depth_fog_ci_pixels( ctx, span, index);
+ if ((span->arrayMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ _mesa_fog_ci_pixels_with_array( ctx, span, span->fogArray, index);
+ else if ((span->interpMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ _mesa_fog_ci_pixels( ctx, span, index);
+ else
+ _mesa_depth_fog_ci_pixels( ctx, span, index);
}
/* Antialias coverage application */
-#if 0
- if (span->coverage) {
- GLuint i;
- for (i = 0; i < span->end; i++) {
- ASSERT(span->coverage[i] < 16);
- index[i] = (index[i] & ~0xf) | span->coverage[i];
- }
+ if (span->arrayMask & SPAN_COVERAGE) {
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ ASSERT(span->coverage[i] < 16);
+ index[i] = (index[i] & ~0xf) | ((GLuint) (span->coverage[i]));
+ }
}
-#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */
@@ -701,148 +782,8 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
(*swrast->Driver.WriteCI32Span)( ctx, span->end, span->x,
span->y, index, span->mask );
}
-}
-
-
-
-
-void
-_mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
- GLuint index, GLenum primitive )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint i;
-
-
- SET_MASK_TO_ONE(span);
-
- 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);
- }
-
-
- /* I have to think where to put this!! */
- if (span->activeMask & SPAN_Z) {
- SW_SPAN_SET_FLAG(span->filledDepth);
-
- if (ctx->Visual.depthBits <= 16) {
- GLuint i;
- GLfixed zval = span->z;
- for (i = 0; i < span->end; i++) {
- span->depth[i] = FixedToInt(zval);
- zval += span->zStep;
- }
- }
- else {
- /* Deep Z buffer, no fixed->int shift */
- GLuint i;
- GLfixed zval = span->z;
- for (i = 0; i < span->end; i++) {
- span->depth[i] = zval;
- zval += span->zStep;
- }
- }
- }
-
- 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->Fog.Enabled
- || ctx->Color.IndexLogicOpEnabled
- || ctx->Color.IndexMask != 0xffffffff
-#if 0
- || span->coverage) {
-#else
- ) {
-#endif
- /* different index per pixel */
- GLuint indexes[MAX_WIDTH];
- for (i = 0; i < span->end; i++) {
- indexes[i] = index;
- }
-
- if (ctx->Fog.Enabled) {
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
- _mesa_fog_ci_pixels( ctx, span, indexes );
- else
- _mesa_depth_fog_ci_pixels( ctx, span, indexes );
- }
- /* Antialias coverage application */
-#if 0
- if (span->coverage) {
- GLuint i;
- for (i = 0; i < span->end; i++) {
- ASSERT(span->coverage[i] < 16);
- indexes[i] = (indexes[i] & ~0xf) | span->coverage[i];
- }
- }
-#endif
-
- 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, indexes, 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, indexes, 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, indexes );
- }
- (*swrast->Driver.WriteCI32Span)( ctx, span->end, span->x, span->y, indexes, span->mask );
- }
- }
- else {
- /* same color index for all pixels */
- ASSERT(!ctx->Color.IndexLogicOpEnabled);
- ASSERT(ctx->Color.IndexMask == 0xffffffff);
- if (swrast->_RasterMask & MULTI_DRAW_BIT) {
- /* draw to zero or two or more buffers */
- GLuint indexes[MAX_WIDTH];
- for (i = 0; i < span->end; i++)
- indexes[i] = index;
- multi_write_index_span( ctx, span->end, span->x, span->y, indexes, span->mask );
- }
- else {
- /* normal situation: draw to exactly one buffer */
- (*swrast->Driver.WriteMonoCISpan)( ctx, span->end, span->x, span->y, index, span->mask );
- }
- }
+ span->arrayMask = origArrayMask;
}
@@ -853,16 +794,16 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
*/
void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[MAX_WIDTH], 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);
+ const GLuint origArrayMask = span->arrayMask;
-
- SET_MASK_TO_ONE(span);
+ MEMSET(span->mask, 1, span->end);
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span( ctx,span ) == GL_FALSE) {
@@ -870,7 +811,6 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
}
}
-
/* Do the scissor test */
if (ctx->Scissor.Enabled) {
if (_mesa_scissor_span( ctx, span ) == GL_FALSE) {
@@ -878,12 +818,14 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
}
}
-
/* Polygon Stippling */
if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
stipple_polygon_span( ctx, span);
}
+ 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)) {
@@ -895,23 +837,25 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
rgba = span->color.rgba;
}
-
/* Do the alpha test */
if (ctx->Color.AlphaEnabled) {
if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba) == 0) {
+ span->arrayMask = origArrayMask;
return;
}
}
/* I have to think where to put this!! */
- if (span->activeMask & SPAN_Z) {
- SW_SPAN_SET_FLAG(span->filledDepth);
+ if (span->interpMask & SPAN_Z) {
+#ifdef DEBUG
+ span->filledDepth = GL_TRUE;
+#endif
if (ctx->Visual.depthBits <= 16) {
GLuint i;
GLfixed zval = span->z;
for (i = 0; i < span->end; i++) {
- span->depth[i] = FixedToInt(zval);
+ span->zArray[i] = FixedToInt(zval);
zval += span->zStep;
}
}
@@ -920,21 +864,26 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
GLuint i;
GLfixed zval = span->z;
for (i = 0; i < span->end; i++) {
- span->depth[i] = zval;
+ span->zArray[i] = zval;
zval += span->zStep;
}
}
+ span->arrayMask |= SPAN_Z;
}
if (ctx->Stencil.Enabled) {
/* first stencil test */
- if (_mesa_stencil_and_ztest_span(ctx, span) == GL_FALSE)
+ 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) == GL_FALSE)
+ if (_mesa_depth_test_span(ctx, span) == GL_FALSE) {
+ span->arrayMask = origArrayMask;
return;
+ }
}
/* if we get here, something passed the depth test */
@@ -942,23 +891,21 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog != NULL && !swrast->_PreferPixelFog)
- _mesa_fog_rgba_pixels_with_array( ctx, span, fog, rgba);
- else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ 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 );
else
_mesa_depth_fog_rgba_pixels( ctx, span, rgba );
}
/* Antialias coverage application */
-#if 0
- if (span->coverage) {
+ if (span->arrayMask & SPAN_COVERAGE) {
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
}
}
-#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, span->mask );
@@ -977,6 +924,7 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Color component masking */
if (colorMask == 0x0) {
+ span->arrayMask = origArrayMask;
return;
}
else if (colorMask != 0xffffffff) {
@@ -994,6 +942,8 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
+
+ span->arrayMask = origArrayMask;
}
@@ -1013,8 +963,7 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
GLchan rgba[MAX_WIDTH][4];
SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- SET_MASK_TO_ONE(span);
+ MEMSET(span->mask, 1, span->end);
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx,span) == GL_FALSE) {
@@ -1046,14 +995,14 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
}
/* I have to think where to put this!! */
- if (span->activeMask & SPAN_Z) {
+ if (span->interpMask & SPAN_Z) {
SW_SPAN_SET_FLAG(span->filledDepth);
if (ctx->Visual.depthBits <= 16) {
GLuint i;
GLfixed zval = span->z;
for (i = 0; i < span->end; i++) {
- span->depth[i] = FixedToInt(zval);
+ span->zArray[i] = FixedToInt(zval);
zval += span->zStep;
}
}
@@ -1062,10 +1011,11 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
GLuint i;
GLfixed zval = span->z;
for (i = 0; i < span->end; i++) {
- span->depth[i] = zval;
+ span->zArray[i] = zval;
zval += span->zStep;
}
}
+ span->arrayMask |= SPAN_Z;
}
if (ctx->Stencil.Enabled) {
@@ -1087,12 +1037,10 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
return;
}
- if (ctx->Color.ColorLogicOpEnabled || colorMask != 0xffffffff ||
-#if 0
- (swrast->_RasterMask & (BLEND_BIT | FOG_BIT)) || coverage) {
-#else
- (swrast->_RasterMask & (BLEND_BIT | FOG_BIT))) {
-#endif
+ 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++) {
@@ -1103,21 +1051,19 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ 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 0
- if (span->coverage) {
+ if (span->arrayMask & SPAN_COVERAGE) {
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
}
}
-#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y,
@@ -1126,10 +1072,12 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
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 );
+ _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 );
+ _mesa_blend_span( ctx, span->end, span->x, span->y,
+ rgba, span->mask );
}
/* Color component masking */
@@ -1142,12 +1090,12 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
- (const GLchan (*)[4]) rgba,
- span->writeAll ? ((const GLubyte *) NULL) : span->mask );
+ (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]) rgba,
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
@@ -1167,11 +1115,12 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
(const GLchan (*)[4]) rgba, span->mask );
}
else {
- (*swrast->Driver.WriteMonoRGBASpan)( ctx, span->end, span->x, span->y, color, span->mask );
+ (*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 );
+ (GLchan) color[ACOMP],
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
@@ -1181,25 +1130,26 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/*
* 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
+ * or GL_COLOR_SUM_EXT is enabled.
*/
static void
add_colors(CONST struct sw_span *span, GLchan rgba[][4])
{
GLuint i;
- ASSERT(span->filledSpecular == GL_TRUE);
- ASSERT(span->filledColor == GL_TRUE);
+ assert(span->arrayMask & SPAN_RGBA);
+ assert(span->arrayMask & SPAN_SPEC);
for (i = 0; i < span->end; i++) {
#if CHAN_TYPE == GL_FLOAT
/* no clamping */
- rgba[i][RCOMP] += span->specular[i][RCOMP];
- rgba[i][GCOMP] += span->specular[i][GCOMP];
- rgba[i][BCOMP] += span->specular[i][BCOMP];
+ rgba[i][RCOMP] += span->specArray[i][RCOMP];
+ rgba[i][GCOMP] += span->specArray[i][GCOMP];
+ rgba[i][BCOMP] += span->specArray[i][BCOMP];
#else
- GLint r = rgba[i][RCOMP] + span->specular[i][RCOMP];
- GLint g = rgba[i][GCOMP] + span->specular[i][GCOMP];
- GLint b = rgba[i][BCOMP] + span->specular[i][BCOMP];
+ GLint r = rgba[i][RCOMP] + span->specArray[i][RCOMP];
+ GLint g = rgba[i][GCOMP] + span->specArray[i][GCOMP];
+ GLint b = rgba[i][BCOMP] + span->specArray[i][BCOMP];
rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
@@ -1219,14 +1169,14 @@ add_colors(CONST struct sw_span *span, GLchan rgba[][4])
*/
void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[MAX_WIDTH], GLenum primitive )
+ GLenum primitive )
{
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
GLchan rgbaBackup[MAX_WIDTH][4];
GLchan (*rgba)[4]; /* points to either rgbaIn or rgbaBackup */
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- SET_MASK_TO_ONE(span);
+ MEMSET(span->mask, 1, span->end);
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx,span) == GL_FALSE) {
@@ -1292,17 +1242,18 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
/* Add base and specular colors */
- if ((span->activeMask & SPAN_SPEC) && /* Is this right test ???*/
+ if ((span->arrayMask & SPAN_SPEC) && /* Is this right test ???*/
(ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)))
- add_colors(span, rgba); /* rgba = rgba + spec */
-
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR))) {
+ add_colors(span, rgba); /* rgba = rgba + span->spec */
+ }
+
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog != NULL && !swrast->_PreferPixelFog)
- _mesa_fog_rgba_pixels_with_array( ctx, span, fog, rgba);
- else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ 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 );
else
_mesa_depth_fog_rgba_pixels(ctx, span, rgba);
@@ -1310,14 +1261,12 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
/* Antialias coverage application */
-#if 0
- if (span->coverage) {
+ if (span->arrayMask & SPAN_COVERAGE) {
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
}
}
-#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, span->mask );
@@ -1416,30 +1365,28 @@ masked_texture_span( GLcontext *ctx, struct sw_span *span)
/* Add base and specular colors */
- if ((span->activeMask & SPAN_SPEC) && /* Is this right test ???*/
+ if ((span->interpMask & SPAN_SPEC) && /* Is this right test ???*/
(ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)))
- add_colors(span, rgba); /* rgba = rgba + spec */
+ add_colors(span, rgba); /* rgba = rgba + span->spec */
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ 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 0
- if (span->coverage) {
+ if (span->arrayMask & SPAN_COVERAGE) {
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
}
}
-#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, span->mask );
@@ -1526,30 +1473,28 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
/* Add base and specular colors */
- if ((span->activeMask & SPAN_SPEC) && /* Is this right test ???*/
+ if ((span->interpMask & SPAN_SPEC) && /* Is this right test ???*/
(ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)))
- add_colors(span, rgba); /* rgba = rgba + spec */
+ add_colors(span, rgba); /* rgba = rgba + span->spec */
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ 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 0
- if (span->coverage) {
+ if (span->arrayMask & SPAN_COVERAGE) {
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * span->coverage[i]);
}
}
-#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y,
@@ -1597,8 +1542,7 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- SET_MASK_TO_ONE(span);
-
+ MEMSET(span->mask, 1, span->end);
if (swrast->_RasterMask & WINCLIP_BIT) {
if (clip_span(ctx, span) == GL_FALSE) {
@@ -1619,14 +1563,14 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
}
/* I have to think where to put this!! */
- if (span->activeMask & SPAN_Z) {
+ if (span->interpMask & SPAN_Z) {
SW_SPAN_SET_FLAG(span->filledDepth);
if (ctx->Visual.depthBits <= 16) {
GLuint i;
GLfixed zval = span->z;
for (i = 0; i < span->end; i++) {
- span->depth[i] = FixedToInt(zval);
+ span->zArray[i] = FixedToInt(zval);
zval += span->zStep;
}
}
@@ -1635,17 +1579,18 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
GLuint i;
GLfixed zval = span->z;
for (i = 0; i < span->end; i++) {
- span->depth[i] = zval;
+ span->zArray[i] = zval;
zval += span->zStep;
}
}
+ span->arrayMask |= SPAN_Z;
}
/* Correct order: texturing --> alpha test --> depth test. But if
no alpha test needed, we can do here the depth test and
potentially avoid some of the texturing (otherwise alpha test,
depth test etc. happens in masked_texture_span(). */
- if (span->activeMask & SPAN_Z && !ctx->Color.AlphaEnabled) {
+ if (span->interpMask & SPAN_Z && !ctx->Color.AlphaEnabled) {
if (ctx->Stencil.Enabled) {
/* first stencil test */
if (_mesa_stencil_and_ztest_span(ctx, span) == GL_FALSE)
@@ -1659,229 +1604,20 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
}
}
- if (span->activeMask & SPAN_RGBA) {
- SW_SPAN_SET_FLAG(span->filledColor);
- SW_SPAN_SET_FLAG(span->filledAlpha);
- if (span->activeMask & SPAN_FLAT) {
- GLuint i;
- GLchan color[4];
- color[RCOMP] = FixedToChan(span->red);
- color[GCOMP] = FixedToChan(span->green);
- color[BCOMP] = FixedToChan(span->blue);
- color[ACOMP] = FixedToChan(span->alpha);
- for (i = 0; i < span->end; i++) {
- COPY_CHAN4(span->color.rgba[i], color);
- }
- }
- else {
- /* smooth interpolation */
-#if CHAN_TYPE == GL_FLOAT
- GLfloat r = span->red;
- GLfloat g = span->green;
- GLfloat b = span->blue;
- GLfloat a = span->alpha;
-#else
- GLfixed r = span->red;
- GLfixed g = span->green;
- GLfixed b = span->blue;
- GLfixed a = span->alpha;
-#endif
- GLuint i;
- for (i = 0; i < span->end; i++) {
- span->color.rgba[i][RCOMP] = FixedToChan(r);
- span->color.rgba[i][GCOMP] = FixedToChan(g);
- span->color.rgba[i][BCOMP] = FixedToChan(b);
- span->color.rgba[i][ACOMP] = FixedToChan(a);
- r += span->redStep;
- g += span->greenStep;
- b += span->blueStep;
- a += span->alphaStep;
- }
- }
- }
+ if (span->interpMask & SPAN_RGBA)
+ interpolate_colors(ctx, span);
- if (span->activeMask & SPAN_SPEC) {
- SW_SPAN_SET_FLAG(span->filledSpecular);
- if (span->activeMask & SPAN_FLAT) {
- const GLchan r = FixedToChan(span->specRed);
- const GLchan g = FixedToChan(span->specGreen);
- const GLchan b = FixedToChan(span->specBlue);
- GLuint i;
- for (i = 0; i < span->end; i++) {
- span->specular[i][RCOMP] = r;
- span->specular[i][GCOMP] = g;
- span->specular[i][BCOMP] = b;
- }
- }
- else {
- /* smooth interpolation */
-#if CHAN_TYPE == GL_FLOAT
- GLfloat r = span->specRed;
- GLfloat g = span->specGreen;
- GLfloat b = span->specBlue;
-#else
- GLfixed r = span->specRed;
- GLfixed g = span->specGreen;
- GLfixed b = span->specBlue;
-#endif
- GLuint i;
- for (i = 0; i < span->end; i++) {
- span->specular[i][RCOMP] = FixedToChan(r);
- span->specular[i][GCOMP] = FixedToChan(g);
- span->specular[i][BCOMP] = FixedToChan(b);
- r += span->specRedStep;
- g += span->specGreenStep;
- b += span->specBlueStep;
- }
- }
- }
+ if (span->interpMask & SPAN_SPEC)
+ interpolate_specular(ctx, span);
- if (span->activeMask & SPAN_INDEX) {
- SW_SPAN_SET_FLAG(span->filledColor);
- if (span->activeMask & SPAN_FLAT) {
- GLuint i;
- const GLint indx = FixedToInt(span->index);
- for (i = 0; i < span->end; i++) {
- span->color.index[i] = indx;
- }
- }
- else {
- /* smooth interpolation */
- GLuint i;
- GLfixed ind = span->index;
- for (i = 0; i < span->end; i++) {
- span->color.index[i] = FixedToInt(ind);
- ind += span->indexStep;
- }
- }
- }
+ if (span->interpMask & SPAN_INDEX)
+ interpolate_indexes(ctx, span);
- if (span->activeMask & SPAN_TEXTURE) {
- if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
- /* multitexture */
- if (span->activeMask & SPAN_LAMBDA) {
- /* with lambda */
- GLuint u;
- /* multitexture, lambda */
- for (u = 0; u < MAX_TEXTURE_UNITS; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- GLfloat s = span->tex[u][0];
- GLfloat t = span->tex[u][1];
- GLfloat r = span->tex[u][2];
- GLfloat q = span->tex[u][3];
- GLuint i;
- SW_SPAN_SET_FLAG(span->filledLambda[u]);
- SW_SPAN_SET_FLAG(span->filledTex[u]);
- for (i = 0; i < span->end; i++) {
- const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
- span->texcoords[u][i][0] = s * invQ;
- span->texcoords[u][i][1] = t * invQ;
- span->texcoords[u][i][2] = r * invQ;
- span->lambda[u][i] = (GLfloat)
- (log(span->rho[u] * invQ * invQ) * 1.442695F * 0.5F);
- s += span->texStep[u][0];
- t += span->texStep[u][1];
- r += span->texStep[u][2];
- q += span->texStep[u][3];
- }
- }
- }
- }
- else {
- /* without lambda */
- GLuint u;
- /* multitexture, no lambda */
- for (u = 0; u < MAX_TEXTURE_UNITS; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- GLfloat s = span->tex[u][0];
- GLfloat t = span->tex[u][1];
- GLfloat r = span->tex[u][2];
- GLfloat q = span->tex[u][3];
- GLuint i;
- SW_SPAN_SET_FLAG(span->filledTex[u]);
- for (i = 0; i < span->end; i++) {
- const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
- span->texcoords[u][i][0] = s * invQ;
- span->texcoords[u][i][1] = t * invQ;
- span->texcoords[u][i][2] = r * invQ;
- s += span->texStep[u][0];
- t += span->texStep[u][1];
- r += span->texStep[u][2];
- q += span->texStep[u][3];
- }
- }
- }
- }
- }
- else {
- /* just texture unit 0 */
-#ifdef DEBUG
- {GLint i;
- for (i=0; i<MAX_TEXTURE_UNITS; i++) {
- ASSERT(span->filledTex[i] == GL_FALSE &&
- span->filledLambda[i] == GL_FALSE);
- }}
-#endif
- if (span->activeMask & SPAN_LAMBDA) {
- /* with lambda */
- GLfloat s = span->tex[0][0];
- GLfloat t = span->tex[0][1];
- GLfloat r = span->tex[0][2];
- GLfloat q = span->tex[0][3];
- GLuint i;
- SW_SPAN_SET_FLAG(span->filledLambda[0]);
- SW_SPAN_SET_FLAG(span->filledTex[0]);
- /* single texture, lambda */
- for (i = 0; i < span->end; i++) {
- const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
- span->texcoords[0][i][0] = s * invQ;
- span->texcoords[0][i][1] = t * invQ;
- span->texcoords[0][i][2] = r * invQ;
- span->lambda[0][i] = (GLfloat)
- (log(span->rho[0] * invQ * invQ) * 1.442695F * 0.5F);
- s += span->texStep[0][0];
- t += span->texStep[0][1];
- r += span->texStep[0][2];
- q += span->texStep[0][3];
- }
- }
- else {
- /* without lambda */
- GLfloat s = span->tex[0][0];
- GLfloat t = span->tex[0][1];
- GLfloat r = span->tex[0][2];
- GLfloat q = span->tex[0][3];
- GLuint i;
- SW_SPAN_SET_FLAG(span->filledTex[0]);
- /* single texture, no lambda */
- for (i = 0; i < span->end; i++) {
- const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
- span->texcoords[0][i][0] = s * invQ;
- span->texcoords[0][i][1] = t * invQ;
- span->texcoords[0][i][2] = r * invQ;
- s += span->texStep[0][0];
- t += span->texStep[0][1];
- r += span->texStep[0][2];
- q += span->texStep[0][3];
- }
- }
- }
- }
- /* XXX keep this? */
- if (span->activeMask & SPAN_INT_TEXTURE) {
- GLfixed s = span->intTex[0];
- GLfixed t = span->intTex[1];
- GLuint i;
- for (i = 0; i < span->end; i++) {
- span->itexcoords[i][0] = FixedToInt(s);
- span->itexcoords[i][1] = FixedToInt(t);
- s += span->intTexStep[0];
- t += span->intTexStep[1];
- }
- }
-
- /* examine activeMask and call a s_span.c function */
- if (span->activeMask & SPAN_TEXTURE) {
+ if (span->interpMask & SPAN_TEXTURE)
+ interpolate_texcoords(ctx, span);
+
+ /* examine interpMask and call a s_span.c function */
+ if (span->interpMask & SPAN_TEXTURE) {
if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
/* multi texture */
@@ -1925,166 +1661,6 @@ _old_add_colors(GLuint n, GLchan rgba[][4], GLchan specular[][4] )
/*
- * Write a horizontal span of textured pixels to the frame buffer.
- * The color of each pixel is different.
- * Alpha-testing, stenciling, depth-testing, and blending are done
- * as needed.
- * Input: n - number of pixels in the span
- * x, y - location of leftmost pixel in the span
- * z - array of [n] z-values
- * fog - array of fog factor values in [0,1]
- * s, t - array of (s,t) texture coordinates for each pixel
- * lambda - array of texture lambda values
- * rgba - array of [n] color components
- * primitive - either GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP.
- */
-void
-_old_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLdepth z[], const GLfloat fog[],
- GLfloat texcoord[][4],
- GLfloat lambda[],
- GLchan rgbaIn[][4], GLchan spec[][4],
- const GLfloat coverage[], GLenum primitive )
-{
- const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
- GLubyte mask[MAX_WIDTH];
- GLboolean write_all = GL_TRUE;
- GLchan rgbaBackup[MAX_WIDTH][4];
- GLchan (*rgba)[4]; /* points to either rgbaIn or rgbaBackup */
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- /* init mask to 1's (all pixels are to be written) */
- MEMSET(mask, 1, n);
-
- if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
- if ((n=old_clip_span(ctx, n, x, y, mask)) == 0) {
- return;
- }
- if (mask[0] == 0)
- write_all = GL_FALSE;
- }
-
-
- if (primitive==GL_BITMAP || (swrast->_RasterMask & MULTI_DRAW_BIT)) {
- /* must make a copy of the colors since they may be modified */
- MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLchan));
- rgba = rgbaBackup;
- }
- else {
- rgba = rgbaIn;
- }
-
- /* Do the scissor test */
- if (ctx->Scissor.Enabled) {
- if ((n = _old_scissor_span( ctx, n, x, y, mask )) == 0) {
- return;
- }
- if (mask[0] == 0)
- write_all = GL_FALSE;
- }
-
- /* Polygon Stippling */
- if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
- old_stipple_polygon_span( ctx, n, x, y, mask );
- write_all = GL_FALSE;
- }
-
- /* Texture with alpha test */
- if (ctx->Color.AlphaEnabled) {
- /* Texturing without alpha is done after depth-testing which
- gives a potential speed-up. */
- ASSERT(ctx->Texture._ReallyEnabled);
- _old_swrast_texture_fragments( ctx, 0, n, texcoord, lambda,
- (CONST GLchan (*)[4]) rgba, rgba );
-
- /* Do the alpha test */
- if (_old_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
- return;
- }
- write_all = GL_FALSE;
- }
-
- if (ctx->Stencil.Enabled) {
- /* first stencil test */
- if (_old_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) {
- return;
- }
- write_all = GL_FALSE;
- }
- else if (ctx->Depth.Test) {
- /* regular depth testing */
- GLuint m = _old_depth_test_span( ctx, n, x, y, z, mask );
- if (m == 0) {
- return;
- }
- if (m < n) {
- write_all = GL_FALSE;
- }
- }
-
- /* if we get here, something passed the depth test */
- ctx->OcclusionResult = GL_TRUE;
-
- /* Texture without alpha test */
- if (! ctx->Color.AlphaEnabled) {
- ASSERT(ctx->Texture._ReallyEnabled);
- _old_swrast_texture_fragments( ctx, 0, n, texcoord, lambda,
- (CONST GLchan (*)[4]) rgba, rgba );
- }
-
- /* Add base and specular colors */
- if (spec &&
- (ctx->Fog.ColorSumEnabled ||
- (ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)))
- _old_add_colors( n, rgba, spec ); /* rgba = rgba + spec */
-
- /* Per-pixel fog */
- if (ctx->Fog.Enabled) {
- if (fog && !swrast->_PreferPixelFog)
- _old_fog_rgba_pixels( ctx, n, fog, rgba );
- else
- _old_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 );
- }
- else {
- /* normal: write to exactly one buffer */
- if (ctx->Color.ColorLogicOpEnabled) {
- _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask );
- }
- else if (ctx->Color.BlendEnabled) {
- _mesa_blend_span( ctx, n, x, y, rgba, mask );
- }
- if (colorMask == 0x0) {
- return;
- }
- else if (colorMask != 0xffffffff) {
- _mesa_mask_rgba_span( ctx, n, x, y, rgba );
- }
-
- (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba,
- write_all ? ((const GLubyte *) NULL) : mask );
- if (swrast->_RasterMask & ALPHABUF_BIT) {
- _mesa_write_alpha_span( ctx, n, x, y, (const GLchan (*)[4]) rgba,
- write_all ? ((const GLubyte *) NULL) : mask );
- }
- }
-}
-
-
-
-/*
* As above but perform multiple stages of texture application.
*/
void
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index ce67c6c761..f6d03caf83 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.11 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_span.h,v 1.12 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,36 +34,30 @@
extern void
-_old_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLdepth z[], const GLfloat fog[],
- GLuint index[], const GLint coverage[],
- GLenum primitive );
+_mesa_span_default_z( GLcontext *ctx, struct sw_span *span );
extern void
-_old_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 );
+_mesa_span_default_fog( GLcontext *ctx, struct sw_span *span );
+
+extern void
+_mesa_span_default_color( GLcontext *ctx, struct sw_span *span );
-void
-_mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[MAX_WIDTH], GLenum primitive);
extern void
-_mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
- GLuint index, GLenum primitive );
+_mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
+ GLenum primitive);
extern void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[MAX_WIDTH], GLenum primitive);
+ GLenum primitive);
extern void
_mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
- const GLchan color[4], GLenum primitive );
+ const GLchan color[4], GLenum primitive );
extern void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[MAX_WIDTH], GLenum primitive );
+ GLenum primitive );
extern void
@@ -71,14 +65,6 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span);
extern void
-_old_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLdepth z[], const GLfloat fog[],
- GLfloat texcoord[][4], GLfloat lambda[],
- GLchan rgba[][4], GLchan spec[][4],
- const GLfloat coverage[], GLenum primitive );
-
-
-extern void
_old_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], const GLfloat fog[],
GLfloat texcoord[MAX_TEXTURE_UNITS][MAX_WIDTH][4],
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 6e69fc8d70..3effec2af3 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.15 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.16 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -559,10 +559,11 @@ _mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
ASSERT(ctx->Stencil.Enabled);
ASSERT(span->end <= MAX_WIDTH);
- ASSERT(span->filledMask == GL_TRUE);
- ASSERT(span->filledDepth == GL_TRUE);
- SW_SPAN_SET_FLAG(span->testedDepth);
-
+#ifdef DEBUG
+ if (ctx->Depth.Test) {
+ ASSERT((span->filledDepth == GL_TRUE) || (span->arrayMask & SPAN_Z));
+ }
+#endif
/* Get initial stencil values */
if (swrast->Driver.WriteStencilSpan) {
@@ -578,7 +579,7 @@ _mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
/* do all the stencil/depth testing/updating */
result = stencil_and_ztest_span( ctx, span->end, span->x, span->y,
- span->depth, stencil, span->mask );
+ span->zArray, stencil, span->mask );
if (swrast->Driver.WriteStencilSpan) {
/* Write updated stencil values into hardware stencil buffer */
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index f47f8e011c..5663d1d560 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.45 2002/01/10 16:54:29 brianp Exp $ */
+/* $Id: s_texture.c,v 1.46 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1032,19 +1032,27 @@ sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
texcoords[i][0], texcoords[i][1], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_2d_nearest_mipmap_nearest(ctx, tObj, texcoords[i][0], texcoords[i][1],
+ sample_2d_nearest_mipmap_nearest(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
lambda[i], rgba[i]);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_2d_linear_mipmap_nearest(ctx,tObj, texcoords[i][0], texcoords[i][1],
+ sample_2d_linear_mipmap_nearest(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
lambda[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_2d_nearest_mipmap_linear(ctx,tObj, texcoords[i][0], texcoords[i][1],
+ sample_2d_nearest_mipmap_linear(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
lambda[i], rgba[i]);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_2d_linear_mipmap_linear(ctx,tObj, texcoords[i][0], texcoords[i][1],
+ sample_2d_linear_mipmap_linear(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
lambda[i], rgba[i] );
break;
default:
@@ -1393,7 +1401,9 @@ sample_nearest_3d(GLcontext *ctx, GLuint texUnit,
struct gl_texture_image *image = tObj->Image[tObj->BaseLevel];
(void) lambda;
for (i=0;i<n;i++) {
- sample_3d_nearest(ctx, tObj, image, texcoords[i][0], texcoords[i][1], texcoords[i][2], rgba[i]);
+ sample_3d_nearest(ctx, tObj, image,
+ texcoords[i][0], texcoords[i][1], texcoords[i][2],
+ rgba[i]);
}
}
@@ -1409,7 +1419,9 @@ sample_linear_3d( GLcontext *ctx, GLuint texUnit,
struct gl_texture_image *image = tObj->Image[tObj->BaseLevel];
(void) lambda;
for (i=0;i<n;i++) {
- sample_3d_linear(ctx, tObj, image, texcoords[i][0], texcoords[i][1], texcoords[i][2], rgba[i]);
+ sample_3d_linear(ctx, tObj, image,
+ texcoords[i][0], texcoords[i][1], texcoords[i][2],
+ rgba[i]);
}
}
@@ -1434,26 +1446,40 @@ sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
switch (tObj->MinFilter) {
case GL_NEAREST:
sample_3d_nearest(ctx, tObj, tObj->Image[tObj->BaseLevel],
- texcoords[i][0], texcoords[i][1], texcoords[i][2], rgba[i]);
+ texcoords[i][0], texcoords[i][1],
+ texcoords[i][2], rgba[i]);
break;
case GL_LINEAR:
sample_3d_linear(ctx, tObj, tObj->Image[tObj->BaseLevel],
- texcoords[i][0], texcoords[i][1], texcoords[i][2], rgba[i]);
+ texcoords[i][0], texcoords[i][1],
+ texcoords[i][2], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_3d_nearest_mipmap_nearest(ctx, tObj, texcoords[i][0], texcoords[i][1], texcoords[i][2],
+ sample_3d_nearest_mipmap_nearest(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
+ texcoords[i][2],
lambda[i], rgba[i]);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_3d_linear_mipmap_nearest(ctx, tObj, texcoords[i][0], texcoords[i][1], texcoords[i][2],
+ sample_3d_linear_mipmap_nearest(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
+ texcoords[i][2],
lambda[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_3d_nearest_mipmap_linear(ctx, tObj, texcoords[i][0], texcoords[i][1], texcoords[i][2],
+ sample_3d_nearest_mipmap_linear(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
+ texcoords[i][2],
lambda[i], rgba[i]);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_3d_linear_mipmap_linear(ctx, tObj, texcoords[i][0], texcoords[i][1], texcoords[i][2],
+ sample_3d_linear_mipmap_linear(ctx, tObj,
+ texcoords[i][0],
+ texcoords[i][1],
+ texcoords[i][2],
lambda[i], rgba[i]);
break;
default:
@@ -1465,11 +1491,13 @@ sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
switch (tObj->MagFilter) {
case GL_NEAREST:
sample_3d_nearest(ctx, tObj, tObj->Image[tObj->BaseLevel],
- texcoords[i][0], texcoords[i][1], texcoords[i][2], rgba[i]);
+ texcoords[i][0], texcoords[i][1],
+ texcoords[i][2], rgba[i]);
break;
case GL_LINEAR:
sample_3d_linear(ctx, tObj, tObj->Image[tObj->BaseLevel],
- texcoords[i][0], texcoords[i][1], texcoords[i][2], rgba[i]);
+ texcoords[i][0], texcoords[i][1],
+ texcoords[i][2], rgba[i]);
break;
default:
_mesa_problem(NULL, "Bad mag filter in sample_3d_texture");
@@ -3062,16 +3090,20 @@ _old_swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n,
void
_swrast_texture_fragments( GLcontext *ctx, GLuint texUnit,
struct sw_span *span,
- GLchan rgba[][4] )
+ GLchan rgbaOut[][4] )
{
const GLuint mask = TEXTURE0_ANY << (texUnit * 4);
if (ctx->Texture._ReallyEnabled & mask) {
const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit[texUnit];
- GLfloat *lambda = span->lambda[texUnit];
+ GLfloat *lambda;
+ lambda = (span->arrayMask & SPAN_LAMBDA) ? span->lambda[texUnit] : NULL;
+
+ /* XXXX
ASSERT(span->filledTex[texUnit] == GL_TRUE);
-
+ */
+
if (textureUnit->_Current) { /* XXX need this? */
const struct gl_texture_object *curObj = textureUnit->_Current;
GLchan texel[PB_SIZE][4];
@@ -3111,10 +3143,9 @@ _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit,
lambda, texel );
}
apply_texture( ctx, textureUnit, span->end,
- (CONST GLchan (*)[4])span->color.rgba,
- (CONST GLchan (*)[4]) texel, rgba );
+ (CONST GLchan (*)[4]) span->color.rgba,
+ (CONST GLchan (*)[4]) texel,
+ rgbaOut );
}
}
}
-
-
diff --git a/src/mesa/swrast/s_texture.h b/src/mesa/swrast/s_texture.h
index c85e7faf3f..aa86c0fa04 100644
--- a/src/mesa/swrast/s_texture.h
+++ b/src/mesa/swrast/s_texture.h
@@ -1,4 +1,4 @@
-/* $Id: s_texture.h,v 1.8 2002/01/10 16:54:29 brianp Exp $ */
+/* $Id: s_texture.h,v 1.9 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,7 +47,7 @@ _swrast_texture_fragments( GLcontext *ctx, GLuint texSet,
extern void
_old_swrast_texture_fragments( GLcontext *ctx, GLuint texSet, GLuint n,
GLfloat texcoords[][4], GLfloat lambda[],
- CONST GLchan primary_rgba[][4], GLchan rgba[][4] );
-
+ CONST GLchan primary_rgba[][4],
+ GLchan rgba[][4] );
#endif
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 06d1c31308..fc82485874 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.48 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.49 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -80,8 +80,13 @@ static void flat_ci_triangle( GLcontext *ctx,
#define INTERP_Z 1
#define INTERP_FOG 1
-#define RENDER_SPAN( span ) \
- _mesa_write_monoindex_span(ctx, &span, v2->index, GL_POLYGON );
+#define SETUP_CODE \
+ span.interpMask |= SPAN_INDEX; \
+ span.index = IntToFixed(v2->index); \
+ span.indexStep = 0;
+
+#define RENDER_SPAN( span ) \
+ _mesa_write_index_span(ctx, &span, GL_POLYGON );
#include "s_tritemp.h"
}
@@ -107,7 +112,7 @@ static void smooth_ci_triangle( GLcontext *ctx,
span.color.index[i] = FixedToInt(span.index); \
span.index += span.indexStep; \
} \
- _mesa_write_index_span(ctx, &span, NULL, GL_POLYGON);
+ _mesa_write_index_span(ctx, &span, GL_POLYGON);
#include "s_tritemp.h"
}
@@ -156,6 +161,8 @@ static void smooth_rgba_triangle( GLcontext *ctx,
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); \
@@ -166,7 +173,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
span.blue += span.blueStep; \
span.alpha += span.alphaStep; \
} \
- _mesa_write_rgba_span(ctx, &span, NULL, GL_POLYGON);
+ _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
#include "s_tritemp.h"
@@ -267,6 +274,7 @@ static void simple_z_textured_triangle( GLcontext *ctx,
span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
span.intTex[1] -= FIXED_HALF; \
SW_SPAN_SET_FLAG(span.filledColor); \
+ SW_SPAN_SET_FLAG(span.filledDepth); \
for (i = 0; i < span.end; i++) { \
const GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -460,6 +468,7 @@ affine_span(GLcontext *ctx, struct sw_span *span,
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;
@@ -555,7 +564,9 @@ affine_span(GLcontext *ctx, struct sw_span *span,
}
break;
}
- _mesa_write_rgba_span(ctx, span, NULL, GL_POLYGON);
+ ASSERT(span->interpMask & SPAN_RGBA);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ _mesa_write_rgba_span(ctx, span, GL_POLYGON);
#undef SPAN_NEAREST
#undef SPAN_LINEAR
@@ -594,6 +605,7 @@ static void affine_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) */ \
@@ -726,6 +738,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
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);
@@ -827,7 +840,9 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
break;
}
- _mesa_write_rgba_span(ctx, span, NULL, GL_POLYGON);
+ ASSERT(span->interpMask & SPAN_RGBA);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ _mesa_write_rgba_span(ctx, span, GL_POLYGON);
#undef SPAN_NEAREST
@@ -865,6 +880,7 @@ 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) */ \
@@ -939,10 +955,11 @@ static void general_textured_triangle( GLcontext *ctx,
SW_SPAN_SET_FLAG(span.filledColor); \
SW_SPAN_SET_FLAG(span.filledAlpha); \
SW_SPAN_SET_FLAG(span.filledTex[0]); \
+ SW_SPAN_SET_FLAG(span.filledDepth); \
/* NOTE: we could just call rasterize_span() here instead */ \
for (i = 0; i < span.end; i++) { \
GLdouble invQ = span.tex[0][3] ? (1.0 / span.tex[0][3]) : 1.0; \
- span.depth[i] = FixedToDepth(span.z); \
+ span.zArray[i] = FixedToDepth(span.z); \
span.z += span.zStep; \
span.color.rgba[i][RCOMP] = FixedToChan(span.red); \
span.color.rgba[i][GCOMP] = FixedToChan(span.green); \
@@ -960,7 +977,7 @@ static void general_textured_triangle( GLcontext *ctx,
span.tex[0][2] += span.texStep[0][2]; \
span.tex[0][3] += span.texStep[0][3]; \
} \
- _mesa_write_texture_span( ctx, &span, NULL, GL_POLYGON );
+ _mesa_write_texture_span( ctx, &span, GL_POLYGON );
#include "s_tritemp.h"
}
@@ -1204,11 +1221,11 @@ void _swrast_add_spec_terms_triangle( GLcontext *ctx,
/* record the current triangle function name */
const char *_mesa_triFuncName = NULL;
-#define USE(triFunc) \
-do { \
- _mesa_triFuncName = #triFunc; \
- /*printf("%s\n", triFuncName);*/ \
- swrast->Triangle = triFunc; \
+#define USE(triFunc) \
+do { \
+ _mesa_triFuncName = #triFunc; \
+ /*printf("%s\n", _mesa_triFuncName);*/ \
+ swrast->Triangle = triFunc; \
} while (0)
#else
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 488cd7e58b..fe2caad1bd 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_tritemp.h,v 1.30 2001/12/17 04:58:50 brianp Exp $ */
+/* $Id: s_tritemp.h,v 1.31 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -122,6 +122,8 @@
struct sw_span span;
+ INIT_SPAN(span);
+
#ifdef INTERP_Z
(void) fixedToDepthShift;
#endif
@@ -340,11 +342,10 @@
scan_from_left_to_right = (oneOverArea < 0.0F);
- span.activeMask = 0;
/* compute d?/dx and d?/dy derivatives */
#ifdef INTERP_Z
- span.activeMask |= SPAN_Z;
+ span.interpMask |= SPAN_Z;
{
GLfloat eMaj_dz, eBot_dz;
eMaj_dz = vMax->win[2] - vMin->win[2];
@@ -365,7 +366,7 @@
}
#endif
#ifdef INTERP_FOG
- span.activeMask |= SPAN_FOG;
+ span.interpMask |= SPAN_FOG;
{
const GLfloat eMaj_dfog = vMax->fog - vMin->fog;
const GLfloat eBot_dfog = vMid->fog - vMin->fog;
@@ -374,7 +375,7 @@
}
#endif
#ifdef INTERP_RGB
- span.activeMask |= SPAN_RGBA;
+ span.interpMask |= SPAN_RGBA;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dr, eBot_dr;
GLfloat eMaj_dg, eBot_dg;
@@ -415,7 +416,7 @@
}
else {
ASSERT (ctx->Light.ShadeModel == GL_FLAT);
- span.activeMask |= SPAN_FLAT;
+ span.interpMask |= SPAN_FLAT;
drdx = drdy = 0.0F;
dgdx = dgdy = 0.0F;
dbdx = dbdy = 0.0F;
@@ -429,7 +430,7 @@
}
#endif
#ifdef INTERP_FLOAT_RGBA
- span.activeMask |= SPAN_RGBA;
+ span.interpMask |= SPAN_RGBA;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dr, eBot_dr;
GLfloat eMaj_dg, eBot_dg;
@@ -464,7 +465,7 @@
}
#endif
#ifdef INTERP_SPEC
- span.activeMask |= SPAN_SPEC;
+ span.interpMask |= SPAN_SPEC;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dsr, eBot_dsr;
GLfloat eMaj_dsg, eBot_dsg;
@@ -501,7 +502,7 @@
}
#endif
#ifdef INTERP_FLOAT_SPEC
- span.activeMask |= SPAN_SPEC;
+ span.interpMask |= SPAN_SPEC;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dsr, eBot_dsr;
GLfloat eMaj_dsg, eBot_dsg;
@@ -529,7 +530,7 @@
}
#endif
#ifdef INTERP_INDEX
- span.activeMask |= SPAN_INDEX;
+ span.interpMask |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_di, eBot_di;
eMaj_di = (GLfloat) ((GLint) vMax->index - (GLint) vMin->index);
@@ -539,13 +540,13 @@
didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
}
else {
- span.activeMask |= SPAN_FLAT;
+ span.interpMask |= SPAN_FLAT;
didx = didy = 0.0F;
span.indexStep = 0;
}
#endif
#ifdef INTERP_INT_TEX
- span.activeMask |= SPAN_INT_TEXTURE;
+ span.interpMask |= SPAN_INT_TEXTURE;
{
GLfloat eMaj_ds, eBot_ds;
eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
@@ -565,7 +566,7 @@
#endif
#ifdef INTERP_TEX
- span.activeMask |= SPAN_TEXTURE;
+ span.interpMask |= SPAN_TEXTURE;
{
GLfloat wMax = vMax->win[3];
GLfloat wMin = vMin->win[3];
@@ -608,14 +609,14 @@
GLfloat r1 = dudx * dudx + dudy * dudy;
GLfloat r2 = dvdx * dvdx + dvdy * dvdy;
span.rho[0] = r1 + r2; /* was rho2 = MAX2(r1,r2) */
- span.activeMask |= SPAN_LAMBDA;
+ span.interpMask |= SPAN_LAMBDA;
}
# endif
#endif
#ifdef INTERP_MULTITEX
- span.activeMask |= SPAN_TEXTURE;
+ span.interpMask |= SPAN_TEXTURE;
# ifdef INTERP_LAMBDA
- span.activeMask |= SPAN_LAMBDA;
+ span.interpMask |= SPAN_LAMBDA;
# endif
{
GLfloat wMax = vMax->win[3];
@@ -1143,6 +1144,7 @@
/* 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);
diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c
index 26567fa3c8..4fba332890 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.8 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: s_zoom.c,v 1.9 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -51,7 +51,7 @@
(span).color.rgba[i][BCOMP]) { \
fprintf(stderr, "glZoom: Color-span changed in subfunction."); \
} \
- if (tmp_span.depth[i] != (span).depth[i]) { \
+ if (tmp_span.zArray[i] != (span).zArray[i]) { \
fprintf(stderr, "glZoom: Depth-span changed in subfunction."); \
} \
} \
@@ -83,28 +83,28 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
{
GLint r0, r1, row;
GLint i, j;
- struct sw_span dstspan;
- GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */
+ struct sw_span zoomed;
const GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
- SW_SPAN_RESET (dstspan);
+ SW_SPAN_RESET (zoomed);
+ INIT_SPAN(zoomed);
/* compute width of output row */
- dstspan.end = (GLint) ABSF( n * ctx->Pixel.ZoomX );
- if (dstspan.end == 0) {
+ zoomed.end = (GLint) ABSF( n * ctx->Pixel.ZoomX );
+ if (zoomed.end == 0) {
return;
}
/*here ok or better latter? like it was before */
- else if (dstspan.end > maxwidth) {
- dstspan.end = maxwidth;
+ else if (zoomed.end > maxwidth) {
+ zoomed.end = maxwidth;
}
if (ctx->Pixel.ZoomX<0.0) {
/* adjust x coordinate for left/right mirroring */
- dstspan.x = x - dstspan.end;
+ zoomed.x = x - zoomed.end;
}
else
- dstspan.x = x;
+ zoomed.x = x;
/* compute which rows to draw */
@@ -131,8 +131,8 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
}
/* check if left edge is outside window */
- if (dstspan.x < 0) {
- dstspan.start = -x;
+ if (zoomed.x < 0) {
+ zoomed.start = -x;
}
/* make sure span isn't too long or short */
@@ -140,56 +140,61 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
m = maxwidth;
}*/
- if (dstspan.end <= dstspan.start) {
+ if (zoomed.end <= zoomed.start) {
return;
}
- ASSERT( dstspan.end <= MAX_WIDTH );
+ ASSERT( zoomed.end <= MAX_WIDTH );
/* zoom the span horizontally */
if (ctx->Pixel.ZoomX==-1.0F) {
- SW_SPAN_SET_FLAG(dstspan.filledColor);
- SW_SPAN_SET_FLAG(dstspan.filledAlpha);
- SW_SPAN_SET_FLAG(dstspan.filledDepth);
+ SW_SPAN_SET_FLAG(zoomed.filledColor);
+ SW_SPAN_SET_FLAG(zoomed.filledAlpha);
+ SW_SPAN_SET_FLAG(zoomed.filledDepth);
/* n==m */
- for (j=dstspan.start; j<dstspan.end; j++) {
+ for (j=zoomed.start; j<zoomed.end; j++) {
i = n - j - 1;
- COPY_CHAN4(dstspan.color.rgba[j], rgba[i]);
- dstspan.depth[j] = z[i];
+ COPY_CHAN4(zoomed.color.rgba[j], rgba[i]);
+ zoomed.zArray[j] = z[i];
}
if (fog && ctx->Fog.Enabled) {
- for (j=dstspan.start; j<dstspan.end; j++) {
+ for (j=zoomed.start; j<zoomed.end; j++) {
i = n - j - 1;
- zfog[j] = fog[i];
+ zoomed.fogArray[j] = fog[i];
}
}
}
else {
const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
- SW_SPAN_SET_FLAG(dstspan.filledColor);
- SW_SPAN_SET_FLAG(dstspan.filledAlpha);
- SW_SPAN_SET_FLAG(dstspan.filledDepth);
- for (j=dstspan.start; j<dstspan.end; j++) {
+ SW_SPAN_SET_FLAG(zoomed.filledColor);
+ SW_SPAN_SET_FLAG(zoomed.filledAlpha);
+ SW_SPAN_SET_FLAG(zoomed.filledDepth);
+ for (j=zoomed.start; j<zoomed.end; j++) {
i = (GLint) (j * xscale);
if (i<0) i = n + i - 1;
- COPY_CHAN4(dstspan.color.rgba[j], rgba[i]);
- dstspan.depth[j] = z[i];
+ COPY_CHAN4(zoomed.color.rgba[j], rgba[i]);
+ zoomed.zArray[j] = z[i];
}
if (fog && ctx->Fog.Enabled) {
- for (j=dstspan.start; j<dstspan.end; j++) {
+ for (j=zoomed.start; j<zoomed.end; j++) {
i = (GLint) (j * xscale);
if (i<0) i = n + i - 1;
- zfog[j] = fog[i];
+ zoomed.fogArray[j] = fog[i];
}
}
}
+ zoomed.arrayMask |= SPAN_Z;
+ if (fog)
+ zoomed.arrayMask |= SPAN_FOG;
+
/* write the span */
- for (dstspan.y = r0; dstspan.y < r1; dstspan.y++) {
- SAVE_SPAN(dstspan);
- _mesa_write_rgba_span(ctx, &dstspan, (fog ? zfog : NULL), GL_BITMAP);
- RESTORE_SPAN(dstspan);
- /* problem here: "dstspan" can change inside
+ for (zoomed.y = r0; zoomed.y < r1; zoomed.y++) {
+ SAVE_SPAN(zoomed);
+ ASSERT((zoomed.interpMask & SPAN_RGBA) == 0);
+ _mesa_write_rgba_span(ctx, &zoomed, GL_BITMAP);
+ RESTORE_SPAN(zoomed);
+ /* problem here: "zoomed" can change inside
"_mesa_write_rgba_span". Best solution: make copy "tmpspan"
and give to function, but too slow */
}
@@ -206,10 +211,15 @@ _mesa_write_zoomed_rgb_span( GLcontext *ctx,
GLint m;
GLint r0, r1, row, r;
GLint i, j, skipcol;
- GLchan zrgba[MAX_WIDTH][4]; /* zoomed pixel colors */
- GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */
- GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */
GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+ struct sw_span zoomed;
+
+ INIT_SPAN(zoomed);
+ zoomed.arrayMask |= SPAN_RGBA;
+
+ if (fog && ctx->Fog.Enabled)
+ zoomed.arrayMask |= SPAN_FOG;
+
/* compute width of output row */
m = (GLint) ABSF( n * ctx->Pixel.ZoomX );
@@ -265,16 +275,16 @@ _mesa_write_zoomed_rgb_span( GLcontext *ctx,
/* n==m */
for (j=0;j<m;j++) {
i = n - (j+skipcol) - 1;
- zrgba[j][0] = rgb[i][0];
- zrgba[j][1] = rgb[i][1];
- zrgba[j][2] = rgb[i][2];
- zrgba[j][3] = CHAN_MAX;
- zdepth[j] = z[i];
+ zoomed.color.rgba[j][0] = rgb[i][0];
+ zoomed.color.rgba[j][1] = rgb[i][1];
+ zoomed.color.rgba[j][2] = rgb[i][2];
+ zoomed.color.rgba[j][3] = CHAN_MAX;
+ zoomed.zArray[j] = z[i];
}
- if (fog && ctx->Fog.Enabled) {
+ if (zoomed.arrayMask & SPAN_FOG) {
for (j=0;j<m;j++) {
i = n - (j+skipcol) - 1;
- zfog[j] = fog[i];
+ zoomed.fogArray[j] = fog[i];
}
}
}
@@ -283,25 +293,28 @@ _mesa_write_zoomed_rgb_span( GLcontext *ctx,
for (j=0;j<m;j++) {
i = (GLint) ((j+skipcol) * xscale);
if (i<0) i = n + i - 1;
- zrgba[j][0] = rgb[i][0];
- zrgba[j][1] = rgb[i][1];
- zrgba[j][2] = rgb[i][2];
- zrgba[j][3] = CHAN_MAX;
- zdepth[j] = z[i];
+ zoomed.color.rgba[j][0] = rgb[i][0];
+ zoomed.color.rgba[j][1] = rgb[i][1];
+ zoomed.color.rgba[j][2] = rgb[i][2];
+ zoomed.color.rgba[j][3] = CHAN_MAX;
+ zoomed.zArray[j] = z[i];
}
- if (fog && ctx->Fog.Enabled) {
+ if (zoomed.arrayMask & SPAN_FOG) {
for (j=0;j<m;j++) {
i = (GLint) ((j+skipcol) * xscale);
if (i<0) i = n + i - 1;
- zfog[j] = fog[i];
+ zoomed.fogArray[j] = fog[i];
}
}
}
/* write the span */
for (r=r0; r<r1; r++) {
- _old_write_rgba_span( ctx, m, x+skipcol, r, zdepth,
- (fog ? zfog : 0), zrgba, NULL, GL_BITMAP );
+ zoomed.x = x + skipcol;
+ zoomed.y = r;
+ zoomed.end = m;
+ ASSERT((zoomed.interpMask & SPAN_RGBA) == 0);
+ _mesa_write_rgba_span( ctx, &zoomed, GL_BITMAP );
}
}
@@ -319,10 +332,12 @@ _mesa_write_zoomed_index_span( GLcontext *ctx,
GLint m;
GLint r0, r1, row, r;
GLint i, j, skipcol;
- GLuint zindexes[MAX_WIDTH]; /* zoomed color indexes */
- GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */
- GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */
GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+ struct sw_span zoomed;
+
+ SW_SPAN_RESET(zoomed);
+ INIT_SPAN(zoomed);
+ zoomed.arrayMask |= SPAN_INDEX;
/* compute width of output row */
m = (GLint) ABSF( n * ctx->Pixel.ZoomX );
@@ -378,14 +393,15 @@ _mesa_write_zoomed_index_span( GLcontext *ctx,
/* n==m */
for (j=0;j<m;j++) {
i = n - (j+skipcol) - 1;
- zindexes[j] = indexes[i];
- zdepth[j] = z[i];
+ zoomed.color.index[j] = indexes[i];
+ zoomed.zArray[j] = z[i];
}
if (fog && ctx->Fog.Enabled) {
for (j=0;j<m;j++) {
i = n - (j+skipcol) - 1;
- zfog[j] = fog[i];
+ zoomed.fogArray[j] = fog[i];
}
+ zoomed.arrayMask |= SPAN_FOG;
}
}
else {
@@ -393,22 +409,30 @@ _mesa_write_zoomed_index_span( GLcontext *ctx,
for (j=0;j<m;j++) {
i = (GLint) ((j+skipcol) * xscale);
if (i<0) i = n + i - 1;
- zindexes[j] = indexes[i];
- zdepth[j] = z[i];
+ zoomed.color.index[j] = indexes[i];
+ zoomed.zArray[j] = z[i];
}
if (fog && ctx->Fog.Enabled) {
for (j=0;j<m;j++) {
i = (GLint) ((j+skipcol) * xscale);
if (i<0) i = n + i - 1;
- zfog[j] = fog[i];
+ zoomed.fogArray[j] = fog[i];
}
+ zoomed.arrayMask |= SPAN_FOG;
}
}
+ zoomed.arrayMask |= SPAN_Z;
+
/* write the span */
for (r=r0; r<r1; r++) {
- _old_write_index_span( ctx, m, x+skipcol, r, zdepth,
- (fog ? zfog : 0), zindexes, NULL, GL_BITMAP );
+ SAVE_SPAN(zoomed);
+ ASSERT((zoomed.interpMask & SPAN_INDEX) == 0);
+ zoomed.x = x + skipcol;
+ zoomed.y = r;
+ zoomed.end = m;
+ _mesa_write_index_span(ctx, &zoomed, GL_BITMAP);
+ RESTORE_SPAN(zoomed);
}
}
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 5ee58bfcf1..c65631b1c5 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,4 +1,4 @@
-/* $Id: swrast.h,v 1.15 2002/01/21 18:12:34 brianp Exp $ */
+/* $Id: swrast.h,v 1.16 2002/01/27 18:32:03 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -92,7 +92,8 @@ typedef struct {
#define SPAN_TEXTURE 0x020
#define SPAN_INT_TEXTURE 0x040
#define SPAN_LAMBDA 0x080
-#define SPAN_FLAT 0x100 /* flat shading? */
+#define SPAN_COVERAGE 0x100
+#define SPAN_FLAT 0x200 /* flat shading? */
struct sw_span {
@@ -104,7 +105,10 @@ struct sw_span {
/* This flag indicates that only a part of the span is visible */
GLboolean writeAll;
- GLuint activeMask; /* OR of the SPAN_* flags */
+ /* This bitmask (bitwise-or of SPAN_* flags) indicates which of the
+ * x/xStep variables are relevant.
+ */
+ GLuint interpMask;
#if CHAN_TYPE == GL_FLOAT
GLfloat red, redStep;
@@ -132,39 +136,52 @@ struct sw_span {
GLfloat rho[MAX_TEXTURE_UNITS];
GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS];
+ /* This bitmask (bitwise-or of SPAN_* flags) indicates which of the
+ * fragment arrays are relevant.
+ */
+ GLuint arrayMask;
+
/**
* Arrays of fragment values. These will either be computed from the
* x/xStep values above or loadd from glDrawPixels, etc.
*/
- GLdepth depth[MAX_WIDTH];
union {
GLchan rgb[MAX_WIDTH][3];
GLchan rgba[MAX_WIDTH][4];
GLuint index[MAX_WIDTH];
} color;
- GLchan specular[MAX_WIDTH][4];
- GLint itexcoords[MAX_WIDTH][2]; /* Integer texture (s, t) */
+ GLchan specArray[MAX_WIDTH][4];
+ GLdepth zArray[MAX_WIDTH];
+ GLfloat fogArray[MAX_WIDTH];
/* Texture (s,t,r). 4th component only used for pixel texture */
GLfloat texcoords[MAX_TEXTURE_UNITS][MAX_WIDTH][4];
GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
GLfloat coverage[MAX_WIDTH];
+
+ /* This mask indicates if fragment is alive or culled */
GLubyte mask[MAX_WIDTH];
#ifdef DEBUG
- GLboolean filledDepth, filledMask, filledAlpha;
+ GLboolean filledDepth, filledAlpha;
GLboolean filledColor, filledSpecular;
GLboolean filledLambda[MAX_TEXTURE_UNITS], filledTex[MAX_TEXTURE_UNITS];
- GLboolean testedDepth, testedAlpha;
#endif
};
+#define INIT_SPAN(S) \
+do { \
+ S.interpMask = 0; \
+ S.arrayMask = 0; \
+ S.start = S.end = 0; \
+} while (0)
+
+
#ifdef DEBUG
#define SW_SPAN_SET_FLAG(flag) {ASSERT((flag) == GL_FALSE);(flag) = GL_TRUE;}
#define SW_SPAN_RESET(span) { \
- (span).filledDepth = (span).filledMask = (span).filledAlpha \
- = (span).filledColor = (span).filledSpecular \
- = (span).testedDepth = (span).testedAlpha = GL_FALSE; \
+ (span).filledDepth = (span).filledAlpha \
+ = (span).filledColor = (span).filledSpecular = GL_FALSE; \
MEMSET((span).filledTex, GL_FALSE, \
MAX_TEXTURE_UNITS*sizeof(GLboolean)); \
MEMSET((span).filledLambda, GL_FALSE, \