summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-08-14 14:08:44 +0000
committerBrian Paul <[email protected]>2001-08-14 14:08:44 +0000
commit60174c1aef7c6650a800f16f103a4f9ed2d1004e (patch)
tree6d3f3866ab1ac2506e79637685f1a0432759e2bb /src/mesa
parent76a52525c7edcefcb40a1cbc9ce88d6c6e402f1a (diff)
Fixes for 32-bit GLchans: smooth/flat/textured triangles seem to work now.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/swrast/s_context.h6
-rw-r--r--src/mesa/swrast/s_span.c6
-rw-r--r--src/mesa/swrast/s_texture.c17
-rw-r--r--src/mesa/swrast/s_tritemp.h59
4 files changed, 47 insertions, 41 deletions
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 5aad31683ba..88f877e883e 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -1,4 +1,4 @@
-/* $Id: s_context.h,v 1.11 2001/07/13 20:07:37 brianp Exp $ */
+/* $Id: s_context.h,v 1.12 2001/08/14 14:08:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -195,8 +195,8 @@ _swrast_validate_derived( GLcontext *ctx );
* These should probably go elsewhere at some point.
*/
#if CHAN_TYPE == GL_FLOAT
-#define ChanToFixed(X) FloatToFixed(X)
-#define FixedToChan(X) FixedToFloat(X)
+#define ChanToFixed(X) (X)
+#define FixedToChan(X) (X)
#else
#define ChanToFixed(X) IntToFixed(X)
#define FixedToChan(X) FixedToInt(X)
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 8e57296a09a..07ab8bd1a59 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.16 2001/07/23 16:08:19 brianp Exp $ */
+/* $Id: s_span.c,v 1.17 2001/08/14 14:08:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -859,7 +859,7 @@ _mesa_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
write_all = GL_FALSE;
}
- /* Texture with alpha test*/
+ /* Texture with alpha test */
if (ctx->Color.AlphaEnabled) {
/* Texturing without alpha is done after depth-testing which
gives a potential speed-up. */
@@ -1015,7 +1015,7 @@ _mesa_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
write_all = GL_FALSE;
}
- /* Texture with alpha test*/
+ /* Texture with alpha test */
if (ctx->Color.AlphaEnabled) {
/* Texturing without alpha is done after depth-testing which
* gives a potential speed-up.
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 3d8b41de60f..9c3e2c5b5f6 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.37 2001/08/07 22:05:11 brianp Exp $ */
+/* $Id: s_texture.c,v 1.38 2001/08/14 14:08:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -910,8 +910,7 @@ opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
const GLint colMask = img->Width - 1;
const GLint rowMask = img->Height - 1;
const GLint shift = img->WidthLog2;
- GLuint k;
- GLchan (*ptr_rgba)[4] = rgba;
+ GLuint i;
(void) u;
(void) lambda;
ASSERT(tObj->WrapS==GL_REPEAT);
@@ -919,12 +918,12 @@ opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
ASSERT(img->Border==0);
ASSERT(img->Format==GL_RGBA);
- for (k=0; k<n; k++, ptr_rgba ++) {
- GLint i = IFLOOR(s[k] * width) & colMask;
- GLint j = IFLOOR(t[k] * height) & rowMask;
- GLint pos = (j << shift) | i;
- GLchan *texel = ((GLchan *) img->Data) + (pos << 2); /* pos*4 */
- COPY_CHAN4 (ptr_rgba, texel);
+ for (i = 0; i < n; i++) {
+ const GLint col = IFLOOR(s[i] * width) & colMask;
+ const GLint row = IFLOOR(t[i] * height) & rowMask;
+ const GLint pos = (row << shift) | col;
+ const GLchan *texel = ((GLchan *) img->Data) + (pos << 2); /* pos*4 */
+ COPY_CHAN4(rgba[i], texel);
}
}
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 9f0ce46a21d..ae381d39c01 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_tritemp.h,v 1.23 2001/07/26 15:57:49 brianp Exp $ */
+/* $Id: s_tritemp.h,v 1.24 2001/08/14 14:08:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -419,23 +419,23 @@
GLfloat eMaj_dg, eBot_dg;
GLfloat eMaj_db, eBot_db;
GLfloat eMaj_da, eBot_da;
- eMaj_dr = (GLint) vMax->color[RCOMP] - (GLint) vMin->color[RCOMP];
- eBot_dr = (GLint) vMid->color[RCOMP] - (GLint) vMin->color[RCOMP];
+ eMaj_dr = vMax->color[RCOMP] - vMin->color[RCOMP];
+ eBot_dr = vMid->color[RCOMP] - vMin->color[RCOMP];
drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
span.redStep = drdx;
drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
- eMaj_dg = (GLint) vMax->color[GCOMP] - (GLint) vMin->color[GCOMP];
- eBot_dg = (GLint) vMid->color[GCOMP] - (GLint) vMin->color[GCOMP];
+ eMaj_dg = vMax->color[GCOMP] - vMin->color[GCOMP];
+ eBot_dg = vMid->color[GCOMP] - vMin->color[GCOMP];
dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
span.greenStep = dgdx;
dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
- eMaj_db = (GLint) vMax->color[BCOMP] - (GLint) vMin->color[BCOMP];
- eBot_db = (GLint) vMid->color[BCOMP] - (GLint) vMin->color[BCOMP];
+ eMaj_db = vMax->color[BCOMP] - vMin->color[BCOMP];
+ eBot_db = vMid->color[BCOMP] - vMin->color[BCOMP];
dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
span.blueStep = dbdx;
dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
- eMaj_da = (GLint) vMax->color[ACOMP] - (GLint) vMin->color[ACOMP];
- eBot_da = (GLint) vMid->color[ACOMP] - (GLint) vMin->color[ACOMP];
+ eMaj_da = vMax->color[ACOMP] - vMin->color[ACOMP];
+ eBot_da = vMid->color[ACOMP] - vMin->color[ACOMP];
dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
span.alphaStep = dadx;
dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
@@ -484,18 +484,18 @@
GLfloat eMaj_dsr, eBot_dsr;
GLfloat eMaj_dsg, eBot_dsg;
GLfloat eMaj_dsb, eBot_dsb;
- eMaj_dsr = (GLint) vMax->specular[RCOMP] - (GLint) vMin->specular[RCOMP];
- eBot_dsr = (GLint) vMid->specular[RCOMP] - (GLint) vMin->specular[RCOMP];
+ eMaj_dsr = vMax->specular[RCOMP] - vMin->specular[RCOMP];
+ eBot_dsr = vMid->specular[RCOMP] - vMin->specular[RCOMP];
dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
span.specRedStep = dsrdx;
dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
- eMaj_dsg = (GLint) vMax->specular[GCOMP] - (GLint) vMin->specular[GCOMP];
- eBot_dsg = (GLint) vMid->specular[GCOMP] - (GLint) vMin->specular[GCOMP];
+ eMaj_dsg = vMax->specular[GCOMP] - vMin->specular[GCOMP];
+ eBot_dsg = vMid->specular[GCOMP] - vMin->specular[GCOMP];
dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
span.specGreenStep = dsgdx;
dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
- eMaj_dsb = (GLint) vMax->specular[BCOMP] - (GLint) vMin->specular[BCOMP];
- eBot_dsb = (GLint) vMid->specular[BCOMP] - (GLint) vMin->specular[BCOMP];
+ eMaj_dsb = vMax->specular[BCOMP] - vMin->specular[BCOMP];
+ eBot_dsb = vMid->specular[BCOMP] - vMin->specular[BCOMP];
dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
span.specBlueStep = dsbdx;
dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
@@ -919,13 +919,17 @@
#endif
#ifdef INTERP_FLOAT_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- fr = vLower->color[RCOMP] + drdx * adjx + drdy * adjy;
+ fr = vLower->color[RCOMP]
+ + (drdx * adjx + drdy * adjy) * (1.0F / FIXED_SCALE);
fdrOuter = drdy + dxOuter * drdx;
- fg = vLower->color[GCOMP] + dgdx * adjx + dgdy * adjy;
+ fg = vLower->color[GCOMP]
+ + (dgdx * adjx + dgdy * adjy) * (1.0F / FIXED_SCALE);
fdgOuter = dgdy + dxOuter * dgdx;
- fb = vLower->color[BCOMP] + dbdx * adjx + dbdy * adjy;
+ fb = vLower->color[BCOMP]
+ + (dbdx * adjx + dbdy * adjy) * (1.0F / FIXED_SCALE);
fdbOuter = dbdy + dxOuter * dbdx;
- fa = vLower->color[ACOMP] + dadx * adjx + dady * adjy;
+ fa = vLower->color[ACOMP]
+ + (dadx * adjx + dady * adjy) * (1.0F / FIXED_SCALE);
fdaOuter = dady + dxOuter * dadx;
}
else {
@@ -939,13 +943,13 @@
#ifdef INTERP_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
fsr = (GLfixed) (ChanToFixed(vLower->specular[RCOMP])
- + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
+ + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx);
fsg = (GLfixed) (ChanToFixed(vLower->specular[GCOMP])
- + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
+ + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx);
fsb = (GLfixed) (ChanToFixed(vLower->specular[BCOMP])
- + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
+ + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx);
}
else {
@@ -957,18 +961,21 @@
#endif
#ifdef INTERP_FLOAT_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- fsr = vLower->specular[RCOMP] + dsrdx * adjx + dsrdy * adjy;
+ fsr = vLower->specular[RCOMP]
+ + (dsrdx * adjx + dsrdy * adjy) * (1.0F / FIXED_SCALE);
fdsrOuter = dsrdy + dxOuter * dsrdx;
- fsg = vLower->specular[GCOMP] + dsgdx * adjx + dsgdy * adjy;
+ fsg = vLower->specular[GCOMP]
+ + (dsgdx * adjx + dsgdy * adjy) * (1.0F / FIXED_SCALE);
fdsgOuter = dsgdy + dxOuter * dsgdx;
- fsb = vLower->specular[BCOMP] + dsbdx * adjx + dsbdy * adjy;
+ fsb = vLower->specular[BCOMP]
+ + (dsbdx * adjx + dsbdy * adjy) * (1.0F / FIXED_SCALE);
fdsbOuter = dsbdy + dxOuter * dsbdx;
}
else {
fsr = v2->specular[RCOMP];
fsg = v2->specular[GCOMP];
fsb = v2->specular[BCOMP];
- fdsrOuter = fdsgOuter = fdsbOuter = 0.0F:
+ fdsrOuter = fdsgOuter = fdsbOuter = 0.0F;
}
#endif
#ifdef INTERP_INDEX