diff options
author | Brian <[email protected]> | 2007-04-23 21:21:52 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-04-23 21:21:52 -0600 |
commit | 0bdf216dd06d5136b8529297297aa962bab548c2 (patch) | |
tree | bb7c516d3d6f2e818f2cbb0f8865a45fecf053c6 /src/mesa/swrast | |
parent | d59e6f233b02ffe2c36c2fb89ec26c208a421540 (diff) |
Improve the code for interpolating fragment attributes a little. More to come...
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_aalinetemp.h | 84 | ||||
-rw-r--r-- | src/mesa/swrast/s_aatritemp.h | 136 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 30 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.h | 25 | ||||
-rw-r--r-- | src/mesa/swrast/s_linetemp.h | 41 | ||||
-rw-r--r-- | src/mesa/swrast/s_pointtemp.h | 50 | ||||
-rw-r--r-- | src/mesa/swrast/s_tritemp.h | 38 |
7 files changed, 182 insertions, 222 deletions
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index dd741630a1d..b0b73e816dd 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -81,31 +81,26 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) line->span.array->spec[i][BCOMP] = solve_plane_chan(fx, fy, line->sbPlane); #endif #if defined(DO_TEXVAR) - { - GLuint attr; - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; - GLfloat invQ; - if (ctx->FragmentProgram._Active) { - invQ = 1.0F; - } - else { - invQ = solve_plane_recip(fx, fy, line->vPlane[attr]); - } - attribArray[i][0] = solve_plane(fx, fy, line->sPlane[attr]) * invQ; - attribArray[i][1] = solve_plane(fx, fy, line->tPlane[attr]) * invQ; - attribArray[i][2] = solve_plane(fx, fy, line->uPlane[attr]) * invQ; - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint unit = attr - FRAG_ATTRIB_TEX0; - line->span.array->lambda[unit][i] - = compute_lambda(line->sPlane[attr], - line->tPlane[attr], invQ, - line->texWidth[attr], line->texHeight[attr]); - } - } + ATTRIB_LOOP_BEGIN + GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; + GLfloat invQ; + if (ctx->FragmentProgram._Active) { + invQ = 1.0F; } - } + else { + invQ = solve_plane_recip(fx, fy, line->vPlane[attr]); + } + attribArray[i][0] = solve_plane(fx, fy, line->sPlane[attr]) * invQ; + attribArray[i][1] = solve_plane(fx, fy, line->tPlane[attr]) * invQ; + attribArray[i][2] = solve_plane(fx, fy, line->uPlane[attr]) * invQ; + if (attr < FRAG_ATTRIB_VAR0) { + const GLuint unit = attr - FRAG_ATTRIB_TEX0; + line->span.array->lambda[unit][i] + = compute_lambda(line->sPlane[attr], + line->tPlane[attr], invQ, + line->texWidth[attr], line->texHeight[attr]); + } + ATTRIB_LOOP_END #endif if (line->span.end == MAX_WIDTH) { @@ -207,33 +202,30 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) #endif #if defined(DO_TEXVAR) { - GLuint attr; const GLfloat invW0 = v0->win[3]; const GLfloat invW1 = v1->win[3]; line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA | SPAN_VARYING); - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - const GLfloat s0 = v0->attrib[attr][0] * invW0; - const GLfloat s1 = v1->attrib[attr][0] * invW1; - const GLfloat t0 = v0->attrib[attr][1] * invW0; - const GLfloat t1 = v1->attrib[attr][1] * invW1; - const GLfloat r0 = v0->attrib[attr][2] * invW0; - const GLfloat r1 = v1->attrib[attr][2] * invW1; - const GLfloat q0 = v0->attrib[attr][3] * invW0; - const GLfloat q1 = v1->attrib[attr][3] * invW1; - compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[attr]); - compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[attr]); - compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[attr]); - compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[attr]); - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint u = attr - FRAG_ATTRIB_TEX0; - const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; - line.texWidth[attr] = (GLfloat) texImage->Width; + ATTRIB_LOOP_BEGIN + const GLfloat s0 = v0->attrib[attr][0] * invW0; + const GLfloat s1 = v1->attrib[attr][0] * invW1; + const GLfloat t0 = v0->attrib[attr][1] * invW0; + const GLfloat t1 = v1->attrib[attr][1] * invW1; + const GLfloat r0 = v0->attrib[attr][2] * invW0; + const GLfloat r1 = v1->attrib[attr][2] * invW1; + const GLfloat q0 = v0->attrib[attr][3] * invW0; + const GLfloat q1 = v1->attrib[attr][3] * invW1; + compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[attr]); + compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[attr]); + compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[attr]); + compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[attr]); + if (attr < FRAG_ATTRIB_VAR0) { + const GLuint u = attr - FRAG_ATTRIB_TEX0; + const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; + const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; + line.texWidth[attr] = (GLfloat) texImage->Width; line.texHeight[attr] = (GLfloat) texImage->Height; - } } - } + ATTRIB_LOOP_END } #endif diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index bbf9cc611d8..f6c8e68a9b7 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -179,40 +179,37 @@ #endif #if defined(DO_TEXVAR) { - GLuint attr; const GLfloat invW0 = v0->win[3]; const GLfloat invW1 = v1->win[3]; const GLfloat invW2 = v2->win[3]; - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - const GLfloat s0 = v0->attrib[attr][0] * invW0; - const GLfloat s1 = v1->attrib[attr][0] * invW1; - const GLfloat s2 = v2->attrib[attr][0] * invW2; - const GLfloat t0 = v0->attrib[attr][1] * invW0; - const GLfloat t1 = v1->attrib[attr][1] * invW1; - const GLfloat t2 = v2->attrib[attr][1] * invW2; - const GLfloat r0 = v0->attrib[attr][2] * invW0; - const GLfloat r1 = v1->attrib[attr][2] * invW1; - const GLfloat r2 = v2->attrib[attr][2] * invW2; - const GLfloat q0 = v0->attrib[attr][3] * invW0; - const GLfloat q1 = v1->attrib[attr][3] * invW1; - const GLfloat q2 = v2->attrib[attr][3] * invW2; - compute_plane(p0, p1, p2, s0, s1, s2, sPlane[attr]); - compute_plane(p0, p1, p2, t0, t1, t2, tPlane[attr]); - compute_plane(p0, p1, p2, r0, r1, r2, uPlane[attr]); - compute_plane(p0, p1, p2, q0, q1, q2, vPlane[attr]); - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint u = attr - FRAG_ATTRIB_TEX0; - const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; - texWidth[attr] = (GLfloat) texImage->Width; - texHeight[attr] = (GLfloat) texImage->Height; - } - else { - texWidth[attr] = texHeight[attr] = 1.0; - } + ATTRIB_LOOP_BEGIN + const GLfloat s0 = v0->attrib[attr][0] * invW0; + const GLfloat s1 = v1->attrib[attr][0] * invW1; + const GLfloat s2 = v2->attrib[attr][0] * invW2; + const GLfloat t0 = v0->attrib[attr][1] * invW0; + const GLfloat t1 = v1->attrib[attr][1] * invW1; + const GLfloat t2 = v2->attrib[attr][1] * invW2; + const GLfloat r0 = v0->attrib[attr][2] * invW0; + const GLfloat r1 = v1->attrib[attr][2] * invW1; + const GLfloat r2 = v2->attrib[attr][2] * invW2; + const GLfloat q0 = v0->attrib[attr][3] * invW0; + const GLfloat q1 = v1->attrib[attr][3] * invW1; + const GLfloat q2 = v2->attrib[attr][3] * invW2; + compute_plane(p0, p1, p2, s0, s1, s2, sPlane[attr]); + compute_plane(p0, p1, p2, t0, t1, t2, tPlane[attr]); + compute_plane(p0, p1, p2, r0, r1, r2, uPlane[attr]); + compute_plane(p0, p1, p2, q0, q1, q2, vPlane[attr]); + if (attr < FRAG_ATTRIB_VAR0) { + const GLuint u = attr - FRAG_ATTRIB_TEX0; + const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; + const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; + texWidth[attr] = (GLfloat) texImage->Width; + texHeight[attr] = (GLfloat) texImage->Height; } - } + else { + texWidth[attr] = texHeight[attr] = 1.0; + } + ATTRIB_LOOP_END } span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA | SPAN_VARYING); #endif @@ -283,23 +280,18 @@ array->spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane); #endif #if defined(DO_TEXVAR) - { - GLuint attr; - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - GLfloat invQ = solve_plane_recip(cx, cy, vPlane[attr]); - array->attribs[attr][count][0] = solve_plane(cx, cy, sPlane[attr]) * invQ; - array->attribs[attr][count][1] = solve_plane(cx, cy, tPlane[attr]) * invQ; - array->attribs[attr][count][2] = solve_plane(cx, cy, uPlane[attr]) * invQ; - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint unit = attr - FRAG_ATTRIB_TEX0; - array->lambda[unit][count] = compute_lambda(sPlane[attr], tPlane[attr], - vPlane[attr], cx, cy, invQ, - texWidth[attr], texHeight[attr]); - } - } + ATTRIB_LOOP_BEGIN + GLfloat invQ = solve_plane_recip(cx, cy, vPlane[attr]); + array->attribs[attr][count][0] = solve_plane(cx, cy, sPlane[attr]) * invQ; + array->attribs[attr][count][1] = solve_plane(cx, cy, tPlane[attr]) * invQ; + array->attribs[attr][count][2] = solve_plane(cx, cy, uPlane[attr]) * invQ; + if (attr < FRAG_ATTRIB_VAR0) { + const GLuint unit = attr - FRAG_ATTRIB_TEX0; + array->lambda[unit][count] = compute_lambda(sPlane[attr], tPlane[attr], + vPlane[attr], cx, cy, invQ, + texWidth[attr], texHeight[attr]); } - } + ATTRIB_LOOP_END #endif ix++; count++; @@ -380,26 +372,21 @@ array->spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane); #endif #if defined(DO_TEXVAR) - { - GLuint attr; - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - GLfloat invQ = solve_plane_recip(cx, cy, vPlane[attr]); - array->attribs[attr][ix][0] = solve_plane(cx, cy, sPlane[attr]) * invQ; - array->attribs[attr][ix][1] = solve_plane(cx, cy, tPlane[attr]) * invQ; - array->attribs[attr][ix][2] = solve_plane(cx, cy, uPlane[attr]) * invQ; - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint unit = attr - FRAG_ATTRIB_TEX0; - array->lambda[unit][ix] = compute_lambda(sPlane[attr], - tPlane[attr], - vPlane[attr], - cx, cy, invQ, - texWidth[attr], - texHeight[attr]); - } - } + ATTRIB_LOOP_BEGIN + GLfloat invQ = solve_plane_recip(cx, cy, vPlane[attr]); + array->attribs[attr][ix][0] = solve_plane(cx, cy, sPlane[attr]) * invQ; + array->attribs[attr][ix][1] = solve_plane(cx, cy, tPlane[attr]) * invQ; + array->attribs[attr][ix][2] = solve_plane(cx, cy, uPlane[attr]) * invQ; + if (attr < FRAG_ATTRIB_VAR0) { + const GLuint unit = attr - FRAG_ATTRIB_TEX0; + array->lambda[unit][ix] = compute_lambda(sPlane[attr], + tPlane[attr], + vPlane[attr], + cx, cy, invQ, + texWidth[attr], + texHeight[attr]); } - } + ATTRIB_LOOP_END #endif ix--; count++; @@ -445,18 +432,15 @@ /* shift texcoords, varying */ { SWspanarrays *array = span.array; - GLuint attr; - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - GLint j; - for (j = 0; j < (GLint) n; j++) { - array->attribs[attr][j][0] = array->attribs[attr][j + left][0]; - array->attribs[attr][j][1] = array->attribs[attr][j + left][1]; - array->attribs[attr][j][2] = array->attribs[attr][j + left][2]; - /*array->lambda[unit][j] = array->lambda[unit][j + left];*/ - } + ATTRIB_LOOP_BEGIN + GLint j; + for (j = 0; j < (GLint) n; j++) { + array->attribs[attr][j][0] = array->attribs[attr][j + left][0]; + array->attribs[attr][j][1] = array->attribs[attr][j + left][1]; + array->attribs[attr][j][2] = array->attribs[attr][j + left][2]; + /*array->lambda[unit][j] = array->lambda[unit][j + left];*/ } - } + ATTRIB_LOOP_END } #endif diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 55b835bf85c..d4782aacb97 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -505,45 +505,43 @@ _swrast_update_texture_samplers(GLcontext *ctx) /** - * Update the swrast->_FragmentAttribs field. + * Update swrast->_ActiveAttribs and swrast->_NumActiveAttribs */ static void _swrast_update_fragment_attribs(GLcontext *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLuint attribsMask; if (ctx->FragmentProgram._Current) { - swrast->_FragmentAttribs - = ctx->FragmentProgram._Current->Base.InputsRead; + attribsMask = ctx->FragmentProgram._Current->Base.InputsRead; } else { GLuint u; - swrast->_FragmentAttribs = 0x0; + attribsMask = 0x0; if (ctx->Depth.Test) - swrast->_FragmentAttribs |= FRAG_BIT_WPOS; + attribsMask |= FRAG_BIT_WPOS; if (NEED_SECONDARY_COLOR(ctx)) - swrast->_FragmentAttribs |= FRAG_BIT_COL1; + attribsMask |= FRAG_BIT_COL1; if (swrast->_FogEnabled) - swrast->_FragmentAttribs |= FRAG_BIT_FOGC; + attribsMask |= FRAG_BIT_FOGC; for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { if (ctx->Texture.Unit[u]._ReallyEnabled) { - swrast->_FragmentAttribs |= FRAG_BIT_TEX(u); + attribsMask |= FRAG_BIT_TEX(u); } } } - /* Find lowest, highest bit set in _FragmentAttribs */ + /* Update _ActiveAttribs[] list */ { - GLuint bits = swrast->_FragmentAttribs; - GLuint i = 0;; - while (bits) { - i++; - bits = bits >> 1; + GLuint i, num = 0; + for (i = 0; i < FRAG_ATTRIB_MAX; i++) { + if (attribsMask & (1 << i)) + swrast->_ActiveAttribs[num++] = i; } - swrast->_MaxFragmentAttrib = i; - swrast->_MinFragmentAttrib = FRAG_ATTRIB_TEX0; /* XXX temporary */ + swrast->_NumActiveAttribs = num; } } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index dfe311a40bc..c8333b8e0a1 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -138,12 +138,10 @@ typedef struct GLbitfield _ColorOutputsMask; GLuint _NumColorOutputs; - /** Fragment attributes to compute during rasterization. - * Mask of FRAG_BIT_* flags. - */ - GLbitfield _FragmentAttribs; - GLuint _MinFragmentAttrib; /**< Lowest bit set in _FragmentAttribs */ - GLuint _MaxFragmentAttrib; /**< Highest bit set in _FragmentAttribs + 1 */ + /** List/array of the fragment attributes to interpolate */ + GLuint _ActiveAttribs[FRAG_ATTRIB_MAX]; + /** Number of fragment attributes to interpolate */ + GLuint _NumActiveAttribs; /* Accum buffer temporaries. */ @@ -277,4 +275,19 @@ _swrast_update_texture_samplers(GLcontext *ctx); #define FixedToChan(X) FixedToInt(X) #endif + +/** + * For looping over fragment attributes in the pointe, line + * triangle rasterizers. + */ +#define ATTRIB_LOOP_BEGIN \ + { \ + GLuint a; \ + for (a = 0; a < swrast->_NumActiveAttribs; a++) { \ + const GLuint attr = swrast->_ActiveAttribs[a]; + +#define ATTRIB_LOOP_END } } + + + #endif diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 7b66291eb5e..6c52e8dd478 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -314,28 +314,25 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) const GLfloat invLen = 1.0F / numPixels; const GLfloat invw0 = vert0->win[3]; const GLfloat invw1 = vert1->win[3]; - GLuint attr; - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - 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; - } - } + 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; + ATTRIB_LOOP_END } #endif diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index 1956eeba50b..23ac5712366 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -63,7 +63,6 @@ */ - static void NAME ( GLcontext *ctx, const SWvertex *vert ) { @@ -89,7 +88,6 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) #endif #if FLAGS & TEXTURE GLfloat attrib[FRAG_ATTRIB_MAX][4]; /* texture & varying */ - GLuint attr; #endif SWcontext *swrast = SWRAST_CONTEXT(ctx); SWspan *span = &(swrast->PointSpan); @@ -123,24 +121,20 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) span->arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); if (ctx->FragmentProgram._Active) { /* Don't divide texture s,t,r by q (use TXP to do that) */ - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - COPY_4V(attrib[attr], vert->attrib[attr]); - } - } + ATTRIB_LOOP_BEGIN + COPY_4V(attrib[attr], vert->attrib[attr]); + ATTRIB_LOOP_END } else { /* Divide texture s,t,r by q here */ - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - const GLfloat q = vert->attrib[attr][3]; - const GLfloat invQ = (q == 0.0F || q == 1.0F) ? 1.0F : (1.0F / q); - attrib[attr][0] = vert->attrib[attr][0] * invQ; - attrib[attr][1] = vert->attrib[attr][1] * invQ; - attrib[attr][2] = vert->attrib[attr][2] * invQ; - attrib[attr][3] = q; - } - } + ATTRIB_LOOP_BEGIN + const GLfloat q = vert->attrib[attr][3]; + const GLfloat invQ = (q == 0.0F || q == 1.0F) ? 1.0F : (1.0F / q); + attrib[attr][0] = vert->attrib[attr][0] * invQ; + attrib[attr][1] = vert->attrib[attr][1] * invQ; + attrib[attr][2] = vert->attrib[attr][2] * invQ; + attrib[attr][3] = q; + ATTRIB_LOOP_END } /* need these for fragment programs */ span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; @@ -279,15 +273,13 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) span->array->index[count] = colorIndex; #endif #if FLAGS & TEXTURE - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - COPY_4V(span->array->attribs[attr][count], attrib[attr]); - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint u = attr - FRAG_ATTRIB_TEX0; - span->array->lambda[u][count] = 0.0; - } + ATTRIB_LOOP_BEGIN + COPY_4V(span->array->attribs[attr][count], attrib[attr]); + if (attr < FRAG_ATTRIB_VAR0) { + const GLuint u = attr - FRAG_ATTRIB_TEX0; + span->array->lambda[u][count] = 0.0; } - } + ATTRIB_LOOP_END #endif #if FLAGS & SMOOTH @@ -406,11 +398,9 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) span->array->index[count] = colorIndex; #endif #if FLAGS & TEXTURE - for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { - if (swrast->_FragmentAttribs & (1 << attr)) { - COPY_4V(span->array->attribs[attr][count], attribs[attr]); - } - } + ATTRIB_LOOP_BEGIN + COPY_4V(span->array->attribs[attr][count], attribs[attr]); + ATTRIB_LOOP_END #endif span->array->x[count] = (GLint) vert->win[0]; diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index b25d3d1550c..deab7edbedb 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -117,20 +117,6 @@ #endif -#define TEXVAR_LOOP(CODE) \ - { \ - GLuint attr; \ - for (attr = swrast->_MinFragmentAttrib; \ - attr < swrast->_MaxFragmentAttrib; attr++) { \ - if (swrast->_FragmentAttribs & (1 << attr)) { \ - CODE \ - } \ - } \ - } - - - - /* * Some code we unfortunately need to prevent negative interpolated colors. */ @@ -620,7 +606,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, { /* win[3] is 1/W */ const GLfloat wMax = vMax->win[3], wMin = vMin->win[3], wMid = vMid->win[3]; - TEXVAR_LOOP( + ATTRIB_LOOP_BEGIN GLfloat eMaj_ds = vMax->attrib[attr][0] * wMax - vMin->attrib[attr][0] * wMin; GLfloat eBot_ds = vMid->attrib[attr][0] * wMid - vMin->attrib[attr][0] * wMin; GLfloat eMaj_dt = vMax->attrib[attr][1] * wMax - vMin->attrib[attr][1] * wMin; @@ -637,7 +623,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, 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); - ) + ATTRIB_LOOP_END } #endif @@ -1001,7 +987,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, } #endif #ifdef INTERP_TEX - TEXVAR_LOOP( + ATTRIB_LOOP_BEGIN const GLfloat invW = vLower->win[3]; const GLfloat s0 = vLower->attrib[attr][0] * invW; const GLfloat t0 = vLower->attrib[attr][1] * invW; @@ -1015,7 +1001,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, dtOuter[attr] = span.attrStepY[attr][1] + dxOuter * span.attrStepX[attr][1]; duOuter[attr] = span.attrStepY[attr][2] + dxOuter * span.attrStepX[attr][2]; dvOuter[attr] = span.attrStepY[attr][3] + dxOuter * span.attrStepX[attr][3]; - ) + ATTRIB_LOOP_END #endif } /*if setupLeft*/ @@ -1072,12 +1058,12 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, dtInner = dtOuter + span.intTexStep[1]; #endif #ifdef INTERP_TEX - TEXVAR_LOOP( + ATTRIB_LOOP_BEGIN dsInner[attr] = dsOuter[attr] + span.attrStepX[attr][0]; dtInner[attr] = dtOuter[attr] + span.attrStepX[attr][1]; duInner[attr] = duOuter[attr] + span.attrStepX[attr][2]; dvInner[attr] = dvOuter[attr] + span.attrStepX[attr][3]; - ) + ATTRIB_LOOP_END #endif while (lines > 0) { @@ -1121,12 +1107,12 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #endif #ifdef INTERP_TEX - TEXVAR_LOOP( + ATTRIB_LOOP_BEGIN span.attrStart[attr][0] = sLeft[attr]; span.attrStart[attr][1] = tLeft[attr]; span.attrStart[attr][2] = uLeft[attr]; span.attrStart[attr][3] = vLeft[attr]; - ) + ATTRIB_LOOP_END #endif /* This is where we actually generate fragments */ @@ -1209,12 +1195,12 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, tLeft += dtOuter; #endif #ifdef INTERP_TEX - TEXVAR_LOOP( + ATTRIB_LOOP_BEGIN sLeft[attr] += dsOuter[attr]; tLeft[attr] += dtOuter[attr]; uLeft[attr] += duOuter[attr]; vLeft[attr] += dvOuter[attr]; - ) + ATTRIB_LOOP_END #endif } else { @@ -1254,12 +1240,12 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, tLeft += dtInner; #endif #ifdef INTERP_TEX - TEXVAR_LOOP( + ATTRIB_LOOP_BEGIN sLeft[attr] += dsInner[attr]; tLeft[attr] += dtInner[attr]; uLeft[attr] += duInner[attr]; vLeft[attr] += dvInner[attr]; - ) + ATTRIB_LOOP_END #endif } } /*while lines>0*/ |