From 464b9f4f6c6514a7cfcc873923b5c127c1c6f60b Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Dec 2006 10:09:49 -0700 Subject: varying var changes --- src/mesa/swrast/s_tritemp.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/mesa/swrast/s_tritemp.h') diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 9e0a8a3d32..0ed1772a88 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -144,14 +144,14 @@ #ifdef INTERP_VARYING -#define VARYING_LOOP(CODE)\ - {\ - GLuint iv, ic;\ - for (iv = 0; iv < MAX_VARYING_VECTORS; iv++) {\ - for (ic = 0; ic < VARYINGS_PER_VECTOR; ic++) {\ - CODE\ - }\ - }\ +#define VARYING_LOOP(CODE) \ + { \ + GLuint iv, ic; \ + for (iv = 0; iv < MAX_VARYING; iv++) { \ + for (ic = 0; ic < 4; ic++) { \ + CODE \ + } \ + } \ } #endif @@ -780,9 +780,9 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, GLfloat dvOuter[MAX_TEXTURE_COORD_UNITS], dvInner[MAX_TEXTURE_COORD_UNITS]; #endif #ifdef INTERP_VARYING - GLfloat varLeft[MAX_VARYING_VECTORS][VARYINGS_PER_VECTOR]; - GLfloat dvarOuter[MAX_VARYING_VECTORS][VARYINGS_PER_VECTOR]; - GLfloat dvarInner[MAX_VARYING_VECTORS][VARYINGS_PER_VECTOR]; + GLfloat varLeft[MAX_VARYING][4]; + GLfloat dvarOuter[MAX_VARYING][4]; + GLfloat dvarInner[MAX_VARYING][4]; #endif for (subTriangle=0; subTriangle<=1; subTriangle++) { -- cgit v1.2.3 From eb2a6d62f9353d90be757fc1617040c7ccddac39 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 21 Dec 2006 17:50:07 -0700 Subject: s/attribute/varying/ --- src/mesa/swrast/s_tritemp.h | 9 +++++---- src/mesa/swrast/swrast.h | 2 +- src/mesa/swrast_setup/ss_context.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/mesa/swrast/s_tritemp.h') diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 0ed1772a88..c85379b4b1 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -41,7 +41,7 @@ * INTERP_TEX - if defined, interpolate set 0 float STRQ texcoords * NOTE: OpenGL STRQ = Mesa STUV (R was taken for red) * INTERP_MULTITEX - if defined, interpolate N units of STRQ texcoords - * INTERP_VARYING - if defined, interpolate M floats of GLSL varyings + * INTERP_VARYING - if defined, interpolate M GLSL varyings * * When one can directly address pixels in the color buffer the following * macros can be defined and used to compute pixel addresses during @@ -144,6 +144,7 @@ #ifdef INTERP_VARYING +/* XXX need a varyingEnabled[] check */ #define VARYING_LOOP(CODE) \ { \ GLuint iv, ic; \ @@ -669,8 +670,8 @@ 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]; VARYING_LOOP( - GLfloat eMaj_dvar = vMax->attribute[iv][ic] * wMax - vMin->attribute[iv][ic] * wMin; - GLfloat eBot_dvar = vMid->attribute[iv][ic] * wMid - vMin->attribute[iv][ic] * wMin; + GLfloat eMaj_dvar = vMax->varying[iv][ic] * wMax - vMin->varying[iv][ic] * wMin; + GLfloat eBot_dvar = vMid->varying[iv][ic] * wMid - vMin->varying[iv][ic] * wMin; span.varStepX[iv][ic] = oneOverArea * (eMaj_dvar * eBot.dy - eMaj.dy * eBot_dvar); span.varStepY[iv][ic] = oneOverArea * (eMaj.dx * eBot_dvar - eMaj_dvar * eBot.dx); ) @@ -1060,7 +1061,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_VARYING VARYING_LOOP( const GLfloat invW = vLower->win[3]; - const GLfloat var0 = vLower->attribute[iv][ic] * invW; + const GLfloat var0 = vLower->varying[iv][ic] * invW; varLeft[iv][ic] = var0 + (span.varStepX[iv][ic] * adjx + span.varStepY[iv][ic] * adjy) * (1.0f / FIXED_SCALE); dvarOuter[iv][ic] = span.varStepY[iv][ic] + dxOuter * span.varStepX[iv][ic]; diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index 09686c8380..2c1c0952af 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -73,7 +73,7 @@ typedef struct { GLfloat fog; GLfloat index; GLfloat pointSize; - GLfloat attribute[MAX_VERTEX_ATTRIBS][4]; + GLfloat varying[MAX_VERTEX_ATTRIBS][4]; } SWvertex; diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index 924b423e88..f17e69bfb2 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -156,7 +156,7 @@ _swsetup_RenderStart( GLcontext *ctx ) for (i = 0; i < ctx->Const.MaxVarying; i++) { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_GENERIC(i) )) { EMIT_ATTR( _TNL_ATTRIB_GENERIC(i), VARYING_EMIT_STYLE, - attribute[i] ); + varying[i] ); } } } -- cgit v1.2.3 From 0552abce0ec54dbb3f8de2fb9665fd5e58451543 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Jan 2007 14:13:02 -0700 Subject: only setup varying vars that will be used --- src/mesa/swrast/s_linetemp.h | 48 ++++++++++++++++++++++++-------------------- src/mesa/swrast/s_tritemp.h | 12 ++++++++--- 2 files changed, 35 insertions(+), 25 deletions(-) (limited to 'src/mesa/swrast/s_tritemp.h') diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 61c338ac69..b7b434771e 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.3 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -336,29 +336,33 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) #endif #ifdef INTERP_VARYING interpFlags |= SPAN_VARYING; - { /* XXX review this */ + { const GLfloat invLen = 1.0F / numPixels; + const GLbitfield inputsUsed = ctx->FragmentProgram._Current ? + ctx->FragmentProgram._Current->Base.InputsRead : 0x0; + const GLfloat invw0 = vert0->win[3]; + const GLfloat invw1 = vert1->win[3]; GLuint v; for (v = 0; v < MAX_VARYING; v++) { - const GLfloat invw0 = vert0->win[3]; - const GLfloat invw1 = vert1->win[3]; - GLfloat ds, dt, dr, dq; - span.var[v][0] = invw0 * vert0->varying[v][0]; - span.var[v][1] = invw0 * vert0->varying[v][1]; - span.var[v][2] = invw0 * vert0->varying[v][2]; - span.var[v][3] = invw0 * vert0->varying[v][3]; - ds = (invw1 * vert1->varying[v][0]) - span.var[v][0]; - dt = (invw1 * vert1->varying[v][1]) - span.var[v][1]; - dr = (invw1 * vert1->varying[v][2]) - span.var[v][2]; - dq = (invw1 * vert1->varying[v][3]) - span.var[v][3]; - span.varStepX[v][0] = ds * invLen; - span.varStepX[v][1] = dt * invLen; - span.varStepX[v][2] = dr * invLen; - span.varStepX[v][3] = dq * invLen; - span.varStepY[v][0] = 0.0F; - span.varStepY[v][1] = 0.0F; - span.varStepY[v][2] = 0.0F; - span.varStepY[v][3] = 0.0F; + if (inputsUsed & FRAG_BIT_VAR(v)) { + GLfloat ds, dt, dr, dq; + span.var[v][0] = invw0 * vert0->varying[v][0]; + span.var[v][1] = invw0 * vert0->varying[v][1]; + span.var[v][2] = invw0 * vert0->varying[v][2]; + span.var[v][3] = invw0 * vert0->varying[v][3]; + ds = (invw1 * vert1->varying[v][0]) - span.var[v][0]; + dt = (invw1 * vert1->varying[v][1]) - span.var[v][1]; + dr = (invw1 * vert1->varying[v][2]) - span.var[v][2]; + dq = (invw1 * vert1->varying[v][3]) - span.var[v][3]; + span.varStepX[v][0] = ds * invLen; + span.varStepX[v][1] = dt * invLen; + span.varStepX[v][2] = dr * invLen; + span.varStepX[v][3] = dq * invLen; + span.varStepY[v][0] = 0.0F; + span.varStepY[v][1] = 0.0F; + span.varStepY[v][2] = 0.0F; + span.varStepY[v][3] = 0.0F; + } } } #endif diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index c85379b4b1..6ff52b5e4a 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -144,13 +144,15 @@ #ifdef INTERP_VARYING -/* XXX need a varyingEnabled[] check */ + #define VARYING_LOOP(CODE) \ { \ GLuint iv, ic; \ for (iv = 0; iv < MAX_VARYING; iv++) { \ - for (ic = 0; ic < 4; ic++) { \ - CODE \ + if (inputsUsed & FRAG_BIT_VAR(iv)) { \ + for (ic = 0; ic < 4; ic++) { \ + CODE \ + } \ } \ } \ } @@ -216,6 +218,10 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */ #endif GLinterp vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy; +#ifdef INTERP_VARYING + const GLbitfield inputsUsed = ctx->FragmentProgram._Current ? + ctx->FragmentProgram._Current->Base.InputsRead : 0x0; +#endif SWspan span; -- cgit v1.2.3 From 462d8f5fafcc5ac69ea89cac1222abadded642e2 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 2 Feb 2007 09:46:43 -0700 Subject: New span attrStart/attrStepX/attrStepY fields to replace fog, specular, etc. fields. More to come. --- src/mesa/swrast/s_fog.c | 20 +++++------ src/mesa/swrast/s_fragprog.c | 57 +++++++++++++++--------------- src/mesa/swrast/s_linetemp.h | 37 ++++++++++---------- src/mesa/swrast/s_pointtemp.h | 5 +-- src/mesa/swrast/s_span.c | 16 +++++---- src/mesa/swrast/s_span.h | 13 +++---- src/mesa/swrast/s_tritemp.h | 80 +++++++++++++++++++++---------------------- src/mesa/swrast/s_zoom.c | 5 +-- 8 files changed, 118 insertions(+), 115 deletions(-) (limited to 'src/mesa/swrast/s_tritemp.h') diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c index 93d2ab469f..a2bf4c620c 100644 --- a/src/mesa/swrast/s_fog.c +++ b/src/mesa/swrast/s_fog.c @@ -72,8 +72,8 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z) */ #define FOG_LOOP(TYPE, COMPUTE_F) \ do { \ - const GLfloat fogStep = span->fogStep; \ - GLfloat fogCoord = span->fog; \ + 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; \ GLuint i; \ @@ -293,8 +293,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) const GLfloat fogEnd = ctx->Fog.End; const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End) ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start); - const GLfloat fogStep = span->fogStep; - GLfloat fogCoord = span->fog; + 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; GLuint i; @@ -310,8 +310,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) case GL_EXP: { const GLfloat density = -ctx->Fog.Density; - const GLfloat fogStep = span->fogStep; - GLfloat fogCoord = span->fog; + 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; GLuint i; @@ -327,8 +327,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) case GL_EXP2: { const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density; - const GLfloat fogStep = span->fogStep; - GLfloat fogCoord = span->fog; + 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; GLuint i; @@ -368,8 +368,8 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) /* The span's fog start/step values are blend factors. * They were previously computed per-vertex. */ - const GLfloat fogStep = span->fogStep; - GLfloat fog = span->fog; + 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; GLuint i; diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 9ae423dde9..22483c56a6 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -287,27 +287,27 @@ fetch_vector4_deriv( GLcontext *ctx, break; case FRAG_ATTRIB_COL1: if (xOrY == 'X') { - src[0] = span->dsrdx * (1.0F / CHAN_MAXF); - src[1] = span->dsgdx * (1.0F / CHAN_MAXF); - src[2] = span->dsbdx * (1.0F / CHAN_MAXF); - src[3] = 0.0; /* XXX need this */ + src[0] = span->attrStepX[FRAG_ATTRIB_COL1][0] * (1.0F / CHAN_MAXF); + src[1] = span->attrStepX[FRAG_ATTRIB_COL1][1] * (1.0F / CHAN_MAXF); + src[2] = span->attrStepX[FRAG_ATTRIB_COL1][2] * (1.0F / CHAN_MAXF); + src[3] = span->attrStepX[FRAG_ATTRIB_COL1][3] * (1.0F / CHAN_MAXF); } else { - src[0] = span->dsrdy * (1.0F / CHAN_MAXF); - src[1] = span->dsgdy * (1.0F / CHAN_MAXF); - src[2] = span->dsbdy * (1.0F / CHAN_MAXF); - src[3] = 0.0; /* XXX need this */ + src[0] = span->attrStepY[FRAG_ATTRIB_COL1][0] * (1.0F / CHAN_MAXF); + src[1] = span->attrStepY[FRAG_ATTRIB_COL1][1] * (1.0F / CHAN_MAXF); + src[2] = span->attrStepY[FRAG_ATTRIB_COL1][2] * (1.0F / CHAN_MAXF); + src[3] = span->attrStepY[FRAG_ATTRIB_COL1][3] * (1.0F / CHAN_MAXF); } break; case FRAG_ATTRIB_FOGC: if (xOrY == 'X') { - src[0] = span->dfogdx; + src[0] = span->attrStepX[FRAG_ATTRIB_FOGC][0] * (1.0F / CHAN_MAXF); src[1] = 0.0; src[2] = 0.0; src[3] = 0.0; } else { - src[0] = span->dfogdy; + src[0] = span->attrStepY[FRAG_ATTRIB_FOGC][0] * (1.0F / CHAN_MAXF); src[1] = 0.0; src[2] = 0.0; src[3] = 0.0; @@ -589,25 +589,25 @@ init_machine_deriv( GLcontext *ctx, if (program->Base.InputsRead & FRAG_BIT_COL1) { GLfloat *col1 = machine->Attribs[FRAG_ATTRIB_COL1][machine->CurFrag]; if (xOrY == 'X') { - col1[0] += span->dsrdx * (1.0F / CHAN_MAXF); - col1[1] += span->dsgdx * (1.0F / CHAN_MAXF); - col1[2] += span->dsbdx * (1.0F / CHAN_MAXF); - col1[3] += 0.0; /*XXX fix */ + col1[0] += span->attrStepX[FRAG_ATTRIB_COL1][0] * (1.0F / CHAN_MAXF); + col1[1] += span->attrStepX[FRAG_ATTRIB_COL1][1] * (1.0F / CHAN_MAXF); + col1[2] += span->attrStepX[FRAG_ATTRIB_COL1][2] * (1.0F / CHAN_MAXF); + col1[3] += span->attrStepX[FRAG_ATTRIB_COL1][3] * (1.0F / CHAN_MAXF); } else { - col1[0] += span->dsrdy * (1.0F / CHAN_MAXF); - col1[1] += span->dsgdy * (1.0F / CHAN_MAXF); - col1[2] += span->dsbdy * (1.0F / CHAN_MAXF); - col1[3] += 0.0; /*XXX fix */ + col1[0] += span->attrStepY[FRAG_ATTRIB_COL1][0] * (1.0F / CHAN_MAXF); + col1[1] += span->attrStepY[FRAG_ATTRIB_COL1][1] * (1.0F / CHAN_MAXF); + col1[2] += span->attrStepY[FRAG_ATTRIB_COL1][2] * (1.0F / CHAN_MAXF); + col1[3] += span->attrStepY[FRAG_ATTRIB_COL1][3] * (1.0F / CHAN_MAXF); } } if (program->Base.InputsRead & FRAG_BIT_FOGC) { GLfloat *fogc = machine->Attribs[FRAG_ATTRIB_FOGC][machine->CurFrag]; if (xOrY == 'X') { - fogc[0] += span->dfogdx; + fogc[0] += span->attrStepX[FRAG_ATTRIB_FOGC][0]; } else { - fogc[0] += span->dfogdy; + fogc[0] += span->attrStepY[FRAG_ATTRIB_FOGC][0]; } } for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { @@ -632,17 +632,18 @@ init_machine_deriv( GLcontext *ctx, for (v = 0; v < ctx->Const.MaxVarying; v++) { if (program->Base.InputsRead & FRAG_BIT_VAR(v)) { GLfloat *var = machine->Attribs[FRAG_ATTRIB_VAR0 + v][machine->CurFrag]; + GLuint attr = FRAG_ATTRIB_VAR0 + v; if (xOrY == 'X') { - var[0] += span->varStepX[v][0]; - var[1] += span->varStepX[v][1]; - var[2] += span->varStepX[v][2]; - var[3] += span->varStepX[v][3]; + var[0] += span->attrStepX[attr][0]; + var[1] += span->attrStepX[attr][1]; + var[2] += span->attrStepX[attr][2]; + var[3] += span->attrStepX[attr][3]; } else { - var[0] += span->varStepY[v][0]; - var[1] += span->varStepY[v][1]; - var[2] += span->varStepY[v][2]; - var[3] += span->varStepY[v][3]; + var[0] += span->attrStepY[attr][0]; + var[1] += span->attrStepY[attr][1]; + var[2] += span->attrStepY[attr][2]; + var[3] += span->attrStepY[attr][3]; } } } diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index b7b434771e..d68868ded9 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -276,8 +276,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) #endif #ifdef INTERP_FOG interpFlags |= SPAN_FOG; - span.fog = vert0->fog; - span.fogStep = (vert1->fog - vert0->fog) / numPixels; + span.attrStart[FRAG_ATTRIB_FOGC][0] = vert0->fog; + span.attrStepX[FRAG_ATTRIB_FOGC][0] = (vert1->fog - vert0->fog) / numPixels; #endif #ifdef INTERP_TEX interpFlags |= SPAN_TEXTURE; @@ -345,23 +345,24 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) GLuint v; for (v = 0; v < MAX_VARYING; v++) { if (inputsUsed & FRAG_BIT_VAR(v)) { + GLuint attr = FRAG_ATTRIB_VAR0 + v; GLfloat ds, dt, dr, dq; - span.var[v][0] = invw0 * vert0->varying[v][0]; - span.var[v][1] = invw0 * vert0->varying[v][1]; - span.var[v][2] = invw0 * vert0->varying[v][2]; - span.var[v][3] = invw0 * vert0->varying[v][3]; - ds = (invw1 * vert1->varying[v][0]) - span.var[v][0]; - dt = (invw1 * vert1->varying[v][1]) - span.var[v][1]; - dr = (invw1 * vert1->varying[v][2]) - span.var[v][2]; - dq = (invw1 * vert1->varying[v][3]) - span.var[v][3]; - span.varStepX[v][0] = ds * invLen; - span.varStepX[v][1] = dt * invLen; - span.varStepX[v][2] = dr * invLen; - span.varStepX[v][3] = dq * invLen; - span.varStepY[v][0] = 0.0F; - span.varStepY[v][1] = 0.0F; - span.varStepY[v][2] = 0.0F; - span.varStepY[v][3] = 0.0F; + span.attrStart[attr][0] = invw0 * vert0->varying[v][0]; + span.attrStart[attr][1] = invw0 * vert0->varying[v][1]; + span.attrStart[attr][2] = invw0 * vert0->varying[v][2]; + span.attrStart[attr][3] = invw0 * vert0->varying[v][3]; + ds = (invw1 * vert1->varying[v][0]) - span.attrStart[attr][0]; + dt = (invw1 * vert1->varying[v][1]) - span.attrStart[attr][1]; + dr = (invw1 * vert1->varying[v][2]) - span.attrStart[attr][2]; + dq = (invw1 * vert1->varying[v][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; } } } diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index f68630af93..f769f524a0 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -107,8 +107,9 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) */ span->interpMask = SPAN_FOG; span->arrayMask = SPAN_XY | SPAN_Z; - span->fog = vert->fog; - span->fogStep = 0.0; + span->attrStart[FRAG_ATTRIB_FOGC][0] = vert->fog; + span->attrStepX[FRAG_ATTRIB_FOGC][0] = 0.0; + span->attrStepY[FRAG_ATTRIB_FOGC][0] = 0.0; #if FLAGS & RGBA span->arrayMask |= SPAN_RGBA; #endif diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 4a562752a8..52c7501df8 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -75,8 +75,9 @@ _swrast_span_default_z( GLcontext *ctx, SWspan *span ) void _swrast_span_default_fog( GLcontext *ctx, SWspan *span ) { - span->fog = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance); - span->fogStep = span->dfogdx = span->dfogdy = 0.0F; + span->attrStart[FRAG_ATTRIB_FOGC][0] = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance); + span->attrStepX[FRAG_ATTRIB_FOGC][0] = 0.0; + span->attrStepY[FRAG_ATTRIB_FOGC][0] = 0.0; span->interpMask |= SPAN_FOG; } @@ -431,8 +432,8 @@ static INLINE void interpolate_fog(const GLcontext *ctx, SWspan *span) { GLfloat (*fog)[4] = span->array->attribs[FRAG_ATTRIB_FOGC]; - const GLfloat fogStep = span->fogStep; - GLfloat fogCoord = span->fog; + 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; @@ -834,16 +835,17 @@ interpolate_varying(GLcontext *ctx, SWspan *span) for (var = 0; var < MAX_VARYING; var++) { if (inputsUsed & FRAG_BIT_VAR(var)) { + const GLuint attr = FRAG_ATTRIB_VAR0 + var; GLuint j; for (j = 0; j < 4; j++) { - const GLfloat dvdx = span->varStepX[var][j]; - GLfloat v = span->var[var][j]; + const GLfloat dvdx = span->attrStepX[attr][j]; + GLfloat v = span->attrStart[attr][j]; const GLfloat dwdx = span->dwdx; GLfloat w = span->w; GLuint k; for (k = 0; k < span->end; k++) { GLfloat invW = 1.0f / w; - span->array->attribs[FRAG_ATTRIB_VAR0 + var][k][j] = v * invW; + span->array->attribs[attr][k][j] = v * invW; v += dvdx; w += dwdx; } diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index c5f79871f1..f60d4279e1 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -169,14 +169,15 @@ typedef struct sw_span #endif GLfixed index, indexStep; GLfixed z, zStep; /* XXX z should probably be GLuint */ - GLfloat fog, fogStep; 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 */ - GLfloat var[MAX_VARYING][4]; - GLfloat varStepX[MAX_VARYING][4]; - GLfloat varStepY[MAX_VARYING][4]; + + /** 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; @@ -185,10 +186,6 @@ typedef struct sw_span GLfloat dgdx, dgdy; GLfloat dbdx, dbdy; GLfloat dadx, dady; - GLfloat dsrdx, dsrdy; - GLfloat dsgdx, dsgdy; - GLfloat dsbdx, dsbdy; - GLfloat dfogdx, dfogdy; /** * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 6ff52b5e4a..c8fe4b6e9e 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -150,6 +150,7 @@ 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 \ } \ @@ -507,9 +508,8 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, const GLfloat eMaj_dfog = vMax->fog - vMin->fog; const GLfloat eBot_dfog = vMid->fog - vMin->fog; # endif - span.dfogdx = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog); - span.dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx); - span.fogStep = span.dfogdx; + span.attrStepX[FRAG_ATTRIB_FOGC][0] = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog); + span.attrStepY[FRAG_ATTRIB_FOGC][0] = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx); } #endif #ifdef INTERP_RGB @@ -584,26 +584,26 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, GLfloat eBot_dsg = (GLfloat) ((ColorTemp) vMid->specular[GCOMP] - (ColorTemp) vMin->specular[GCOMP]); GLfloat eMaj_dsb = (GLfloat) ((ColorTemp) vMax->specular[BCOMP] - (ColorTemp) vMin->specular[BCOMP]); GLfloat eBot_dsb = (GLfloat) ((ColorTemp) vMid->specular[BCOMP] - (ColorTemp) vMin->specular[BCOMP]); - span.dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr); - span.dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx); - span.dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg); - span.dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx); - span.dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb); - span.dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx); + span.attrStepX[FRAG_ATTRIB_COL1][0] = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr); + span.attrStepY[FRAG_ATTRIB_COL1][0] = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx); + span.attrStepX[FRAG_ATTRIB_COL1][1] = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg); + span.attrStepY[FRAG_ATTRIB_COL1][1] = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx); + span.attrStepX[FRAG_ATTRIB_COL1][2] = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb); + span.attrStepY[FRAG_ATTRIB_COL1][2] = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx); # if CHAN_TYPE == GL_FLOAT - span.specRedStep = span.dsrdx; + span.specRedStep = span.attrStep[FRAG_ATTRIB_COL1][0]; span.specGreenStep = span.dsgdx; span.specBlueStep = span.dsbdx; # else - span.specRedStep = SignedFloatToFixed(span.dsrdx); - span.specGreenStep = SignedFloatToFixed(span.dsgdx); - span.specBlueStep = SignedFloatToFixed(span.dsbdx); + span.specRedStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL1][0]); + span.specGreenStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL1][1]); + span.specBlueStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL1][2]); # endif } else { - span.dsrdx = span.dsrdy = 0.0F; - span.dsgdx = span.dsgdy = 0.0F; - span.dsbdx = span.dsbdy = 0.0F; + span.attrStepX[FRAG_ATTRIB_COL1][0] = span.attrStepY[FRAG_ATTRIB_COL1][0] = 0.0F; + span.attrStepX[FRAG_ATTRIB_COL1][1] = span.attrStepY[FRAG_ATTRIB_COL1][1] = 0.0F; + span.attrStepX[FRAG_ATTRIB_COL1][2] = span.attrStepY[FRAG_ATTRIB_COL1][2] = 0.0F; # if CHAN_TYPE == GL_FLOAT span.specRedStep = 0.0F; span.specGreenStep = 0.0F; @@ -678,8 +678,8 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, VARYING_LOOP( GLfloat eMaj_dvar = vMax->varying[iv][ic] * wMax - vMin->varying[iv][ic] * wMin; GLfloat eBot_dvar = vMid->varying[iv][ic] * wMid - vMin->varying[iv][ic] * wMin; - span.varStepX[iv][ic] = oneOverArea * (eMaj_dvar * eBot.dy - eMaj.dy * eBot_dvar); - span.varStepY[iv][ic] = oneOverArea * (eMaj.dx * eBot_dvar - eMaj_dvar * eBot.dx); + span.attrStepX[attr][ic] = oneOverArea * (eMaj_dvar * eBot.dy - eMaj.dy * eBot_dvar); + span.attrStepY[attr][ic] = oneOverArea * (eMaj.dx * eBot_dvar - eMaj_dvar * eBot.dx); ) } #endif @@ -928,11 +928,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #endif #ifdef INTERP_FOG # ifdef INTERP_W - fogLeft = vLower->fog * vLower->win[3] + (span.dfogdx * adjx + span.dfogdy * adjy) * (1.0F/FIXED_SCALE); + fogLeft = vLower->fog * vLower->win[3] + (span.attrStepX[FRAG_ATTRIB_FOGC][0] * adjx + span.attrStepY[FRAG_ATTRIB_FOGC][0] * adjy) * (1.0F/FIXED_SCALE); # else - fogLeft = vLower->fog + (span.dfogdx * adjx + span.dfogdy * adjy) * (1.0F/FIXED_SCALE); + fogLeft = vLower->fog + (span.attrStepX[FRAG_ATTRIB_FOGC][0] * adjx + span.attrStepY[FRAG_ATTRIB_FOGC][0] * adjy) * (1.0F/FIXED_SCALE); # endif - dfogOuter = span.dfogdy + dxOuter * span.dfogdx; + dfogOuter = span.attrStepY[FRAG_ATTRIB_FOGC][0] + dxOuter * span.attrStepX[FRAG_ATTRIB_FOGC][0]; #endif #ifdef INTERP_RGB if (ctx->Light.ShadeModel == GL_SMOOTH) { @@ -990,19 +990,19 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_SPEC if (ctx->Light.ShadeModel == GL_SMOOTH) { # if CHAN_TYPE == GL_FLOAT - srLeft = vLower->specular[RCOMP] + (span.dsrdx * adjx + span.dsrdy * adjy) * (1.0F / FIXED_SCALE); - sgLeft = vLower->specular[GCOMP] + (span.dsgdx * adjx + span.dsgdy * adjy) * (1.0F / FIXED_SCALE); - sbLeft = vLower->specular[BCOMP] + (span.dsbdx * adjx + span.dsbdy * adjy) * (1.0F / FIXED_SCALE); - dsrOuter = span.dsrdy + dxOuter * span.dsrdx; - dsgOuter = span.dsgdy + dxOuter * span.dsgdx; - dsbOuter = span.dsbdy + dxOuter * span.dsbdx; + srLeft = vLower->specular[RCOMP] + (span.attrStepX[FRAG_ATTRIB_COL1][0] * adjx + span.attrStepY[FRAG_ATTRIB_COL1][0] * adjy) * (1.0F / FIXED_SCALE); + sgLeft = vLower->specular[GCOMP] + (span.attrStepX[FRAG_ATTRIB_COL1][1] * adjx + span.attrStepY[FRAG_ATTRIB_COL1][1] * adjy) * (1.0F / FIXED_SCALE); + sbLeft = vLower->specular[BCOMP] + (span.attrStepX[FRAG_ATTRIB_COL1][2] * adjx + span.attrStepY[FRAG_ATTRIB_COL1][2] * adjy) * (1.0F / FIXED_SCALE); + dsrOuter = span.attrStepY[FRAG_ATTRIB_COL1][0] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL1][0]; + dsgOuter = span.attrStepY[FRAG_ATTRIB_COL1][1] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL1][1]; + dsbOuter = span.attrStepY[FRAG_ATTRIB_COL1][2] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL1][2]; # else - srLeft = (GLfixed) (ChanToFixed(vLower->specular[RCOMP]) + span.dsrdx * adjx + span.dsrdy * adjy) + FIXED_HALF; - sgLeft = (GLfixed) (ChanToFixed(vLower->specular[GCOMP]) + span.dsgdx * adjx + span.dsgdy * adjy) + FIXED_HALF; - sbLeft = (GLfixed) (ChanToFixed(vLower->specular[BCOMP]) + span.dsbdx * adjx + span.dsbdy * adjy) + FIXED_HALF; - dsrOuter = SignedFloatToFixed(span.dsrdy + dxOuter * span.dsrdx); - dsgOuter = SignedFloatToFixed(span.dsgdy + dxOuter * span.dsgdx); - dsbOuter = SignedFloatToFixed(span.dsbdy + dxOuter * span.dsbdx); + srLeft = (GLfixed) (ChanToFixed(vLower->specular[RCOMP]) + span.attrStepX[FRAG_ATTRIB_COL1][0] * adjx + span.attrStepY[FRAG_ATTRIB_COL1][0] * adjy) + FIXED_HALF; + sgLeft = (GLfixed) (ChanToFixed(vLower->specular[GCOMP]) + span.attrStepX[FRAG_ATTRIB_COL1][1] * adjx + span.attrStepY[FRAG_ATTRIB_COL1][1] * adjy) + FIXED_HALF; + sbLeft = (GLfixed) (ChanToFixed(vLower->specular[BCOMP]) + span.attrStepX[FRAG_ATTRIB_COL1][2] * adjx + span.attrStepY[FRAG_ATTRIB_COL1][2] * adjy) + FIXED_HALF; + dsrOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL1][0] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL1][0]); + dsgOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL1][1] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL1][1]); + dsbOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL1][2] + dxOuter * span.attrStepX[FRAG_ATTRIB_COL1][2]); # endif } else { @@ -1068,9 +1068,9 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, VARYING_LOOP( const GLfloat invW = vLower->win[3]; const GLfloat var0 = vLower->varying[iv][ic] * invW; - varLeft[iv][ic] = var0 + (span.varStepX[iv][ic] * adjx + - span.varStepY[iv][ic] * adjy) * (1.0f / FIXED_SCALE); - dvarOuter[iv][ic] = span.varStepY[iv][ic] + dxOuter * span.varStepX[iv][ic]; + varLeft[iv][ic] = var0 + (span.attrStepX[attr][ic] * adjx + + span.attrStepY[attr][ic] * adjy) * (1.0f / FIXED_SCALE); + dvarOuter[iv][ic] = span.attrStepY[attr][ic] + dxOuter * span.attrStepX[attr][ic]; ) #endif } /*if setupLeft*/ @@ -1105,7 +1105,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, dwInner = dwOuter + span.dwdx; #endif #ifdef INTERP_FOG - dfogInner = dfogOuter + span.dfogdx; + dfogInner = dfogOuter + span.attrStepX[FRAG_ATTRIB_FOGC][0]; #endif #ifdef INTERP_RGB fdrInner = fdrOuter + span.redStep; @@ -1137,7 +1137,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #endif #ifdef INTERP_VARYING VARYING_LOOP( - dvarInner[iv][ic] = dvarOuter[iv][ic] + span.varStepX[iv][ic]; + dvarInner[iv][ic] = dvarOuter[iv][ic] + span.attrStepX[attr][ic]; ) #endif @@ -1158,7 +1158,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, span.w = wLeft; #endif #ifdef INTERP_FOG - span.fog = fogLeft; + span.attrStart[FRAG_ATTRIB_FOGC][0] = fogLeft; #endif #ifdef INTERP_RGB span.red = rLeft; @@ -1191,7 +1191,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #endif #ifdef INTERP_VARYING VARYING_LOOP( - span.var[iv][ic] = varLeft[iv][ic]; + span.attrStart[attr][ic] = varLeft[iv][ic]; ) #endif diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 34732a67e6..a4e8d9a36f 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -159,8 +159,9 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, /* copy fog interp info */ - zoomed.fog = span->fog; - zoomed.fogStep = span->fogStep; + zoomed.attrStart[FRAG_ATTRIB_FOGC][0] = span->attrStart[FRAG_ATTRIB_FOGC][0]; + zoomed.attrStepX[FRAG_ATTRIB_FOGC][0] = span->attrStepX[FRAG_ATTRIB_FOGC][0]; + zoomed.attrStepY[FRAG_ATTRIB_FOGC][0] = span->attrStepY[FRAG_ATTRIB_FOGC][0]; /* XXX copy texcoord info? */ if (format == GL_RGBA || format == GL_RGB) { -- cgit v1.2.3 From 9ab512ad8cf3a12f4f7f8494fa99bc9389f217db Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 2 Feb 2007 11:01:01 -0700 Subject: Replace color, z, w, texture interpolants with new generic attrib interpolants. --- src/mesa/swrast/s_fog.c | 20 ++-- src/mesa/swrast/s_fragprog.c | 91 +++++++++--------- src/mesa/swrast/s_linetemp.h | 71 +++++++------- src/mesa/swrast/s_pointtemp.h | 6 +- src/mesa/swrast/s_span.c | 121 ++++++++++++------------ src/mesa/swrast/s_span.h | 26 ++---- src/mesa/swrast/s_triangle.c | 14 +-- src/mesa/swrast/s_tritemp.h | 208 ++++++++++++++++++++++-------------------- 8 files changed, 280 insertions(+), 277 deletions(-) (limited to 'src/mesa/swrast/s_tritemp.h') 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 -- cgit v1.2.3 From dd34fe8679fa200e55cfaf8e80bbecdecea084e3 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 5 Feb 2007 10:10:01 -0700 Subject: Merge SWvertex texcoord and varying fields into attrib[] array field. Fragment texcoords and varying code is now unified in the point/line/triangle rasterization code. In the future, merge color, fog, etc. attribs. --- src/mesa/swrast/s_aaline.c | 51 ++++----- src/mesa/swrast/s_aalinetemp.h | 121 ++++++++------------ src/mesa/swrast/s_aatriangle.c | 52 ++------- src/mesa/swrast/s_aatritemp.h | 217 ++++++++++++++--------------------- src/mesa/swrast/s_context.c | 56 ++++++++- src/mesa/swrast/s_context.h | 7 ++ src/mesa/swrast/s_feedback.c | 17 ++- src/mesa/swrast/s_linetemp.h | 81 ++++--------- src/mesa/swrast/s_pointtemp.h | 59 +++++----- src/mesa/swrast/s_triangle.c | 31 +---- src/mesa/swrast/s_tritemp.h | 229 ++++++++++++------------------------- src/mesa/swrast/swrast.h | 3 +- src/mesa/swrast_setup/ss_context.c | 13 ++- 13 files changed, 372 insertions(+), 565 deletions(-) (limited to 'src/mesa/swrast/s_tritemp.h') diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index b3a209923f..c81095163b 100644 --- a/src/mesa/swrast/s_aaline.c +++ b/src/mesa/swrast/s_aaline.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -67,14 +67,14 @@ struct LineInfo GLfloat iPlane[4]; /* DO_SPEC */ GLfloat srPlane[4], sgPlane[4], sbPlane[4]; - /* DO_TEX or DO_MULTITEX */ - GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; - GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; - GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; - GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; - GLfloat lambda[MAX_TEXTURE_COORD_UNITS]; - GLfloat texWidth[MAX_TEXTURE_COORD_UNITS]; - GLfloat texHeight[MAX_TEXTURE_COORD_UNITS]; + /* DO_TEXVAR */ + GLfloat sPlane[FRAG_ATTRIB_MAX][4]; + GLfloat tPlane[FRAG_ATTRIB_MAX][4]; + GLfloat uPlane[FRAG_ATTRIB_MAX][4]; + GLfloat vPlane[FRAG_ATTRIB_MAX][4]; + GLfloat lambda[FRAG_ATTRIB_MAX]; + GLfloat texWidth[FRAG_ATTRIB_MAX]; + GLfloat texHeight[FRAG_ATTRIB_MAX]; SWspan span; }; @@ -499,15 +499,7 @@ segment(GLcontext *ctx, #define DO_Z #define DO_FOG #define DO_RGBA -#define DO_TEX -#include "s_aalinetemp.h" - - -#define NAME(x) aa_multitex_rgba_##x -#define DO_Z -#define DO_FOG -#define DO_RGBA -#define DO_MULTITEX +#define DO_TEXVAR #include "s_aalinetemp.h" @@ -515,7 +507,7 @@ segment(GLcontext *ctx, #define DO_Z #define DO_FOG #define DO_RGBA -#define DO_MULTITEX +#define DO_TEXVAR #define DO_SPEC #include "s_aalinetemp.h" @@ -530,18 +522,15 @@ _swrast_choose_aa_line_function(GLcontext *ctx) if (ctx->Visual.rgbMode) { /* RGBA */ - if (ctx->Texture._EnabledCoordUnits != 0) { - if (ctx->Texture._EnabledCoordUnits > 1) { - /* Multitextured! */ - if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR || - ctx->Fog.ColorSumEnabled) - swrast->Line = aa_multitex_spec_line; - else - swrast->Line = aa_multitex_rgba_line; - } - else { + if (ctx->Texture._EnabledCoordUnits != 0 + || ctx->FragmentProgram._Current) { + + if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR || + ctx->Fog.ColorSumEnabled) + swrast->Line = aa_multitex_spec_line; + else swrast->Line = aa_tex_rgba_line; - } + } else { swrast->Line = aa_rgba_line; diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index b977ab8325..4d33b7dff7 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.3 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -36,6 +36,7 @@ static void NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) { + const SWcontext *swrast = SWRAST_CONTEXT(ctx); const GLfloat fx = (GLfloat) ix; const GLfloat fy = (GLfloat) iy; #ifdef DO_INDEX @@ -45,6 +46,8 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) #endif const GLuint i = line->span.end; + (void) swrast; + if (coverage == 0.0) return; @@ -77,41 +80,29 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) line->span.array->spec[i][GCOMP] = solve_plane_chan(fx, fy, line->sgPlane); line->span.array->spec[i][BCOMP] = solve_plane_chan(fx, fy, line->sbPlane); #endif -#ifdef DO_TEX - { - GLfloat invQ; - if (ctx->FragmentProgram._Current) { - invQ = 1.0F; - } - else { - invQ = solve_plane_recip(fx, fy, line->vPlane[0]); - } - line->span.array->attribs[FRAG_ATTRIB_TEX0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ; - line->span.array->attribs[FRAG_ATTRIB_TEX0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ; - line->span.array->attribs[FRAG_ATTRIB_TEX0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ; - line->span.array->lambda[0][i] = compute_lambda(line->sPlane[0], - line->tPlane[0], invQ, - line->texWidth[0], - line->texHeight[0]); - } -#elif defined(DO_MULTITEX) +#if defined(DO_TEXVAR) { - GLuint unit; - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled) { + 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._Current) { invQ = 1.0F; } else { - invQ = solve_plane_recip(fx, fy, line->vPlane[unit]); + 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]); } - line->span.array->attribs[FRAG_ATTRIB_TEX0 + unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ; - line->span.array->attribs[FRAG_ATTRIB_TEX0 + unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ; - line->span.array->attribs[FRAG_ATTRIB_TEX0 + unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ; - line->span.array->lambda[unit][i] = compute_lambda(line->sPlane[unit], - line->tPlane[unit], invQ, - line->texWidth[unit], line->texHeight[unit]); } } } @@ -214,52 +205,33 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) constant_plane(v1->index, line.iPlane); } #endif -#ifdef DO_TEX +#if defined(DO_TEXVAR) { - const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; + GLuint attr; const GLfloat invW0 = v0->win[3]; const GLfloat invW1 = v1->win[3]; - const GLfloat s0 = v0->texcoord[0][0] * invW0; - const GLfloat s1 = v1->texcoord[0][0] * invW1; - const GLfloat t0 = v0->texcoord[0][1] * invW0; - const GLfloat t1 = v1->texcoord[0][1] * invW1; - const GLfloat r0 = v0->texcoord[0][2] * invW0; - const GLfloat r1 = v1->texcoord[0][2] * invW1; - const GLfloat q0 = v0->texcoord[0][3] * invW0; - const GLfloat q1 = v1->texcoord[0][3] * invW1; - line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); - compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[0]); - compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[0]); - compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[0]); - compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[0]); - line.texWidth[0] = (GLfloat) texImage->Width; - line.texHeight[0] = (GLfloat) texImage->Height; - } -#elif defined(DO_MULTITEX) - { - GLuint u; - line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; - const GLfloat invW0 = v0->win[3]; - const GLfloat invW1 = v1->win[3]; - const GLfloat s0 = v0->texcoord[u][0] * invW0; - const GLfloat s1 = v1->texcoord[u][0] * invW1; - const GLfloat t0 = v0->texcoord[u][1] * invW0; - const GLfloat t1 = v1->texcoord[u][1] * invW1; - const GLfloat r0 = v0->texcoord[u][2] * invW0; - const GLfloat r1 = v1->texcoord[u][2] * invW1; - const GLfloat q0 = v0->texcoord[u][3] * invW0; - const GLfloat q1 = v1->texcoord[u][3] * invW1; - compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[u]); - compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[u]); - compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[u]); - compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[u]); - line.texWidth[u] = (GLfloat) texImage->Width; - line.texHeight[u] = (GLfloat) texImage->Height; + 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; + line.texHeight[attr] = (GLfloat) texImage->Height; + } } } } @@ -324,6 +296,5 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) #undef DO_RGBA #undef DO_INDEX #undef DO_SPEC -#undef DO_TEX -#undef DO_MULTITEX +#undef DO_TEXVAR #undef NAME diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index 63a13cf3fb..5e3059af93 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 6.5.3 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -408,7 +408,7 @@ tex_aa_tri(GLcontext *ctx, #define DO_Z #define DO_FOG #define DO_RGBA -#define DO_TEX +#define DO_TEXVAR #include "s_aatritemp.h" } @@ -422,39 +422,12 @@ spec_tex_aa_tri(GLcontext *ctx, #define DO_Z #define DO_FOG #define DO_RGBA -#define DO_TEX +#define DO_TEXVAR #define DO_SPEC #include "s_aatritemp.h" } -static void -multitex_aa_tri(GLcontext *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ -#define DO_Z -#define DO_FOG -#define DO_RGBA -#define DO_MULTITEX -#include "s_aatritemp.h" -} - -static void -spec_multitex_aa_tri(GLcontext *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ -#define DO_Z -#define DO_FOG -#define DO_RGBA -#define DO_MULTITEX -#define DO_SPEC -#include "s_aatritemp.h" -} - /* * Examine GL state and set swrast->Triangle to an @@ -465,22 +438,13 @@ _swrast_set_aa_triangle_function(GLcontext *ctx) { ASSERT(ctx->Polygon.SmoothFlag); - if (ctx->Texture._EnabledCoordUnits != 0) { + if (ctx->Texture._EnabledCoordUnits != 0 + || ctx->FragmentProgram._Current) { if (NEED_SECONDARY_COLOR(ctx)) { - if (ctx->Texture._EnabledCoordUnits > 1) { - SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri; - } - else { - SWRAST_CONTEXT(ctx)->Triangle = spec_tex_aa_tri; - } + SWRAST_CONTEXT(ctx)->Triangle = spec_tex_aa_tri; } else { - if (ctx->Texture._EnabledCoordUnits > 1) { - SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri; - } - else { - SWRAST_CONTEXT(ctx)->Triangle = tex_aa_tri; - } + SWRAST_CONTEXT(ctx)->Triangle = tex_aa_tri; } } else if (ctx->Visual.rgbMode) { diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 3359a919e5..bbf9cc611d 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.3 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -36,12 +36,12 @@ * DO_RGBA - if defined, compute RGBA values * DO_INDEX - if defined, compute color index values * DO_SPEC - if defined, compute specular RGB values - * DO_TEX - if defined, compute unit 0 STRQ texcoords - * DO_MULTITEX - if defined, compute all unit's STRQ texcoords + * DO_TEXVAR - if defined, compute texcoords, varying */ /*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ { + const SWcontext *swrast = SWRAST_CONTEXT(ctx); const GLfloat *p0 = v0->win; const GLfloat *p1 = v1->win; const GLfloat *p2 = v2->win; @@ -70,20 +70,18 @@ #ifdef DO_SPEC GLfloat srPlane[4], sgPlane[4], sbPlane[4]; #endif -#ifdef DO_TEX - GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4]; - GLfloat texWidth, texHeight; -#elif defined(DO_MULTITEX) - GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture S */ - GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture T */ - GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture R */ - GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture Q */ - GLfloat texWidth[MAX_TEXTURE_COORD_UNITS]; - GLfloat texHeight[MAX_TEXTURE_COORD_UNITS]; +#if defined(DO_TEXVAR) + GLfloat sPlane[FRAG_ATTRIB_MAX][4]; /* texture S */ + GLfloat tPlane[FRAG_ATTRIB_MAX][4]; /* texture T */ + GLfloat uPlane[FRAG_ATTRIB_MAX][4]; /* texture R */ + GLfloat vPlane[FRAG_ATTRIB_MAX][4]; /* texture Q */ + GLfloat texWidth[FRAG_ATTRIB_MAX]; + GLfloat texHeight[FRAG_ATTRIB_MAX]; #endif GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign; - + (void) swrast; + INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE); /* determine bottom to top order of vertices */ @@ -179,65 +177,44 @@ } span.arrayMask |= SPAN_SPEC; #endif -#ifdef DO_TEX +#if defined(DO_TEXVAR) { - const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; + GLuint attr; const GLfloat invW0 = v0->win[3]; const GLfloat invW1 = v1->win[3]; const GLfloat invW2 = v2->win[3]; - const GLfloat s0 = v0->texcoord[0][0] * invW0; - const GLfloat s1 = v1->texcoord[0][0] * invW1; - const GLfloat s2 = v2->texcoord[0][0] * invW2; - const GLfloat t0 = v0->texcoord[0][1] * invW0; - const GLfloat t1 = v1->texcoord[0][1] * invW1; - const GLfloat t2 = v2->texcoord[0][1] * invW2; - const GLfloat r0 = v0->texcoord[0][2] * invW0; - const GLfloat r1 = v1->texcoord[0][2] * invW1; - const GLfloat r2 = v2->texcoord[0][2] * invW2; - const GLfloat q0 = v0->texcoord[0][3] * invW0; - const GLfloat q1 = v1->texcoord[0][3] * invW1; - const GLfloat q2 = v2->texcoord[0][3] * invW2; - compute_plane(p0, p1, p2, s0, s1, s2, sPlane); - compute_plane(p0, p1, p2, t0, t1, t2, tPlane); - compute_plane(p0, p1, p2, r0, r1, r2, uPlane); - compute_plane(p0, p1, p2, q0, q1, q2, vPlane); - texWidth = (GLfloat) texImage->Width; - texHeight = (GLfloat) texImage->Height; - } - span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); -#elif defined(DO_MULTITEX) - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; - const GLfloat invW0 = v0->win[3]; - const GLfloat invW1 = v1->win[3]; - const GLfloat invW2 = v2->win[3]; - const GLfloat s0 = v0->texcoord[u][0] * invW0; - const GLfloat s1 = v1->texcoord[u][0] * invW1; - const GLfloat s2 = v2->texcoord[u][0] * invW2; - const GLfloat t0 = v0->texcoord[u][1] * invW0; - const GLfloat t1 = v1->texcoord[u][1] * invW1; - const GLfloat t2 = v2->texcoord[u][1] * invW2; - const GLfloat r0 = v0->texcoord[u][2] * invW0; - const GLfloat r1 = v1->texcoord[u][2] * invW1; - const GLfloat r2 = v2->texcoord[u][2] * invW2; - const GLfloat q0 = v0->texcoord[u][3] * invW0; - const GLfloat q1 = v1->texcoord[u][3] * invW1; - const GLfloat q2 = v2->texcoord[u][3] * invW2; - compute_plane(p0, p1, p2, s0, s1, s2, sPlane[u]); - compute_plane(p0, p1, p2, t0, t1, t2, tPlane[u]); - compute_plane(p0, p1, p2, r0, r1, r2, uPlane[u]); - compute_plane(p0, p1, p2, q0, q1, q2, vPlane[u]); - texWidth[u] = (GLfloat) texImage->Width; - texHeight[u] = (GLfloat) texImage->Height; + 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; + } } } } - span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); + span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA | SPAN_VARYING); #endif /* Begin bottom-to-top scan over the triangle. @@ -305,28 +282,21 @@ array->spec[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane); array->spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane); #endif -#ifdef DO_TEX +#if defined(DO_TEXVAR) { - const GLfloat invQ = solve_plane_recip(cx, cy, vPlane); - array->attribs[FRAG_ATTRIB_TEX0 + 0][count][0] = solve_plane(cx, cy, sPlane) * invQ; - array->attribs[FRAG_ATTRIB_TEX0 + 0][count][1] = solve_plane(cx, cy, tPlane) * invQ; - array->attribs[FRAG_ATTRIB_TEX0 + 0][count][2] = solve_plane(cx, cy, uPlane) * invQ; - array->lambda[0][count] = compute_lambda(sPlane, tPlane, vPlane, - cx, cy, invQ, - texWidth, texHeight); - } -#elif defined(DO_MULTITEX) - { - GLuint unit; - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled) { - GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); - array->attribs[FRAG_ATTRIB_TEX0 + unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ; - array->attribs[FRAG_ATTRIB_TEX0 + unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ; - array->attribs[FRAG_ATTRIB_TEX0 + unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ; - array->lambda[unit][count] = compute_lambda(sPlane[unit], - tPlane[unit], vPlane[unit], cx, cy, invQ, - texWidth[unit], texHeight[unit]); + 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]); + } } } } @@ -409,30 +379,24 @@ array->spec[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane); array->spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane); #endif -#ifdef DO_TEX - { - const GLfloat invQ = solve_plane_recip(cx, cy, vPlane); - array->attribs[FRAG_ATTRIB_TEX0][ix][0] = solve_plane(cx, cy, sPlane) * invQ; - array->attribs[FRAG_ATTRIB_TEX0][ix][1] = solve_plane(cx, cy, tPlane) * invQ; - array->attribs[FRAG_ATTRIB_TEX0][ix][2] = solve_plane(cx, cy, uPlane) * invQ; - array->lambda[0][ix] = compute_lambda(sPlane, tPlane, vPlane, - cx, cy, invQ, texWidth, texHeight); - } -#elif defined(DO_MULTITEX) +#if defined(DO_TEXVAR) { - GLuint unit; - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled) { - GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); - array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ; - array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ; - array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ; - array->lambda[unit][ix] = compute_lambda(sPlane[unit], - tPlane[unit], - vPlane[unit], - cx, cy, invQ, - texWidth[unit], - texHeight[unit]); + 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]); + } } } } @@ -471,28 +435,25 @@ array->attribs[FRAG_ATTRIB_FOGC][j][0] = array->attribs[FRAG_ATTRIB_FOGC][j + left][0]; #endif -#ifdef DO_TEX - COPY_4V(array->attribs[FRAG_ATTRIB_TEX0 + 0][j], array->attribs[FRAG_ATTRIB_TEX0 + 0][j + left]); -#endif -#if defined(DO_MULTITEX) || defined(DO_TEX) +#if defined(DO_TEXVAR) array->lambda[0][j] = array->lambda[0][j + left]; #endif array->coverage[j] = array->coverage[j + left]; } } -#ifdef DO_MULTITEX - /* shift texcoords */ +#ifdef DO_TEXVAR + /* shift texcoords, varying */ { SWspanarrays *array = span.array; - GLuint unit; - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled) { + 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[FRAG_ATTRIB_TEX0 + unit][j][0] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][0]; - array->attribs[FRAG_ATTRIB_TEX0 + unit][j][1] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][1]; - array->attribs[FRAG_ATTRIB_TEX0 + unit][j][2] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][2]; - array->lambda[unit][j] = array->lambda[unit][j + left]; + 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];*/ } } } @@ -533,12 +494,8 @@ #undef DO_SPEC #endif -#ifdef DO_TEX -#undef DO_TEX -#endif - -#ifdef DO_MULTITEX -#undef DO_MULTITEX +#ifdef DO_TEXVAR +#undef DO_TEXVAR #endif #ifdef DO_OCCLUSION_TEST diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index ec2f3d68b8..d8a5520f6b 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -507,6 +507,50 @@ _swrast_update_texture_samplers(GLcontext *ctx) } +/** + * Update the swrast->_FragmentAttribs field. + */ +static void +_swrast_update_fragment_attribs(GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + if (ctx->FragmentProgram._Current) { + swrast->_FragmentAttribs + = ctx->FragmentProgram._Current->Base.InputsRead; + } + else { + GLuint u; + swrast->_FragmentAttribs = 0x0; + + if (ctx->Depth.Test) + swrast->_FragmentAttribs |= FRAG_BIT_WPOS; + if (NEED_SECONDARY_COLOR(ctx)) + swrast->_FragmentAttribs |= FRAG_BIT_COL1; + if (swrast->_FogEnabled) + swrast->_FragmentAttribs |= FRAG_BIT_FOGC; + + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + swrast->_FragmentAttribs |= FRAG_BIT_TEX(u); + } + } + } + + /* Find lowest, highest bit set in _FragmentAttribs */ + { + GLuint bits = swrast->_FragmentAttribs; + GLuint i = 0;; + while (bits) { + i++; + bits = bits >> 1; + } + swrast->_MaxFragmentAttrib = i; + swrast->_MinFragmentAttrib = FRAG_ATTRIB_TEX0; /* XXX temporary */ + } +} + + void _swrast_validate_derived( GLcontext *ctx ) { @@ -547,6 +591,12 @@ _swrast_validate_derived( GLcontext *ctx ) if (swrast->NewState & _SWRAST_NEW_RASTERMASK) _swrast_update_rasterflags( ctx ); + if (swrast->NewState & (_NEW_DEPTH | + _NEW_FOG | + _NEW_PROGRAM | + _NEW_TEXTURE)) + _swrast_update_fragment_attribs(ctx); + swrast->NewState = 0; swrast->StateChanges = 0; swrast->InvalidateState = _swrast_invalidate_state; @@ -806,8 +856,10 @@ _swrast_print_vertex( GLcontext *ctx, const SWvertex *v ) for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) if (ctx->Texture.Unit[i]._ReallyEnabled) _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i, - v->texcoord[i][0], v->texcoord[i][1], - v->texcoord[i][2], v->texcoord[i][3]); + v->attrib[FRAG_ATTRIB_TEX0 + i][0], + v->attrib[FRAG_ATTRIB_TEX0 + i][1], + v->attrib[FRAG_ATTRIB_TEX0 + i][2], + v->attrib[FRAG_ATTRIB_TEX0 + i][3]); #if CHAN_TYPE == GL_FLOAT _mesa_debug(ctx, "color %f %f %f %f\n", diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index b15a22dbf0..a3f61cd5e5 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -133,6 +133,13 @@ typedef struct GLboolean _FogEnabled; GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */ + /** 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 */ + /* Accum buffer temporaries. */ GLboolean _IntegerAccumMode; /**< Storing unscaled integers? */ diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c index 26cb05cd56..5d3fbdfeb6 100644 --- a/src/mesa/swrast/s_feedback.c +++ b/src/mesa/swrast/s_feedback.c @@ -46,10 +46,10 @@ static void feedback_vertex( GLcontext *ctx, const SWvertex *v, const SWvertex *pv ) { - const GLuint texUnit = 0; /* See section 5.3 of 1.2.1 spec */ GLfloat win[4]; GLfloat color[4]; GLfloat tc[4]; + const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX0]; win[0] = v->win[0]; win[1] = v->win[1]; @@ -61,16 +61,15 @@ static void feedback_vertex( GLcontext *ctx, color[2] = CHAN_TO_FLOAT(pv->color[2]); color[3] = CHAN_TO_FLOAT(pv->color[3]); - if (v->texcoord[texUnit][3] != 1.0 && - v->texcoord[texUnit][3] != 0.0) { - GLfloat invq = 1.0F / v->texcoord[texUnit][3]; - tc[0] = v->texcoord[texUnit][0] * invq; - tc[1] = v->texcoord[texUnit][1] * invq; - tc[2] = v->texcoord[texUnit][2] * invq; - tc[3] = v->texcoord[texUnit][3]; + if (vtc[3] != 1.0 && vtc[3] != 0.0) { + GLfloat invq = 1.0F / vtc[3]; + tc[0] = vtc[0] * invq; + tc[1] = vtc[1] * invq; + tc[2] = vtc[2] * invq; + tc[3] = vtc[3]; } else { - COPY_4V(tc, v->texcoord[texUnit]); + COPY_4V(tc, vtc); } _mesa_feedback_vertex( ctx, win, color, (GLfloat) v->index, tc ); diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index e3ca4bd0ac..d2f37bf391 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -71,6 +71,7 @@ static void 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]; @@ -99,6 +100,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) SETUP_CODE #endif + (void) swrast; + /* Cull primitives with malformed coordinates. */ { @@ -286,14 +289,14 @@ 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.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.attrStart[FRAG_ATTRIB_TEX0][0] = invw0 * vert0->attrib[FRAG_ATTRIB_TEX0][0]; + span.attrStart[FRAG_ATTRIB_TEX0][1] = invw0 * vert0->attrib[FRAG_ATTRIB_TEX0][1]; + span.attrStart[FRAG_ATTRIB_TEX0][2] = invw0 * vert0->attrib[FRAG_ATTRIB_TEX0][2]; + span.attrStart[FRAG_ATTRIB_TEX0][3] = invw0 * vert0->attrib[FRAG_ATTRIB_TEX0][3]; + ds = (invw1 * vert1->attrib[FRAG_ATTRIB_TEX0][0]) - span.attrStart[FRAG_ATTRIB_TEX0][0]; + dt = (invw1 * vert1->attrib[FRAG_ATTRIB_TEX0][1]) - span.attrStart[FRAG_ATTRIB_TEX0][1]; + dr = (invw1 * vert1->attrib[FRAG_ATTRIB_TEX0][2]) - span.attrStart[FRAG_ATTRIB_TEX0][2]; + dq = (invw1 * vert1->attrib[FRAG_ATTRIB_TEX0][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; @@ -304,58 +307,24 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) span.attrStepY[FRAG_ATTRIB_TEX0][3] = 0.0F; } #endif -#ifdef INTERP_MULTITEX - interpFlags |= SPAN_TEXTURE; +#if defined(INTERP_MULTITEX) || defined(INTERP_VARYING) + interpFlags |= (SPAN_TEXTURE | SPAN_VARYING); { const GLfloat invLen = 1.0F / numPixels; - 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.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; - } - } - } -#endif -#ifdef INTERP_VARYING - interpFlags |= SPAN_VARYING; - { - const GLfloat invLen = 1.0F / numPixels; - const GLbitfield inputsUsed = ctx->FragmentProgram._Current ? - ctx->FragmentProgram._Current->Base.InputsRead : 0x0; const GLfloat invw0 = vert0->win[3]; const GLfloat invw1 = vert1->win[3]; - GLuint v; - for (v = 0; v < MAX_VARYING; v++) { - if (inputsUsed & FRAG_BIT_VAR(v)) { - GLuint attr = FRAG_ATTRIB_VAR0 + v; + 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->varying[v][0]; - span.attrStart[attr][1] = invw0 * vert0->varying[v][1]; - span.attrStart[attr][2] = invw0 * vert0->varying[v][2]; - span.attrStart[attr][3] = invw0 * vert0->varying[v][3]; - ds = (invw1 * vert1->varying[v][0]) - span.attrStart[attr][0]; - dt = (invw1 * vert1->varying[v][1]) - span.attrStart[attr][1]; - dr = (invw1 * vert1->varying[v][2]) - span.attrStart[attr][2]; - dq = (invw1 * vert1->varying[v][3]) - span.attrStart[attr][3]; + 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; @@ -364,7 +333,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) span.attrStepY[attr][1] = 0.0F; span.attrStepY[attr][2] = 0.0F; span.attrStepY[attr][3] = 0.0F; - } + } } } #endif diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index d211a5a3a2..eca0b9d38d 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -88,8 +88,8 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) const GLuint colorIndex = (GLuint) vert->index; /* XXX round? */ #endif #if FLAGS & TEXTURE - GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4]; - GLuint u; + GLfloat attrib[FRAG_ATTRIB_MAX][4]; /* texture & varying */ + GLuint attr; #endif SWcontext *swrast = SWRAST_CONTEXT(ctx); SWspan *span = &(swrast->PointSpan); @@ -123,22 +123,22 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) span->arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); if (ctx->FragmentProgram._Current) { /* Don't divide texture s,t,r by q (use TXP to do that) */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture._EnabledCoordUnits & (1 << u)) { - COPY_4V(texcoord[u], vert->texcoord[u]); + for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { + if (swrast->_FragmentAttribs & (1 << attr)) { + COPY_4V(attrib[attr], vert->attrib[attr]); } } } else { /* Divide texture s,t,r by q here */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture._EnabledCoordUnits & (1 << u)) { - const GLfloat q = vert->texcoord[u][3]; + 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); - texcoord[u][0] = vert->texcoord[u][0] * invQ; - texcoord[u][1] = vert->texcoord[u][1] * invQ; - texcoord[u][2] = vert->texcoord[u][2] * invQ; - texcoord[u][3] = 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; } } } @@ -260,7 +260,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) count = span->end = 0; } for (x = xmin; x <= xmax; x++) { -#if FLAGS & (SPRITE | TEXTURE) +#if FLAGS & SPRITE GLuint u; #endif @@ -279,10 +279,13 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) span->array->index[count] = colorIndex; #endif #if FLAGS & TEXTURE - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture._EnabledCoordUnits & (1 << u)) { - COPY_4V(span->array->attribs[FRAG_ATTRIB_TEX0 + u][count], texcoord[u]); - span->array->lambda[u][count] = 0.0; + 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; + } } } #endif @@ -329,6 +332,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) #if FLAGS & SPRITE for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + GLuint attr = FRAG_ATTRIB_TEX0 + u; if (ctx->Texture.Unit[u]._ReallyEnabled) { if (ctx->Point.CoordReplace[u]) { GLfloat s = 0.5F + (x + 0.5F - vert->win[0]) / size; @@ -340,17 +344,18 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) if (ctx->Point.SpriteRMode == GL_ZERO) r = 0.0F; else if (ctx->Point.SpriteRMode == GL_S) - r = vert->texcoord[u][0]; + r = vert->attrib[attr][0]; else /* GL_R */ - r = vert->texcoord[u][2]; - span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][0] = s; - span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][1] = t; - span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][2] = r; - span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][3] = 1.0F; + r = vert->attrib[attr][2]; + span->array->attribs[attr][count][0] = s; + span->array->attribs[attr][count][1] = t; + span->array->attribs[attr][count][2] = r; + span->array->attribs[attr][count][3] = 1.0F; span->array->lambda[u][count] = 0.0; /* XXX fix? */ } else { - COPY_4V(span->array->attribs[FRAG_ATTRIB_TEX0 + u][count], vert->texcoord[u]); + COPY_4V(span->array->attribs[attr][count], + vert->attrib[attr]); } } } @@ -401,9 +406,9 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) span->array->index[count] = colorIndex; #endif #if FLAGS & TEXTURE - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - COPY_4V(span->array->attribs[FRAG_ATTRIB_TEX0 + u][count], texcoord[u]); + for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) { + if (swrast->_FragmentAttribs & (1 << attr)) { + COPY_4V(span->array->attribs[attr][count], attribs[attr]); } } #endif diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 6c2e3862a3..3b7960bf80 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -866,7 +866,6 @@ fast_persp_span(GLcontext *ctx, SWspan *span, /* * Render a smooth-shaded, textured, RGBA triangle. - * Interpolate S,T,R with perspective correction, w/out mipmapping. */ #define NAME general_textured_triangle #define INTERP_Z 1 @@ -881,24 +880,6 @@ fast_persp_span(GLcontext *ctx, SWspan *span, -/* - * This is the big one! - * Interpolate Z, RGB, Alpha, specular, fog, N sets of texture coordinates, - * and varying floats. Yup, it's slow. - */ -#define NAME multitextured_triangle -#define INTERP_Z 1 -#define INTERP_W 1 -#define INTERP_FOG 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define INTERP_SPEC 1 -#define INTERP_MULTITEX 1 -#define INTERP_VARYING 1 -#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); -#include "s_tritemp.h" - - /* * Special tri function for occlusion testing @@ -1137,13 +1118,7 @@ _swrast_choose_triangle( GLcontext *ctx ) } else { /* general case textured triangles */ - if (ctx->Texture._EnabledCoordUnits > 1 || - ctx->FragmentProgram._Current) { - USE(multitextured_triangle); - } - else { - USE(general_textured_triangle); - } + USE(general_textured_triangle); } } else { diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 83b2f03781..435491a0c8 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -38,10 +38,8 @@ * INTERP_INDEX - if defined, interpolate color index values * INTERP_INT_TEX - if defined, interpolate integer ST texcoords * (fast, simple 2-D texture mapping) - * INTERP_TEX - if defined, interpolate set 0 float STRQ texcoords + * INTERP_TEX - if defined, interpolate texcoords and varying vars * NOTE: OpenGL STRQ = Mesa STUV (R was taken for red) - * INTERP_MULTITEX - if defined, interpolate N units of STRQ texcoords - * INTERP_VARYING - if defined, interpolate M GLSL varyings * * When one can directly address pixels in the color buffer the following * macros can be defined and used to compute pixel addresses during @@ -119,52 +117,19 @@ #endif -/* - * Either loop over all texture units, or just use unit zero. - */ -#ifdef INTERP_MULTITEX -#define TEX_UNIT_LOOP(CODE) \ - { \ - 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 \ - } \ - } \ +#define TEXVAR_LOOP(CODE) \ + { \ + GLuint attr; \ + for (attr = swrast->_MinFragmentAttrib; \ + attr < swrast->_MaxFragmentAttrib; attr++) { \ + if (swrast->_FragmentAttribs & (1 << attr)) { \ + CODE \ + } \ + } \ } -#define INTERP_TEX -#elif defined(INTERP_TEX) -#define TEX_UNIT_LOOP(CODE) \ - { \ - const GLuint u = 0; \ - const GLuint attr = FRAG_ATTRIB_TEX0 + u; \ - (void) attr; \ - CODE \ - } -#endif -#ifdef INTERP_VARYING - -#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; \ - (void) attr; \ - for (ic = 0; ic < 4; ic++) { \ - CODE \ - } \ - } \ - } \ - } -#endif - - /* * Some code we unfortunately need to prevent negative interpolated colors. @@ -210,6 +175,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, GLint lines; /* number of lines to be sampled on this edge */ } EdgeT; + const SWcontext *swrast = SWRAST_CONTEXT(ctx); #ifdef INTERP_Z const GLint depthBits = ctx->DrawBuffer->Visual.depthBits; const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0; @@ -224,13 +190,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */ #endif GLinterp vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy; -#ifdef INTERP_VARYING - const GLbitfield inputsUsed = ctx->FragmentProgram._Current ? - ctx->FragmentProgram._Current->Base.InputsRead : 0x0; -#endif SWspan span; + (void) swrast; + INIT_SPAN(span, GL_POLYGON, 0, 0, 0); #ifdef INTERP_Z @@ -638,10 +602,10 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_INT_TEX span.interpMask |= SPAN_INT_TEXTURE; { - GLfloat eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE; - 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; + GLfloat eMaj_ds = (vMax->attrib[FRAG_ATTRIB_TEX0][0] - vMin->attrib[FRAG_ATTRIB_TEX0][0]) * S_SCALE; + GLfloat eBot_ds = (vMid->attrib[FRAG_ATTRIB_TEX0][0] - vMin->attrib[FRAG_ATTRIB_TEX0][0]) * S_SCALE; + GLfloat eMaj_dt = (vMax->attrib[FRAG_ATTRIB_TEX0][1] - vMin->attrib[FRAG_ATTRIB_TEX0][1]) * T_SCALE; + GLfloat eBot_dt = (vMid->attrib[FRAG_ATTRIB_TEX0][1] - vMin->attrib[FRAG_ATTRIB_TEX0][1]) * T_SCALE; 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); @@ -651,19 +615,19 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, } #endif #ifdef INTERP_TEX - span.interpMask |= SPAN_TEXTURE; + span.interpMask |= (SPAN_TEXTURE | SPAN_VARYING); { /* win[3] is 1/W */ const GLfloat wMax = vMax->win[3], wMin = vMin->win[3], wMid = vMid->win[3]; - TEX_UNIT_LOOP( - GLfloat eMaj_ds = vMax->texcoord[u][0] * wMax - vMin->texcoord[u][0] * wMin; - GLfloat eBot_ds = vMid->texcoord[u][0] * wMid - vMin->texcoord[u][0] * wMin; - GLfloat eMaj_dt = vMax->texcoord[u][1] * wMax - vMin->texcoord[u][1] * wMin; - GLfloat eBot_dt = vMid->texcoord[u][1] * wMid - vMin->texcoord[u][1] * wMin; - GLfloat eMaj_du = vMax->texcoord[u][2] * wMax - vMin->texcoord[u][2] * wMin; - 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; + TEXVAR_LOOP( + 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; + GLfloat eBot_dt = vMid->attrib[attr][1] * wMid - vMin->attrib[attr][1] * wMin; + GLfloat eMaj_du = vMax->attrib[attr][2] * wMax - vMin->attrib[attr][2] * wMin; + GLfloat eBot_du = vMid->attrib[attr][2] * wMid - vMin->attrib[attr][2] * wMin; + GLfloat eMaj_dv = vMax->attrib[attr][3] * wMax - vMin->attrib[attr][3] * wMin; + GLfloat eBot_dv = vMid->attrib[attr][3] * wMid - vMin->attrib[attr][3] * wMin; 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); @@ -675,19 +639,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, ) } #endif -#ifdef INTERP_VARYING - span.interpMask |= SPAN_VARYING; - { - /* win[3] is 1/W */ - const GLfloat wMax = vMax->win[3], wMin = vMin->win[3], wMid = vMid->win[3]; - VARYING_LOOP( - GLfloat eMaj_dvar = vMax->varying[iv][ic] * wMax - vMin->varying[iv][ic] * wMin; - GLfloat eBot_dvar = vMid->varying[iv][ic] * wMid - vMin->varying[iv][ic] * wMin; - span.attrStepX[attr][ic] = oneOverArea * (eMaj_dvar * eBot.dy - eMaj.dy * eBot_dvar); - span.attrStepY[attr][ic] = oneOverArea * (eMaj.dx * eBot_dvar - eMaj_dvar * eBot.dx); - ) - } -#endif /* * We always sample at pixel centers. However, we avoid @@ -782,19 +733,14 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, GLfixed tLeft=0, dtOuter=0, dtInner; #endif #ifdef INTERP_TEX - GLfloat sLeft[MAX_TEXTURE_COORD_UNITS]; - GLfloat tLeft[MAX_TEXTURE_COORD_UNITS]; - GLfloat uLeft[MAX_TEXTURE_COORD_UNITS]; - GLfloat vLeft[MAX_TEXTURE_COORD_UNITS]; - GLfloat dsOuter[MAX_TEXTURE_COORD_UNITS], dsInner[MAX_TEXTURE_COORD_UNITS]; - GLfloat dtOuter[MAX_TEXTURE_COORD_UNITS], dtInner[MAX_TEXTURE_COORD_UNITS]; - GLfloat duOuter[MAX_TEXTURE_COORD_UNITS], duInner[MAX_TEXTURE_COORD_UNITS]; - GLfloat dvOuter[MAX_TEXTURE_COORD_UNITS], dvInner[MAX_TEXTURE_COORD_UNITS]; -#endif -#ifdef INTERP_VARYING - GLfloat varLeft[MAX_VARYING][4]; - GLfloat dvarOuter[MAX_VARYING][4]; - GLfloat dvarInner[MAX_VARYING][4]; + GLfloat sLeft[FRAG_ATTRIB_MAX]; + GLfloat tLeft[FRAG_ATTRIB_MAX]; + GLfloat uLeft[FRAG_ATTRIB_MAX]; + GLfloat vLeft[FRAG_ATTRIB_MAX]; + GLfloat dsOuter[FRAG_ATTRIB_MAX], dsInner[FRAG_ATTRIB_MAX]; + GLfloat dtOuter[FRAG_ATTRIB_MAX], dtInner[FRAG_ATTRIB_MAX]; + GLfloat duOuter[FRAG_ATTRIB_MAX], duInner[FRAG_ATTRIB_MAX]; + GLfloat dvOuter[FRAG_ATTRIB_MAX], dvInner[FRAG_ATTRIB_MAX]; #endif for (subTriangle=0; subTriangle<=1; subTriangle++) { @@ -1042,41 +988,32 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_INT_TEX { GLfloat s0, t0; - s0 = vLower->texcoord[0][0] * S_SCALE; + s0 = vLower->attrib[FRAG_ATTRIB_TEX0][0] * S_SCALE; 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; + t0 = vLower->attrib[FRAG_ATTRIB_TEX0][1] * T_SCALE; 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 - TEX_UNIT_LOOP( + TEXVAR_LOOP( const GLfloat invW = vLower->win[3]; - const GLfloat s0 = vLower->texcoord[u][0] * invW; - 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.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 - VARYING_LOOP( - const GLfloat invW = vLower->win[3]; - const GLfloat var0 = vLower->varying[iv][ic] * invW; - varLeft[iv][ic] = var0 + (span.attrStepX[attr][ic] * adjx + - span.attrStepY[attr][ic] * adjy) * (1.0f / FIXED_SCALE); - dvarOuter[iv][ic] = span.attrStepY[attr][ic] + dxOuter * span.attrStepX[attr][ic]; + const GLfloat s0 = vLower->attrib[attr][0] * invW; + const GLfloat t0 = vLower->attrib[attr][1] * invW; + const GLfloat u0 = vLower->attrib[attr][2] * invW; + const GLfloat v0 = vLower->attrib[attr][3] * invW; + sLeft[attr] = s0 + (span.attrStepX[attr][0] * adjx + span.attrStepY[attr][0] * adjy) * (1.0F/FIXED_SCALE); + tLeft[attr] = t0 + (span.attrStepX[attr][1] * adjx + span.attrStepY[attr][1] * adjy) * (1.0F/FIXED_SCALE); + uLeft[attr] = u0 + (span.attrStepX[attr][2] * adjx + span.attrStepY[attr][2] * adjy) * (1.0F/FIXED_SCALE); + vLeft[attr] = v0 + (span.attrStepX[attr][3] * adjx + span.attrStepY[attr][3] * adjy) * (1.0F/FIXED_SCALE); + dsOuter[attr] = span.attrStepY[attr][0] + dxOuter * span.attrStepX[attr][0]; + 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]; ) #endif } /*if setupLeft*/ @@ -1134,16 +1071,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, dtInner = dtOuter + span.intTexStep[1]; #endif #ifdef INTERP_TEX - TEX_UNIT_LOOP( - 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 - VARYING_LOOP( - dvarInner[iv][ic] = dvarOuter[iv][ic] + span.attrStepX[attr][ic]; + TEXVAR_LOOP( + 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]; ) #endif @@ -1188,16 +1120,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #endif #ifdef INTERP_TEX - TEX_UNIT_LOOP( - 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 - VARYING_LOOP( - span.attrStart[attr][ic] = varLeft[iv][ic]; + TEXVAR_LOOP( + span.attrStart[attr][0] = sLeft[attr]; + span.attrStart[attr][1] = tLeft[attr]; + span.attrStart[attr][2] = uLeft[attr]; + span.attrStart[attr][3] = vLeft[attr]; ) #endif @@ -1281,16 +1208,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, tLeft += dtOuter; #endif #ifdef INTERP_TEX - TEX_UNIT_LOOP( - sLeft[u] += dsOuter[u]; - tLeft[u] += dtOuter[u]; - uLeft[u] += duOuter[u]; - vLeft[u] += dvOuter[u]; - ) -#endif -#ifdef INTERP_VARYING - VARYING_LOOP( - varLeft[iv][ic] += dvarOuter[iv][ic]; + TEXVAR_LOOP( + sLeft[attr] += dsOuter[attr]; + tLeft[attr] += dtOuter[attr]; + uLeft[attr] += duOuter[attr]; + vLeft[attr] += dvOuter[attr]; ) #endif } @@ -1331,16 +1253,11 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, tLeft += dtInner; #endif #ifdef INTERP_TEX - TEX_UNIT_LOOP( - sLeft[u] += dsInner[u]; - tLeft[u] += dtInner[u]; - uLeft[u] += duInner[u]; - vLeft[u] += dvInner[u]; - ) -#endif -#ifdef INTERP_VARYING - VARYING_LOOP( - varLeft[iv][ic] += dvarInner[iv][ic]; + TEXVAR_LOOP( + sLeft[attr] += dsInner[attr]; + tLeft[attr] += dtInner[attr]; + uLeft[attr] += duInner[attr]; + vLeft[attr] += dvInner[attr]; ) #endif } @@ -1373,8 +1290,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #undef INTERP_INDEX #undef INTERP_INT_TEX #undef INTERP_TEX -#undef INTERP_MULTITEX -#undef INTERP_VARYING #undef TEX_UNIT_LOOP #undef VARYING_LOOP diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index 2c1c0952af..9e1fe24bb4 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -67,13 +67,12 @@ typedef struct { * that clip{XYZ} were multiplied by to get ndc{XYZ}. */ GLfloat win[4]; - GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4]; GLchan color[4]; GLchan specular[4]; GLfloat fog; GLfloat index; GLfloat pointSize; - GLfloat varying[MAX_VERTEX_ATTRIBS][4]; + GLfloat attrib[FRAG_ATTRIB_MAX][4]; /**< texcoords & varying, more to come */ } SWvertex; diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index f17e69bfb2..e1b60d0e85 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -145,7 +145,7 @@ _swsetup_RenderStart( GLcontext *ctx ) if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { - EMIT_ATTR( _TNL_ATTRIB_TEX(i), EMIT_4F, texcoord[i] ); + EMIT_ATTR( _TNL_ATTRIB_TEX(i), EMIT_4F, attrib[FRAG_ATTRIB_TEX0 + i] ); } } } @@ -156,7 +156,7 @@ _swsetup_RenderStart( GLcontext *ctx ) for (i = 0; i < ctx->Const.MaxVarying; i++) { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_GENERIC(i) )) { EMIT_ATTR( _TNL_ATTRIB_GENERIC(i), VARYING_EMIT_STYLE, - varying[i] ); + attrib[FRAG_ATTRIB_VAR0 + i] ); } } } @@ -242,8 +242,13 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest ) for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i, dest->texcoord[i] ); - + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i, + dest->attrib[FRAG_ATTRIB_TEX0 + i] ); + + for (i = 0 ; i < ctx->Const.MaxVarying ; i++) + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0+i, + dest->attrib[FRAG_ATTRIB_VAR0 + i] ); + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp ); UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); -- cgit v1.2.3