summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_linetemp.h
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-05-20 12:27:39 -0600
committerBrian <brian@yutani.localnet.net>2007-05-20 12:27:39 -0600
commit9e8a961dd7d7b717a9fb4ecdea1c1b60ea355efe (patch)
tree60c87644ec38f4693ceecbf440b120b02e2d07e6 /src/mesa/swrast/s_linetemp.h
parentaa133a9dae53bc6aa50b88ee43deb8b34e8d0029 (diff)
Overhaul/simplify SWvertex and SWspan attribute handling.
Instead of separate fog/specular/texcoord/varying code, just treat all of them as generic attributes. Simplifies the point/line/triangle functions.
Diffstat (limited to 'src/mesa/swrast/s_linetemp.h')
-rw-r--r--src/mesa/swrast/s_linetemp.h128
1 files changed, 57 insertions, 71 deletions
diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h
index b6e8f287f4..55548f27b0 100644
--- a/src/mesa/swrast/s_linetemp.h
+++ b/src/mesa/swrast/s_linetemp.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.0
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
@@ -31,9 +31,7 @@
* The following macros may be defined to indicate what auxillary information
* must be interplated along the line:
* INTERP_Z - if defined, interpolate Z values
- * INTERP_FOG - if defined, interpolate FOG values
* INTERP_RGBA - if defined, interpolate RGBA values
- * INTERP_SPEC - if defined, interpolate specular RGB values
* INTERP_INDEX - if defined, interpolate color index values
* INTERP_ATTRIBS - if defined, interpolate attribs (texcoords, varying, etc)
*
@@ -72,10 +70,10 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
SWspan span;
GLuint interpFlags = 0;
- GLint x0 = (GLint) vert0->win[0];
- GLint x1 = (GLint) vert1->win[0];
- GLint y0 = (GLint) vert0->win[1];
- GLint y1 = (GLint) vert1->win[1];
+ GLint x0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][0];
+ GLint x1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][0];
+ GLint y0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][1];
+ GLint y1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][1];
GLint dx, dy;
GLint numPixels;
GLint xstep, ystep;
@@ -104,8 +102,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
/* Cull primitives with malformed coordinates.
*/
{
- GLfloat tmp = vert0->win[0] + vert0->win[1]
- + vert1->win[0] + vert1->win[1];
+ GLfloat tmp = vert0->attrib[FRAG_ATTRIB_WPOS][0] + vert0->attrib[FRAG_ATTRIB_WPOS][1]
+ + vert1->attrib[FRAG_ATTRIB_WPOS][0] + vert1->attrib[FRAG_ATTRIB_WPOS][1];
if (IS_INF_OR_NAN(tmp))
return;
}
@@ -113,8 +111,12 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
/*
printf("%s():\n", __FUNCTION__);
printf(" (%f, %f, %f) -> (%f, %f, %f)\n",
- vert0->win[0], vert0->win[1], vert0->win[2],
- vert1->win[0], vert1->win[1], vert1->win[2]);
+ vert0->attrib[FRAG_ATTRIB_WPOS][0],
+ vert0->attrib[FRAG_ATTRIB_WPOS][1],
+ vert0->attrib[FRAG_ATTRIB_WPOS][2],
+ vert1->attrib[FRAG_ATTRIB_WPOS][0],
+ vert1->attrib[FRAG_ATTRIB_WPOS][1],
+ vert1->attrib[FRAG_ATTRIB_WPOS][2]);
printf(" (%d, %d, %d) -> (%d, %d, %d)\n",
vert0->color[0], vert0->color[1], vert0->color[2],
vert1->color[0], vert1->color[1], vert1->color[2]);
@@ -154,6 +156,18 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
if (dx == 0 && dy == 0)
return;
+ /*
+ printf("%s %d,%d %g %g %g %g %g %g %g %g\n", __FUNCTION__, dx, dy,
+ vert0->attrib[FRAG_ATTRIB_COL1][0],
+ vert0->attrib[FRAG_ATTRIB_COL1][1],
+ vert0->attrib[FRAG_ATTRIB_COL1][2],
+ vert0->attrib[FRAG_ATTRIB_COL1][3],
+ vert1->attrib[FRAG_ATTRIB_COL1][0],
+ vert1->attrib[FRAG_ATTRIB_COL1][1],
+ vert1->attrib[FRAG_ATTRIB_COL1][2],
+ vert1->attrib[FRAG_ATTRIB_COL1][3]);
+ */
+
#ifdef DEPTH_TYPE
zPtr = (DEPTH_TYPE *) zrb->GetPointer(ctx, zrb, x0, y0);
#endif
@@ -232,33 +246,15 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
span.alphaStep = 0;
}
#endif
-#ifdef INTERP_SPEC
- interpFlags |= SPAN_SPEC;
- if (ctx->Light.ShadeModel == GL_SMOOTH) {
- span.specRed = ChanToFixed(vert0->specular[0]);
- span.specGreen = ChanToFixed(vert0->specular[1]);
- span.specBlue = ChanToFixed(vert0->specular[2]);
- span.specRedStep = (ChanToFixed(vert1->specular[0]) - span.specRed) / numPixels;
- span.specGreenStep = (ChanToFixed(vert1->specular[1]) - span.specBlue) / numPixels;
- span.specBlueStep = (ChanToFixed(vert1->specular[2]) - span.specGreen) / numPixels;
- }
- else {
- span.specRed = ChanToFixed(vert1->specular[0]);
- span.specGreen = ChanToFixed(vert1->specular[1]);
- span.specBlue = ChanToFixed(vert1->specular[2]);
- span.specRedStep = 0;
- span.specGreenStep = 0;
- span.specBlueStep = 0;
- }
-#endif
#ifdef INTERP_INDEX
interpFlags |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- span.index = FloatToFixed(vert0->index);
- span.indexStep = FloatToFixed(vert1->index - vert0->index) / numPixels;
+ span.index = FloatToFixed(vert0->attrib[FRAG_ATTRIB_CI][0]);
+ span.indexStep = FloatToFixed( vert1->attrib[FRAG_ATTRIB_CI][0]
+ - vert0->attrib[FRAG_ATTRIB_CI][0]) / numPixels;
}
else {
- span.index = FloatToFixed(vert1->index);
+ span.index = FloatToFixed(vert1->attrib[FRAG_ATTRIB_CI][0]);
span.indexStep = 0;
}
#endif
@@ -266,57 +262,49 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
interpFlags |= SPAN_Z;
{
if (depthBits <= 16) {
- span.z = FloatToFixed(vert0->win[2]) + FIXED_HALF;
- span.zStep = FloatToFixed(vert1->win[2] - vert0->win[2]) / numPixels;
+ span.z = FloatToFixed(vert0->attrib[FRAG_ATTRIB_WPOS][2]) + FIXED_HALF;
+ span.zStep = FloatToFixed( vert1->attrib[FRAG_ATTRIB_WPOS][2]
+ - vert0->attrib[FRAG_ATTRIB_WPOS][2]) / numPixels;
}
else {
/* don't use fixed point */
- span.z = (GLuint) vert0->win[2];
- span.zStep = (GLint) ((vert1->win[2] - vert0->win[2]) / numPixels);
+ span.z = (GLuint) vert0->attrib[FRAG_ATTRIB_WPOS][2];
+ span.zStep = (GLint) (( vert1->attrib[FRAG_ATTRIB_WPOS][2]
+ - vert0->attrib[FRAG_ATTRIB_WPOS][2]) / numPixels);
}
}
#endif
-#ifdef INTERP_FOG
- interpFlags |= SPAN_FOG;
- span.attrStart[FRAG_ATTRIB_FOGC][0] = vert0->attrib[FRAG_ATTRIB_FOGC][0];
- span.attrStepX[FRAG_ATTRIB_FOGC][0] = (vert1->attrib[FRAG_ATTRIB_FOGC][0]
- - vert0->attrib[FRAG_ATTRIB_FOGC][0]) / numPixels;
-#endif
#if defined(INTERP_ATTRIBS)
- interpFlags |= (SPAN_TEXTURE | SPAN_VARYING);
{
const GLfloat invLen = 1.0F / numPixels;
- const GLfloat invw0 = vert0->win[3];
- const GLfloat invw1 = vert1->win[3];
+ const GLfloat invw0 = vert0->attrib[FRAG_ATTRIB_WPOS][3];
+ const GLfloat invw1 = vert1->attrib[FRAG_ATTRIB_WPOS][3];
+
+ span.attrStart[FRAG_ATTRIB_WPOS][3] = invw0;
+ span.attrStepX[FRAG_ATTRIB_WPOS][3] = (invw1 - invw0) * invLen;
+ span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0;
+
ATTRIB_LOOP_BEGIN
- GLfloat ds, dt, dr, dq;
- span.attrStart[attr][0] = invw0 * vert0->attrib[attr][0];
- span.attrStart[attr][1] = invw0 * vert0->attrib[attr][1];
- span.attrStart[attr][2] = invw0 * vert0->attrib[attr][2];
- span.attrStart[attr][3] = invw0 * vert0->attrib[attr][3];
- ds = (invw1 * vert1->attrib[attr][0]) - span.attrStart[attr][0];
- dt = (invw1 * vert1->attrib[attr][1]) - span.attrStart[attr][1];
- dr = (invw1 * vert1->attrib[attr][2]) - span.attrStart[attr][2];
- dq = (invw1 * vert1->attrib[attr][3]) - span.attrStart[attr][3];
- span.attrStepX[attr][0] = ds * invLen;
- span.attrStepX[attr][1] = dt * invLen;
- span.attrStepX[attr][2] = dr * invLen;
- span.attrStepX[attr][3] = dq * invLen;
- span.attrStepY[attr][0] = 0.0F;
- span.attrStepY[attr][1] = 0.0F;
- span.attrStepY[attr][2] = 0.0F;
- span.attrStepY[attr][3] = 0.0F;
+ if (swrast->_InterpMode[attr] == GL_FLAT) {
+ COPY_4V(span.attrStart[attr], vert1->attrib[attr]);
+ ASSIGN_4V(span.attrStepX[attr], 0.0, 0.0, 0.0, 0.0);
+ }
+ else {
+ GLuint c;
+ for (c = 0; c < 4; c++) {
+ float da;
+ span.attrStart[attr][c] = invw0 * vert0->attrib[attr][c];
+ da = (invw1 * vert1->attrib[attr][c]) - span.attrStart[attr][c];
+ span.attrStepX[attr][c] = da * invLen;
+ }
+ }
+ ASSIGN_4V(span.attrStepY[attr], 0.0, 0.0, 0.0, 0.0);
ATTRIB_LOOP_END
}
#endif
INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY);
- /* Need these for fragment prog texcoord interpolation */
- span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F;
- span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F;
- span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F;
-
/*
* Draw
*/
@@ -346,7 +334,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
#endif
- if (error<0) {
+ if (error < 0) {
error += errorInc;
}
else {
@@ -413,9 +401,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
#undef NAME
#undef INTERP_Z
-#undef INTERP_FOG
#undef INTERP_RGBA
-#undef INTERP_SPEC
#undef INTERP_ATTRIBS
#undef INTERP_INDEX
#undef PIXEL_ADDRESS