summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-02-02 11:01:01 -0700
committerBrian <brian@yutani.localnet.net>2007-02-02 11:01:01 -0700
commit9ab512ad8cf3a12f4f7f8494fa99bc9389f217db (patch)
tree4026b0a39ff5c0403372f8f396786b9b592dcc48 /src/mesa/swrast
parent462d8f5fafcc5ac69ea89cac1222abadded642e2 (diff)
Replace color, z, w, texture interpolants with new generic attrib interpolants.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_fog.c20
-rw-r--r--src/mesa/swrast/s_fragprog.c91
-rw-r--r--src/mesa/swrast/s_linetemp.h71
-rw-r--r--src/mesa/swrast/s_pointtemp.h6
-rw-r--r--src/mesa/swrast/s_span.c121
-rw-r--r--src/mesa/swrast/s_span.h26
-rw-r--r--src/mesa/swrast/s_triangle.c14
-rw-r--r--src/mesa/swrast/s_tritemp.h208
8 files changed, 280 insertions, 277 deletions
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index a2bf4c620c..433fc4a4d0 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -74,8 +74,8 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z)
do { \
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; \
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0]; \
- const GLfloat wStep = haveW ? span->dwdx : 0.0F; \
- GLfloat w = haveW ? span->w : 1.0F; \
+ const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;\
+ GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F; \
GLuint i; \
for (i = 0; i < span->end; i++) { \
GLfloat f, oneMinusF; \
@@ -295,8 +295,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0];
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
- const GLfloat wStep = haveW ? span->dwdx : 0.0F;
- GLfloat w = haveW ? span->w : 1.0F;
+ const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
+ GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f = (fogEnd - fogCoord / w) * fogScale;
@@ -312,8 +312,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
const GLfloat density = -ctx->Fog.Density;
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0];
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
- const GLfloat wStep = haveW ? span->dwdx : 0.0F;
- GLfloat w = haveW ? span->w : 1.0F;
+ const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
+ GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f = EXPF(density * fogCoord / w);
@@ -329,8 +329,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0];
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
- const GLfloat wStep = haveW ? span->dwdx : 0.0F;
- GLfloat w = haveW ? span->w : 1.0F;
+ const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
+ GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
const GLfloat coord = fogCoord / w;
@@ -370,8 +370,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
*/
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0];
GLfloat fog = span->attrStart[FRAG_ATTRIB_FOGC][0];
- const GLfloat wStep = haveW ? span->dwdx : 0.0F;
- GLfloat w = haveW ? span->w : 1.0F;
+ const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
+ GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
ASSERT(span->interpMask & SPAN_FOG);
for (i = 0; i < span->end; i++) {
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index 22483c56a6..090fd6dd97 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -261,28 +261,30 @@ fetch_vector4_deriv( GLcontext *ctx,
if (xOrY == 'X') {
src[0] = 1.0;
src[1] = 0.0;
- src[2] = span->dzdx / ctx->DrawBuffer->_DepthMaxF;
- src[3] = span->dwdx;
+ src[2] = span->attrStepX[FRAG_ATTRIB_WPOS][2]
+ / ctx->DrawBuffer->_DepthMaxF;
+ src[3] = span->attrStepX[FRAG_ATTRIB_WPOS][3];
}
else {
src[0] = 0.0;
src[1] = 1.0;
- src[2] = span->dzdy / ctx->DrawBuffer->_DepthMaxF;
- src[3] = span->dwdy;
+ src[2] = span->attrStepY[FRAG_ATTRIB_WPOS][2]
+ / ctx->DrawBuffer->_DepthMaxF;
+ src[3] = span->attrStepY[FRAG_ATTRIB_WPOS][3];
}
break;
case FRAG_ATTRIB_COL0:
if (xOrY == 'X') {
- src[0] = span->drdx * (1.0F / CHAN_MAXF);
- src[1] = span->dgdx * (1.0F / CHAN_MAXF);
- src[2] = span->dbdx * (1.0F / CHAN_MAXF);
- src[3] = span->dadx * (1.0F / CHAN_MAXF);
+ src[0] = span->attrStepX[FRAG_ATTRIB_COL0][0] * (1.0F / CHAN_MAXF);
+ src[1] = span->attrStepX[FRAG_ATTRIB_COL0][1] * (1.0F / CHAN_MAXF);
+ src[2] = span->attrStepX[FRAG_ATTRIB_COL0][2] * (1.0F / CHAN_MAXF);
+ src[3] = span->attrStepX[FRAG_ATTRIB_COL0][3] * (1.0F / CHAN_MAXF);
}
else {
- src[0] = span->drdy * (1.0F / CHAN_MAXF);
- src[1] = span->dgdy * (1.0F / CHAN_MAXF);
- src[2] = span->dbdy * (1.0F / CHAN_MAXF);
- src[3] = span->dady * (1.0F / CHAN_MAXF);
+ src[0] = span->attrStepY[FRAG_ATTRIB_COL0][0] * (1.0F / CHAN_MAXF);
+ src[1] = span->attrStepY[FRAG_ATTRIB_COL0][1] * (1.0F / CHAN_MAXF);
+ src[2] = span->attrStepY[FRAG_ATTRIB_COL0][2] * (1.0F / CHAN_MAXF);
+ src[3] = span->attrStepY[FRAG_ATTRIB_COL0][3] * (1.0F / CHAN_MAXF);
}
break;
case FRAG_ATTRIB_COL1:
@@ -322,23 +324,22 @@ fetch_vector4_deriv( GLcontext *ctx,
case FRAG_ATTRIB_TEX6:
case FRAG_ATTRIB_TEX7:
if (xOrY == 'X') {
- const GLuint u = source->Index - FRAG_ATTRIB_TEX0;
/* this is a little tricky - I think I've got it right */
- const GLfloat invQ = 1.0f / (span->tex[u][3]
- + span->texStepX[u][3] * column);
- src[0] = span->texStepX[u][0] * invQ;
- src[1] = span->texStepX[u][1] * invQ;
- src[2] = span->texStepX[u][2] * invQ;
- src[3] = span->texStepX[u][3] * invQ;
+ const GLfloat invQ = 1.0f / (span->attrStart[source->Index][3]
+ + span->attrStepX[source->Index][3] * column);
+ src[0] = span->attrStepX[source->Index][0] * invQ;
+ src[1] = span->attrStepX[source->Index][1] * invQ;
+ src[2] = span->attrStepX[source->Index][2] * invQ;
+ src[3] = span->attrStepX[source->Index][3] * invQ;
}
else {
- const GLuint u = source->Index - FRAG_ATTRIB_TEX0;
/* Tricky, as above, but in Y direction */
- const GLfloat invQ = 1.0f / (span->tex[u][3] + span->texStepY[u][3]);
- src[0] = span->texStepY[u][0] * invQ;
- src[1] = span->texStepY[u][1] * invQ;
- src[2] = span->texStepY[u][2] * invQ;
- src[3] = span->texStepY[u][3] * invQ;
+ const GLfloat invQ = 1.0f / (span->attrStart[source->Index][3]
+ + span->attrStepY[source->Index][3]);
+ src[0] = span->attrStepY[source->Index][0] * invQ;
+ src[1] = span->attrStepY[source->Index][1] * invQ;
+ src[2] = span->attrStepY[source->Index][2] * invQ;
+ src[3] = span->attrStepY[source->Index][3] * invQ;
}
break;
default:
@@ -561,29 +562,29 @@ init_machine_deriv( GLcontext *ctx,
if (xOrY == 'X') {
wpos[0] += 1.0F;
wpos[1] += 0.0F;
- wpos[2] += span->dzdx;
- wpos[3] += span->dwdx;
+ wpos[2] += span->attrStepX[FRAG_ATTRIB_WPOS][2];
+ wpos[3] += span->attrStepX[FRAG_ATTRIB_WPOS][3];
}
else {
wpos[0] += 0.0F;
wpos[1] += 1.0F;
- wpos[2] += span->dzdy;
- wpos[3] += span->dwdy;
+ wpos[2] += span->attrStepY[FRAG_ATTRIB_WPOS][2];
+ wpos[3] += span->attrStepY[FRAG_ATTRIB_WPOS][3];
}
}
if (program->Base.InputsRead & FRAG_BIT_COL0) {
GLfloat *col0 = machine->Attribs[FRAG_ATTRIB_COL0][machine->CurFrag];
if (xOrY == 'X') {
- col0[0] += span->drdx * (1.0F / CHAN_MAXF);
- col0[1] += span->dgdx * (1.0F / CHAN_MAXF);
- col0[2] += span->dbdx * (1.0F / CHAN_MAXF);
- col0[3] += span->dadx * (1.0F / CHAN_MAXF);
+ col0[0] += span->attrStepX[FRAG_ATTRIB_COL0][0] * (1.0F / CHAN_MAXF);
+ col0[1] += span->attrStepX[FRAG_ATTRIB_COL0][1] * (1.0F / CHAN_MAXF);
+ col0[2] += span->attrStepX[FRAG_ATTRIB_COL0][2] * (1.0F / CHAN_MAXF);
+ col0[3] += span->attrStepX[FRAG_ATTRIB_COL0][3] * (1.0F / CHAN_MAXF);
}
else {
- col0[0] += span->drdy * (1.0F / CHAN_MAXF);
- col0[1] += span->dgdy * (1.0F / CHAN_MAXF);
- col0[2] += span->dbdy * (1.0F / CHAN_MAXF);
- col0[3] += span->dady * (1.0F / CHAN_MAXF);
+ col0[0] += span->attrStepY[FRAG_ATTRIB_COL0][0] * (1.0F / CHAN_MAXF);
+ col0[1] += span->attrStepY[FRAG_ATTRIB_COL0][1] * (1.0F / CHAN_MAXF);
+ col0[2] += span->attrStepY[FRAG_ATTRIB_COL0][2] * (1.0F / CHAN_MAXF);
+ col0[3] += span->attrStepY[FRAG_ATTRIB_COL0][3] * (1.0F / CHAN_MAXF);
}
}
if (program->Base.InputsRead & FRAG_BIT_COL1) {
@@ -615,16 +616,16 @@ init_machine_deriv( GLcontext *ctx,
GLfloat *tex = machine->Attribs[FRAG_ATTRIB_TEX0 + u][machine->CurFrag];
/* XXX perspective-correct interpolation */
if (xOrY == 'X') {
- tex[0] += span->texStepX[u][0];
- tex[1] += span->texStepX[u][1];
- tex[2] += span->texStepX[u][2];
- tex[3] += span->texStepX[u][3];
+ tex[0] += span->attrStepX[FRAG_ATTRIB_TEX0 + u][0];
+ tex[1] += span->attrStepX[FRAG_ATTRIB_TEX0 + u][1];
+ tex[2] += span->attrStepX[FRAG_ATTRIB_TEX0 + u][2];
+ tex[3] += span->attrStepX[FRAG_ATTRIB_TEX0 + u][3];
}
else {
- tex[0] += span->texStepY[u][0];
- tex[1] += span->texStepY[u][1];
- tex[2] += span->texStepY[u][2];
- tex[3] += span->texStepY[u][3];
+ tex[0] += span->attrStepY[FRAG_ATTRIB_TEX0 + u][0];
+ tex[1] += span->attrStepY[FRAG_ATTRIB_TEX0 + u][1];
+ tex[2] += span->attrStepY[FRAG_ATTRIB_TEX0 + u][2];
+ tex[3] += span->attrStepY[FRAG_ATTRIB_TEX0 + u][3];
}
}
}
diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h
index d68868ded9..e3ca4bd0ac 100644
--- a/src/mesa/swrast/s_linetemp.h
+++ b/src/mesa/swrast/s_linetemp.h
@@ -286,22 +286,22 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
const GLfloat invw1 = vert1->win[3];
const GLfloat invLen = 1.0F / numPixels;
GLfloat ds, dt, dr, dq;
- span.tex[0][0] = invw0 * vert0->texcoord[0][0];
- span.tex[0][1] = invw0 * vert0->texcoord[0][1];
- span.tex[0][2] = invw0 * vert0->texcoord[0][2];
- span.tex[0][3] = invw0 * vert0->texcoord[0][3];
- ds = (invw1 * vert1->texcoord[0][0]) - span.tex[0][0];
- dt = (invw1 * vert1->texcoord[0][1]) - span.tex[0][1];
- dr = (invw1 * vert1->texcoord[0][2]) - span.tex[0][2];
- dq = (invw1 * vert1->texcoord[0][3]) - span.tex[0][3];
- span.texStepX[0][0] = ds * invLen;
- span.texStepX[0][1] = dt * invLen;
- span.texStepX[0][2] = dr * invLen;
- span.texStepX[0][3] = dq * invLen;
- span.texStepY[0][0] = 0.0F;
- span.texStepY[0][1] = 0.0F;
- span.texStepY[0][2] = 0.0F;
- span.texStepY[0][3] = 0.0F;
+ span.attrStart[FRAG_ATTRIB_TEX0][0] = invw0 * vert0->texcoord[0][0];
+ span.attrStart[FRAG_ATTRIB_TEX0][1] = invw0 * vert0->texcoord[0][1];
+ span.attrStart[FRAG_ATTRIB_TEX0][2] = invw0 * vert0->texcoord[0][2];
+ span.attrStart[FRAG_ATTRIB_TEX0][3] = invw0 * vert0->texcoord[0][3];
+ ds = (invw1 * vert1->texcoord[0][0]) - span.attrStart[FRAG_ATTRIB_TEX0][0];
+ dt = (invw1 * vert1->texcoord[0][1]) - span.attrStart[FRAG_ATTRIB_TEX0][1];
+ dr = (invw1 * vert1->texcoord[0][2]) - span.attrStart[FRAG_ATTRIB_TEX0][2];
+ dq = (invw1 * vert1->texcoord[0][3]) - span.attrStart[FRAG_ATTRIB_TEX0][3];
+ span.attrStepX[FRAG_ATTRIB_TEX0][0] = ds * invLen;
+ span.attrStepX[FRAG_ATTRIB_TEX0][1] = dt * invLen;
+ span.attrStepX[FRAG_ATTRIB_TEX0][2] = dr * invLen;
+ span.attrStepX[FRAG_ATTRIB_TEX0][3] = dq * invLen;
+ span.attrStepY[FRAG_ATTRIB_TEX0][0] = 0.0F;
+ span.attrStepY[FRAG_ATTRIB_TEX0][1] = 0.0F;
+ span.attrStepY[FRAG_ATTRIB_TEX0][2] = 0.0F;
+ span.attrStepY[FRAG_ATTRIB_TEX0][3] = 0.0F;
}
#endif
#ifdef INTERP_MULTITEX
@@ -311,25 +311,26 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ const GLuint attr = FRAG_ATTRIB_TEX0 + u;
const GLfloat invw0 = vert0->win[3];
const GLfloat invw1 = vert1->win[3];
GLfloat ds, dt, dr, dq;
- span.tex[u][0] = invw0 * vert0->texcoord[u][0];
- span.tex[u][1] = invw0 * vert0->texcoord[u][1];
- span.tex[u][2] = invw0 * vert0->texcoord[u][2];
- span.tex[u][3] = invw0 * vert0->texcoord[u][3];
- ds = (invw1 * vert1->texcoord[u][0]) - span.tex[u][0];
- dt = (invw1 * vert1->texcoord[u][1]) - span.tex[u][1];
- dr = (invw1 * vert1->texcoord[u][2]) - span.tex[u][2];
- dq = (invw1 * vert1->texcoord[u][3]) - span.tex[u][3];
- span.texStepX[u][0] = ds * invLen;
- span.texStepX[u][1] = dt * invLen;
- span.texStepX[u][2] = dr * invLen;
- span.texStepX[u][3] = dq * invLen;
- span.texStepY[u][0] = 0.0F;
- span.texStepY[u][1] = 0.0F;
- span.texStepY[u][2] = 0.0F;
- span.texStepY[u][3] = 0.0F;
+ span.attrStart[attr][0] = invw0 * vert0->texcoord[u][0];
+ span.attrStart[attr][1] = invw0 * vert0->texcoord[u][1];
+ span.attrStart[attr][2] = invw0 * vert0->texcoord[u][2];
+ span.attrStart[attr][3] = invw0 * vert0->texcoord[u][3];
+ ds = (invw1 * vert1->texcoord[u][0]) - span.attrStart[attr][0];
+ dt = (invw1 * vert1->texcoord[u][1]) - span.attrStart[attr][1];
+ dr = (invw1 * vert1->texcoord[u][2]) - span.attrStart[attr][2];
+ dq = (invw1 * vert1->texcoord[u][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;
}
}
}
@@ -371,9 +372,9 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY);
/* Need these for fragment prog texcoord interpolation */
- span.w = 1.0F;
- span.dwdx = 0.0F;
- span.dwdy = 0.0F;
+ 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
diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h
index f769f524a0..d211a5a3a2 100644
--- a/src/mesa/swrast/s_pointtemp.h
+++ b/src/mesa/swrast/s_pointtemp.h
@@ -143,9 +143,9 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
}
}
/* need these for fragment programs */
- span->w = 1.0F;
- span->dwdx = 0.0F;
- span->dwdy = 0.0F;
+ span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F;
+ span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F;
+ span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F;
#endif
#if FLAGS & SMOOTH
span->arrayMask |= SPAN_COVERAGE;
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 52c7501df8..ddc63594f2 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -129,22 +129,23 @@ _swrast_span_default_texcoords( GLcontext *ctx, SWspan *span )
{
GLuint i;
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+ const GLuint attr = FRAG_ATTRIB_TEX0 + i;
const GLfloat *tc = ctx->Current.RasterTexCoords[i];
if (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled) {
- COPY_4V(span->tex[i], tc);
+ COPY_4V(span->attrStart[attr], tc);
}
else if (tc[3] > 0.0F) {
/* use (s/q, t/q, r/q, 1) */
- span->tex[i][0] = tc[0] / tc[3];
- span->tex[i][1] = tc[1] / tc[3];
- span->tex[i][2] = tc[2] / tc[3];
- span->tex[i][3] = 1.0;
+ span->attrStart[attr][0] = tc[0] / tc[3];
+ span->attrStart[attr][1] = tc[1] / tc[3];
+ span->attrStart[attr][2] = tc[2] / tc[3];
+ span->attrStart[attr][3] = 1.0;
}
else {
- ASSIGN_4V(span->tex[i], 0.0F, 0.0F, 0.0F, 1.0F);
+ ASSIGN_4V(span->attrStart[attr], 0.0F, 0.0F, 0.0F, 1.0F);
}
- ASSIGN_4V(span->texStepX[i], 0.0F, 0.0F, 0.0F, 0.0F);
- ASSIGN_4V(span->texStepY[i], 0.0F, 0.0F, 0.0F, 0.0F);
+ ASSIGN_4V(span->attrStepX[attr], 0.0F, 0.0F, 0.0F, 0.0F);
+ ASSIGN_4V(span->attrStepY[attr], 0.0F, 0.0F, 0.0F, 0.0F);
}
span->interpMask |= SPAN_TEXTURE;
}
@@ -435,8 +436,8 @@ interpolate_fog(const GLcontext *ctx, SWspan *span)
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0];
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
const GLuint haveW = (span->interpMask & SPAN_W);
- const GLfloat wStep = haveW ? span->dwdx : 0.0F;
- GLfloat w = haveW ? span->w : 1.0F;
+ const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
+ GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
fog[i][0] = fogCoord / w;
@@ -549,6 +550,7 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)
/* XXX CoordUnits vs. ImageUnits */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
+ const GLuint attr = FRAG_ATTRIB_TEX0 + u;
const struct gl_texture_object *obj =ctx->Texture.Unit[u]._Current;
GLfloat texW, texH;
GLboolean needLambda;
@@ -568,23 +570,23 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)
if (needLambda) {
GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0 + u];
GLfloat *lambda = span->array->lambda[u];
- const GLfloat dsdx = span->texStepX[u][0];
- const GLfloat dsdy = span->texStepY[u][0];
- const GLfloat dtdx = span->texStepX[u][1];
- const GLfloat dtdy = span->texStepY[u][1];
- const GLfloat drdx = span->texStepX[u][2];
- const GLfloat dqdx = span->texStepX[u][3];
- const GLfloat dqdy = span->texStepY[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];
+ const GLfloat dsdx = span->attrStepX[attr][0];
+ const GLfloat dsdy = span->attrStepY[attr][0];
+ const GLfloat dtdx = span->attrStepX[attr][1];
+ const GLfloat dtdy = span->attrStepY[attr][1];
+ const GLfloat drdx = span->attrStepX[attr][2];
+ const GLfloat dqdx = span->attrStepX[attr][3];
+ const GLfloat dqdy = span->attrStepY[attr][3];
+ GLfloat s = span->attrStart[attr][0];
+ GLfloat t = span->attrStart[attr][1];
+ GLfloat r = span->attrStart[attr][2];
+ GLfloat q = span->attrStart[attr][3];
GLuint i;
if (ctx->FragmentProgram._Current
|| ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
- const GLfloat dwdx = span->dwdx;
- GLfloat w = span->w;
+ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
+ GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
@@ -622,20 +624,20 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)
else {
GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0 + u];
GLfloat *lambda = span->array->lambda[u];
- const GLfloat dsdx = span->texStepX[u][0];
- const GLfloat dtdx = span->texStepX[u][1];
- const GLfloat drdx = span->texStepX[u][2];
- const GLfloat dqdx = span->texStepX[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];
+ const GLfloat dsdx = span->attrStepX[attr][0];
+ const GLfloat dtdx = span->attrStepX[attr][1];
+ const GLfloat drdx = span->attrStepX[attr][2];
+ const GLfloat dqdx = span->attrStepX[attr][3];
+ GLfloat s = span->attrStart[attr][0];
+ GLfloat t = span->attrStart[attr][1];
+ GLfloat r = span->attrStart[attr][2];
+ GLfloat q = span->attrStart[attr][3];
GLuint i;
if (ctx->FragmentProgram._Current ||
ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
- const GLfloat dwdx = span->dwdx;
- GLfloat w = span->w;
+ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
+ GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
@@ -703,23 +705,23 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)
/* just texture unit 0, with lambda */
GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0];
GLfloat *lambda = span->array->lambda[0];
- const GLfloat dsdx = span->texStepX[0][0];
- const GLfloat dsdy = span->texStepY[0][0];
- const GLfloat dtdx = span->texStepX[0][1];
- const GLfloat dtdy = span->texStepY[0][1];
- const GLfloat drdx = span->texStepX[0][2];
- const GLfloat dqdx = span->texStepX[0][3];
- const GLfloat dqdy = span->texStepY[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];
+ const GLfloat dsdx = span->attrStepX[FRAG_ATTRIB_TEX0][0];
+ const GLfloat dsdy = span->attrStepY[FRAG_ATTRIB_TEX0][0];
+ const GLfloat dtdx = span->attrStepX[FRAG_ATTRIB_TEX0][1];
+ const GLfloat dtdy = span->attrStepY[FRAG_ATTRIB_TEX0][1];
+ const GLfloat drdx = span->attrStepX[FRAG_ATTRIB_TEX0][2];
+ const GLfloat dqdx = span->attrStepX[FRAG_ATTRIB_TEX0][3];
+ const GLfloat dqdy = span->attrStepY[FRAG_ATTRIB_TEX0][3];
+ GLfloat s = span->attrStart[FRAG_ATTRIB_TEX0][0];
+ GLfloat t = span->attrStart[FRAG_ATTRIB_TEX0][1];
+ GLfloat r = span->attrStart[FRAG_ATTRIB_TEX0][2];
+ GLfloat q = span->attrStart[FRAG_ATTRIB_TEX0][3];
GLuint i;
if (ctx->FragmentProgram._Current
|| ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
- const GLfloat dwdx = span->dwdx;
- GLfloat w = span->w;
+ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
+ GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
@@ -758,20 +760,20 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)
else {
/* just texture 0, without lambda */
GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0];
- const GLfloat dsdx = span->texStepX[0][0];
- const GLfloat dtdx = span->texStepX[0][1];
- const GLfloat drdx = span->texStepX[0][2];
- const GLfloat dqdx = span->texStepX[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];
+ const GLfloat dsdx = span->attrStepX[FRAG_ATTRIB_TEX0][0];
+ const GLfloat dtdx = span->attrStepX[FRAG_ATTRIB_TEX0][1];
+ const GLfloat drdx = span->attrStepX[FRAG_ATTRIB_TEX0][2];
+ const GLfloat dqdx = span->attrStepX[FRAG_ATTRIB_TEX0][3];
+ GLfloat s = span->attrStart[FRAG_ATTRIB_TEX0][0];
+ GLfloat t = span->attrStart[FRAG_ATTRIB_TEX0][1];
+ GLfloat r = span->attrStart[FRAG_ATTRIB_TEX0][2];
+ GLfloat q = span->attrStart[FRAG_ATTRIB_TEX0][3];
GLuint i;
if (ctx->FragmentProgram._Current
|| ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
- const GLfloat dwdx = span->dwdx;
- GLfloat w = span->w;
+ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
+ GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
@@ -840,8 +842,8 @@ interpolate_varying(GLcontext *ctx, SWspan *span)
for (j = 0; j < 4; j++) {
const GLfloat dvdx = span->attrStepX[attr][j];
GLfloat v = span->attrStart[attr][j];
- const GLfloat dwdx = span->dwdx;
- GLfloat w = span->w;
+ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
+ GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];
GLuint k;
for (k = 0; k < span->end; k++) {
GLfloat invW = 1.0f / w;
@@ -877,7 +879,8 @@ interpolate_wpos(GLcontext *ctx, SWspan *span)
}
for (i = 0; i < span->end; i++) {
wpos[i][2] = (GLfloat) span->array->z[i] / ctx->DrawBuffer->_DepthMaxF;
- wpos[i][3] = span->w + i * span->dwdx;
+ wpos[i][3] = span->attrStart[FRAG_ATTRIB_WPOS][3]
+ + i * span->attrStepX[FRAG_ATTRIB_WPOS][3];
}
}
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index f60d4279e1..26ef399df3 100644
--- a/src/mesa/swrast/s_span.h
+++ b/src/mesa/swrast/s_span.h
@@ -127,6 +127,7 @@ typedef struct sw_span_arrays
*/
typedef struct sw_span
{
+ /** Coord of first fragment in horizontal span/run */
GLint x, y;
/** Number of fragments in the span */
@@ -143,10 +144,17 @@ typedef struct sw_span
/**
* This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
- * which of the x/xStep variables are relevant.
+ * which of the attrStart/StepX/StepY variables are relevant.
*/
GLbitfield interpMask;
+ /** Fragment attribute interpolants */
+ GLfloat attrStart[FRAG_ATTRIB_MAX][4]; /**< initial value */
+ GLfloat attrStepX[FRAG_ATTRIB_MAX][4]; /**< dvalue/dx */
+ GLfloat attrStepY[FRAG_ATTRIB_MAX][4]; /**< dvalue/dy */
+
+ /* XXX the rest of these will go away eventually... */
+
/* For horizontal spans, step is the partial derivative wrt X.
* For lines, step is the delta from one fragment to the next.
*/
@@ -169,24 +177,8 @@ typedef struct sw_span
#endif
GLfixed index, indexStep;
GLfixed z, zStep; /* XXX z should probably be GLuint */
- GLfloat tex[MAX_TEXTURE_COORD_UNITS][4]; /* s, t, r, q */
- GLfloat texStepX[MAX_TEXTURE_COORD_UNITS][4];
- GLfloat texStepY[MAX_TEXTURE_COORD_UNITS][4];
GLfixed intTex[2], intTexStep[2]; /* s, t only */
- /** Fragment attribute interpolants */
- GLfloat attrStart[FRAG_ATTRIB_MAX][4]; /**< initial value */
- GLfloat attrStepX[FRAG_ATTRIB_MAX][4]; /**< dvalue/dx */
- GLfloat attrStepY[FRAG_ATTRIB_MAX][4]; /**< dvalue/dy */
-
- /* partial derivatives wrt X and Y. */
- GLfloat dzdx, dzdy;
- GLfloat w, dwdx, dwdy;
- GLfloat drdx, drdy;
- GLfloat dgdx, dgdy;
- GLfloat dbdx, dbdy;
- GLfloat dadx, dady;
-
/**
* This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
* which of the fragment arrays in the span_arrays struct are relevant.
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9b775928cd..6c2e3862a3 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -676,13 +676,13 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
const GLuint savedTexEnable = ctx->Texture._EnabledUnits;
ctx->Texture._EnabledUnits = 0;
- tex_coord[0] = span->tex[0][0] * (info->smask + 1);
- tex_step[0] = span->texStepX[0][0] * (info->smask + 1);
- tex_coord[1] = span->tex[0][1] * (info->tmask + 1);
- tex_step[1] = span->texStepX[0][1] * (info->tmask + 1);
- /* span->tex[0][2] only if 3D-texturing, here only 2D */
- tex_coord[2] = span->tex[0][3];
- tex_step[2] = span->texStepX[0][3];
+ tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX0][0] * (info->smask + 1);
+ tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX0][0] * (info->smask + 1);
+ tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1);
+ tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1);
+ /* span->attrStart[FRAG_ATTRIB_TEX0][2] only if 3D-texturing, here only 2D */
+ tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX0][3];
+ tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX0][3];
switch (info->filter) {
case GL_NEAREST:
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index c8fe4b6e9e..83b2f03781 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -128,6 +128,8 @@
GLuint u; \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
if (ctx->Texture._EnabledCoordUnits & (1 << u)) { \
+ const GLuint attr = FRAG_ATTRIB_TEX0 + u; \
+ (void) attr; \
CODE \
} \
} \
@@ -137,6 +139,8 @@
#define TEX_UNIT_LOOP(CODE) \
{ \
const GLuint u = 0; \
+ const GLuint attr = FRAG_ATTRIB_TEX0 + u; \
+ (void) attr; \
CODE \
}
#endif
@@ -145,17 +149,18 @@
#ifdef INTERP_VARYING
-#define VARYING_LOOP(CODE) \
- { \
- GLuint iv, ic; \
- for (iv = 0; iv < MAX_VARYING; iv++) { \
- if (inputsUsed & FRAG_BIT_VAR(iv)) { \
+#define VARYING_LOOP(CODE) \
+ { \
+ GLuint iv, ic; \
+ for (iv = 0; iv < MAX_VARYING; iv++) { \
+ if (inputsUsed & FRAG_BIT_VAR(iv)) { \
GLuint attr = FRAG_ATTRIB_VAR0 + iv; \
- for (ic = 0; ic < 4; ic++) { \
- CODE \
- } \
- } \
- } \
+ (void) attr; \
+ for (ic = 0; ic < 4; ic++) { \
+ CODE \
+ } \
+ } \
+ } \
}
#endif
@@ -473,19 +478,19 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
{
GLfloat eMaj_dz = vMax->win[2] - vMin->win[2];
GLfloat eBot_dz = vMid->win[2] - vMin->win[2];
- span.dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
- if (span.dzdx > maxDepth || span.dzdx < -maxDepth) {
+ span.attrStepX[FRAG_ATTRIB_WPOS][2] = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
+ if (span.attrStepX[FRAG_ATTRIB_WPOS][2] > maxDepth || span.attrStepX[FRAG_ATTRIB_WPOS][2] < -maxDepth) {
/* probably a sliver triangle */
- span.dzdx = 0.0;
- span.dzdy = 0.0;
+ span.attrStepX[FRAG_ATTRIB_WPOS][2] = 0.0;
+ span.attrStepY[FRAG_ATTRIB_WPOS][2] = 0.0;
}
else {
- span.dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx);
+ span.attrStepY[FRAG_ATTRIB_WPOS][2] = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx);
}
if (depthBits <= 16)
- span.zStep = SignedFloatToFixed(span.dzdx);
+ span.zStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_WPOS][2]);
else
- span.zStep = (GLint) span.dzdx;
+ span.zStep = (GLint) span.attrStepX[FRAG_ATTRIB_WPOS][2];
}
#endif
#ifdef INTERP_W
@@ -493,8 +498,8 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
{
const GLfloat eMaj_dw = vMax->win[3] - vMin->win[3];
const GLfloat eBot_dw = vMid->win[3] - vMin->win[3];
- span.dwdx = oneOverArea * (eMaj_dw * eBot.dy - eMaj.dy * eBot_dw);
- span.dwdy = oneOverArea * (eMaj.dx * eBot_dw - eMaj_dw * eBot.dx);
+ span.attrStepX[FRAG_ATTRIB_WPOS][3] = oneOverArea * (eMaj_dw * eBot.dy - eMaj.dy * eBot_dw);
+ span.attrStepY[FRAG_ATTRIB_WPOS][3] = oneOverArea * (eMaj.dx * eBot_dw - eMaj_dw * eBot.dx);
}
#endif
#ifdef INTERP_FOG
@@ -525,37 +530,37 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
GLfloat eMaj_da = (GLfloat) ((ColorTemp) vMax->color[ACOMP] - (ColorTemp) vMin->color[ACOMP]);
GLfloat eBot_da = (GLfloat) ((ColorTemp) vMid->color[ACOMP] - (ColorTemp) vMin->color[ACOMP]);
# endif
- span.drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
- span.drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
- span.dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
- span.dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
- span.dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
- span.dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
+ span.attrStepX[FRAG_ATTRIB_COL0][0] = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
+ span.attrStepY[FRAG_ATTRIB_COL0][0] = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
+ span.attrStepX[FRAG_ATTRIB_COL0][1] = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
+ span.attrStepY[FRAG_ATTRIB_COL0][1] = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
+ span.attrStepX[FRAG_ATTRIB_COL0][2] = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
+ span.attrStepY[FRAG_ATTRIB_COL0][2] = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
# if CHAN_TYPE == GL_FLOAT
- span.redStep = span.drdx;
- span.greenStep = span.dgdx;
- span.blueStep = span.dbdx;
+ span.redStep = span.attrStepX[FRAG_ATTRIB_COL0][0];
+ span.greenStep = span.attrStepX[FRAG_ATTRIB_COL0][1];
+ span.blueStep = span.attrStepX[FRAG_ATTRIB_COL0][2];
# else
- span.redStep = SignedFloatToFixed(span.drdx);
- span.greenStep = SignedFloatToFixed(span.dgdx);
- span.blueStep = SignedFloatToFixed(span.dbdx);
+ span.redStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL0][0]);
+ span.greenStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL0][1]);
+ span.blueStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL0][2]);
# endif /* GL_FLOAT */
# ifdef INTERP_ALPHA
- span.dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
- span.dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
+ span.attrStepX[FRAG_ATTRIB_COL0][3] = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
+ span.attrStepX[FRAG_ATTRIB_COL0][3] = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
# if CHAN_TYPE == GL_FLOAT
- span.alphaStep = span.dadx;
+ span.alphaStep = span.attrStepX[FRAG_ATTRIB_COL0][3];
# else
- span.alphaStep = SignedFloatToFixed(span.dadx);
+ span.alphaStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL0][3]);
# endif /* GL_FLOAT */
# endif /* INTERP_ALPHA */
}
else {
ASSERT(ctx->Light.ShadeModel == GL_FLAT);
span.interpMask |= SPAN_FLAT;
- span.drdx = span.drdy = 0.0F;
- span.dgdx = span.dgdy = 0.0F;
- span.dbdx = span.dbdy = 0.0F;
+ span.attrStepX[FRAG_ATTRIB_COL0][0] = span.attrStepY[FRAG_ATTRIB_COL0][0] = 0.0F;
+ span.attrStepX[FRAG_ATTRIB_COL0][1] = span.attrStepY[FRAG_ATTRIB_COL0][1] = 0.0F;
+ span.attrStepX[FRAG_ATTRIB_COL0][2] = span.attrStepY[FRAG_ATTRIB_COL0][2] = 0.0F;
# if CHAN_TYPE == GL_FLOAT
span.redStep = 0.0F;
span.greenStep = 0.0F;
@@ -566,7 +571,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
span.blueStep = 0;
# endif /* GL_FLOAT */
# ifdef INTERP_ALPHA
- span.dadx = span.dady = 0.0F;
+ span.attrStepX[FRAG_ATTRIB_COL0][3] = span.attrStepX[FRAG_ATTRIB_COL0][3] = 0.0F;
# if CHAN_TYPE == GL_FLOAT
span.alphaStep = 0.0F;
# else
@@ -637,12 +642,12 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
GLfloat eBot_ds = (vMid->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
GLfloat eMaj_dt = (vMax->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
GLfloat eBot_dt = (vMid->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
- span.texStepX[0][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
- span.texStepY[0][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
- span.texStepX[0][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
- span.texStepY[0][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
- span.intTexStep[0] = SignedFloatToFixed(span.texStepX[0][0]);
- span.intTexStep[1] = SignedFloatToFixed(span.texStepX[0][1]);
+ span.attrStepX[FRAG_ATTRIB_TEX0][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
+ span.attrStepY[FRAG_ATTRIB_TEX0][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
+ span.attrStepX[FRAG_ATTRIB_TEX0][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
+ span.attrStepY[FRAG_ATTRIB_TEX0][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
+ span.intTexStep[0] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX0][0]);
+ span.intTexStep[1] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX0][1]);
}
#endif
#ifdef INTERP_TEX
@@ -659,14 +664,14 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
GLfloat eBot_du = vMid->texcoord[u][2] * wMid - vMin->texcoord[u][2] * wMin;
GLfloat eMaj_dv = vMax->texcoord[u][3] * wMax - vMin->texcoord[u][3] * wMin;
GLfloat eBot_dv = vMid->texcoord[u][3] * wMid - vMin->texcoord[u][3] * wMin;
- span.texStepX[u][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
- span.texStepY[u][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
- span.texStepX[u][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
- span.texStepY[u][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
- span.texStepX[u][2] = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
- span.texStepY[u][2] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
- span.texStepX[u][3] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
- span.texStepY[u][3] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
+ span.attrStepX[attr][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
+ span.attrStepY[attr][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
+ span.attrStepX[attr][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
+ span.attrStepY[attr][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
+ span.attrStepX[attr][2] = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
+ span.attrStepY[attr][2] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
+ span.attrStepX[attr][3] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
+ span.attrStepY[attr][3] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
)
}
#endif
@@ -901,19 +906,20 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
GLfloat z0 = vLower->win[2];
if (depthBits <= 16) {
/* interpolate fixed-pt values */
- GLfloat tmp = (z0 * FIXED_SCALE + span.dzdx * adjx
- + span.dzdy * adjy) + FIXED_HALF;
+ GLfloat tmp = (z0 * FIXED_SCALE
+ + span.attrStepX[FRAG_ATTRIB_WPOS][2] * adjx
+ + span.attrStepY[FRAG_ATTRIB_WPOS][2] * adjy) + FIXED_HALF;
if (tmp < MAX_GLUINT / 2)
zLeft = (GLfixed) tmp;
else
zLeft = MAX_GLUINT / 2;
- fdzOuter = SignedFloatToFixed(span.dzdy + dxOuter * span.dzdx);
+ fdzOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_WPOS][2] + dxOuter * span.attrStepX[FRAG_ATTRIB_WPOS][2]);
}
else {
/* interpolate depth values w/out scaling */
- zLeft = (GLuint) (z0 + span.dzdx * FixedToFloat(adjx)
- + span.dzdy * FixedToFloat(adjy));
- fdzOuter = (GLint) (span.dzdy + dxOuter * span.dzdx);
+ zLeft = (GLuint) (z0 + span.attrStepX[FRAG_ATTRIB_WPOS][2] * FixedToFloat(adjx)
+ + span.attrStepY[FRAG_ATTRIB_WPOS][2] * FixedToFloat(adjy));
+ fdzOuter = (GLint) (span.attrStepY[FRAG_ATTRIB_WPOS][2] + dxOuter * span.attrStepX[FRAG_ATTRIB_WPOS][2]);
}
# ifdef DEPTH_TYPE
zRow = (DEPTH_TYPE *)
@@ -923,8 +929,8 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
}
#endif
#ifdef INTERP_W
- wLeft = vLower->win[3] + (span.dwdx * adjx + span.dwdy * adjy) * (1.0F/FIXED_SCALE);
- dwOuter = span.dwdy + dxOuter * span.dwdx;
+ wLeft = vLower->win[3] + (span.attrStepX[FRAG_ATTRIB_WPOS][3] * adjx + span.attrStepY[FRAG_ATTRIB_WPOS][3] * adjy) * (1.0F/FIXED_SCALE);
+ dwOuter = span.attrStepY[FRAG_ATTRIB_WPOS][3] + dxOuter * span.attrStepX[FRAG_ATTRIB_WPOS][3];
#endif
#ifdef INTERP_FOG
# ifdef INTERP_W
@@ -937,27 +943,27 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#ifdef INTERP_RGB
if (ctx->Light.ShadeModel == GL_SMOOTH) {
# if CHAN_TYPE == GL_FLOAT
- rLeft = vLower->color[RCOMP] + (span.drdx * adjx + span.drdy * adjy) * (1.0F / FIXED_SCALE);
- gLeft = vLower->color[GCOMP] + (span.dgdx * adjx + span.dgdy * adjy) * (1.0F / FIXED_SCALE);
- bLeft = vLower->color[BCOMP] + (span.dbdx * adjx + span.dbdy * adjy) * (1.0F / FIXED_SCALE);
- fdrOuter = span.drdy + dxOuter * span.drdx;
- fdgOuter = span.dgdy + dxOuter * span.dgdx;
- fdbOuter = span.dbdy + dxOuter * span.dbdx;
+ rLeft = vLower->color[RCOMP] + (span.attrStepX[FRAG_ATTRIB_COL0][0] * adjx + span.attrStepY[FRAG_ATTRIB_COL0][0] * adjy) * (1.0F / FIXED_SCALE);
+ gLeft = vLower->color[GCOMP] + (span.attrStepX[FRAG_ATTRIB_COL0][1] * adjx + span.attrStepY[FRAG_ATTRIB_COL0][1] * adjy) * (1.0F / FIXED_SCALE);
+ bLeft = vLower->color[BCOMP] + (span.attrStepX[FRAG_ATTRIB_COL0][2] * adjx + span.attrStepY[FRAG_ATTRIB_COL0][2] * adjy) * (1.0F / FIXED_SCALE);
+ fdrOuter = span.attrStepY[FRAG_ATTRIB_COL0][0] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][0];
+ fdgOuter = span.attrStepY[FRAG_ATTRIB_COL0][1] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][1];
+ fdbOuter = span.attrStepY[FRAG_ATTRIB_COL0][2] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][2];
# else
- rLeft = (GLint)(ChanToFixed(vLower->color[RCOMP]) + span.drdx * adjx + span.drdy * adjy) + FIXED_HALF;
- gLeft = (GLint)(ChanToFixed(vLower->color[GCOMP]) + span.dgdx * adjx + span.dgdy * adjy) + FIXED_HALF;
- bLeft = (GLint)(ChanToFixed(vLower->color[BCOMP]) + span.dbdx * adjx + span.dbdy * adjy) + FIXED_HALF;
- fdrOuter = SignedFloatToFixed(span.drdy + dxOuter * span.drdx);
- fdgOuter = SignedFloatToFixed(span.dgdy + dxOuter * span.dgdx);
- fdbOuter = SignedFloatToFixed(span.dbdy + dxOuter * span.dbdx);
+ rLeft = (GLint)(ChanToFixed(vLower->color[RCOMP]) + span.attrStepX[FRAG_ATTRIB_COL0][0] * adjx + span.attrStepY[FRAG_ATTRIB_COL0][0] * adjy) + FIXED_HALF;
+ gLeft = (GLint)(ChanToFixed(vLower->color[GCOMP]) + span.attrStepX[FRAG_ATTRIB_COL0][1] * adjx + span.attrStepY[FRAG_ATTRIB_COL0][1] * adjy) + FIXED_HALF;
+ bLeft = (GLint)(ChanToFixed(vLower->color[BCOMP]) + span.attrStepX[FRAG_ATTRIB_COL0][2] * adjx + span.attrStepY[FRAG_ATTRIB_COL0][2] * adjy) + FIXED_HALF;
+ fdrOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL0][0] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][0]);
+ fdgOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL0][1] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][1]);
+ fdbOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL0][2] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][2]);
# endif
# ifdef INTERP_ALPHA
# if CHAN_TYPE == GL_FLOAT
- aLeft = vLower->color[ACOMP] + (span.dadx * adjx + span.dady * adjy) * (1.0F / FIXED_SCALE);
- fdaOuter = span.dady + dxOuter * span.dadx;
+ aLeft = vLower->color[ACOMP] + (span.attrStepX[FRAG_ATTRIB_COL0][3] * adjx + span.attrStepX[FRAG_ATTRIB_COL0][3] * adjy) * (1.0F / FIXED_SCALE);
+ fdaOuter = span.attrStepX[FRAG_ATTRIB_COL0][3] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][3];
# else
- aLeft = (GLint)(ChanToFixed(vLower->color[ACOMP]) + span.dadx * adjx + span.dady * adjy) + FIXED_HALF;
- fdaOuter = SignedFloatToFixed(span.dady + dxOuter * span.dadx);
+ aLeft = (GLint)(ChanToFixed(vLower->color[ACOMP]) + span.attrStepX[FRAG_ATTRIB_COL0][3] * adjx + span.attrStepX[FRAG_ATTRIB_COL0][3] * adjy) + FIXED_HALF;
+ fdaOuter = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL0][3] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL0][3]);
# endif
# endif
}
@@ -1037,14 +1043,14 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
{
GLfloat s0, t0;
s0 = vLower->texcoord[0][0] * S_SCALE;
- sLeft = (GLfixed)(s0 * FIXED_SCALE + span.texStepX[0][0] * adjx
- + span.texStepY[0][0] * adjy) + FIXED_HALF;
- dsOuter = SignedFloatToFixed(span.texStepY[0][0] + dxOuter * span.texStepX[0][0]);
+ sLeft = (GLfixed)(s0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX0][0] * adjx
+ + span.attrStepY[FRAG_ATTRIB_TEX0][0] * adjy) + FIXED_HALF;
+ dsOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX0][0] + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX0][0]);
t0 = vLower->texcoord[0][1] * T_SCALE;
- tLeft = (GLfixed)(t0 * FIXED_SCALE + span.texStepX[0][1] * adjx
- + span.texStepY[0][1] * adjy) + FIXED_HALF;
- dtOuter = SignedFloatToFixed(span.texStepY[0][1] + dxOuter * span.texStepX[0][1]);
+ tLeft = (GLfixed)(t0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX0][1] * adjx
+ + span.attrStepY[FRAG_ATTRIB_TEX0][1] * adjy) + FIXED_HALF;
+ dtOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX0][1] + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX0][1]);
}
#endif
#ifdef INTERP_TEX
@@ -1054,14 +1060,14 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
const GLfloat t0 = vLower->texcoord[u][1] * invW;
const GLfloat u0 = vLower->texcoord[u][2] * invW;
const GLfloat v0 = vLower->texcoord[u][3] * invW;
- sLeft[u] = s0 + (span.texStepX[u][0] * adjx + span.texStepY[u][0] * adjy) * (1.0F/FIXED_SCALE);
- tLeft[u] = t0 + (span.texStepX[u][1] * adjx + span.texStepY[u][1] * adjy) * (1.0F/FIXED_SCALE);
- uLeft[u] = u0 + (span.texStepX[u][2] * adjx + span.texStepY[u][2] * adjy) * (1.0F/FIXED_SCALE);
- vLeft[u] = v0 + (span.texStepX[u][3] * adjx + span.texStepY[u][3] * adjy) * (1.0F/FIXED_SCALE);
- dsOuter[u] = span.texStepY[u][0] + dxOuter * span.texStepX[u][0];
- dtOuter[u] = span.texStepY[u][1] + dxOuter * span.texStepX[u][1];
- duOuter[u] = span.texStepY[u][2] + dxOuter * span.texStepX[u][2];
- dvOuter[u] = span.texStepY[u][3] + dxOuter * span.texStepX[u][3];
+ sLeft[u] = s0 + (span.attrStepX[attr][0] * adjx + span.attrStepY[attr][0] * adjy) * (1.0F/FIXED_SCALE);
+ tLeft[u] = t0 + (span.attrStepX[attr][1] * adjx + span.attrStepY[attr][1] * adjy) * (1.0F/FIXED_SCALE);
+ uLeft[u] = u0 + (span.attrStepX[attr][2] * adjx + span.attrStepY[attr][2] * adjy) * (1.0F/FIXED_SCALE);
+ vLeft[u] = v0 + (span.attrStepX[attr][3] * adjx + span.attrStepY[attr][3] * adjy) * (1.0F/FIXED_SCALE);
+ dsOuter[u] = span.attrStepY[attr][0] + dxOuter * span.attrStepX[attr][0];
+ dtOuter[u] = span.attrStepY[attr][1] + dxOuter * span.attrStepX[attr][1];
+ duOuter[u] = span.attrStepY[attr][2] + dxOuter * span.attrStepX[attr][2];
+ dvOuter[u] = span.attrStepY[attr][3] + dxOuter * span.attrStepX[attr][3];
)
#endif
#ifdef INTERP_VARYING
@@ -1102,7 +1108,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
fdzInner = fdzOuter + span.zStep;
#endif
#ifdef INTERP_W
- dwInner = dwOuter + span.dwdx;
+ dwInner = dwOuter + span.attrStepX[FRAG_ATTRIB_WPOS][3];
#endif
#ifdef INTERP_FOG
dfogInner = dfogOuter + span.attrStepX[FRAG_ATTRIB_FOGC][0];
@@ -1129,10 +1135,10 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#endif
#ifdef INTERP_TEX
TEX_UNIT_LOOP(
- dsInner[u] = dsOuter[u] + span.texStepX[u][0];
- dtInner[u] = dtOuter[u] + span.texStepX[u][1];
- duInner[u] = duOuter[u] + span.texStepX[u][2];
- dvInner[u] = dvOuter[u] + span.texStepX[u][3];
+ dsInner[u] = dsOuter[u] + span.attrStepX[attr][0];
+ dtInner[u] = dtOuter[u] + span.attrStepX[attr][1];
+ duInner[u] = duOuter[u] + span.attrStepX[attr][2];
+ dvInner[u] = dvOuter[u] + span.attrStepX[attr][3];
)
#endif
#ifdef INTERP_VARYING
@@ -1155,7 +1161,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
span.z = zLeft;
#endif
#ifdef INTERP_W
- span.w = wLeft;
+ span.attrStart[FRAG_ATTRIB_WPOS][3] = wLeft;
#endif
#ifdef INTERP_FOG
span.attrStart[FRAG_ATTRIB_FOGC][0] = fogLeft;
@@ -1183,10 +1189,10 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#ifdef INTERP_TEX
TEX_UNIT_LOOP(
- span.tex[u][0] = sLeft[u];
- span.tex[u][1] = tLeft[u];
- span.tex[u][2] = uLeft[u];
- span.tex[u][3] = vLeft[u];
+ span.attrStart[attr][0] = sLeft[u];
+ span.attrStart[attr][1] = tLeft[u];
+ span.attrStart[attr][2] = uLeft[u];
+ span.attrStart[attr][3] = vLeft[u];
)
#endif
#ifdef INTERP_VARYING