From 1b3528fe635242f782fbcdde3ba74b5b7359a362 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 May 2001 22:13:32 +0000 Subject: interpolate fog valus as floats, not fixed - fixed the swrast fog problem --- src/mesa/swrast/s_aalinetemp.h | 8 +-- src/mesa/swrast/s_aatritemp.h | 8 +-- src/mesa/swrast/s_bitmap.c | 4 +- src/mesa/swrast/s_fog.c | 45 ++++++---------- src/mesa/swrast/s_fog.h | 11 ++-- src/mesa/swrast/s_lines.c | 18 +++---- src/mesa/swrast/s_linetemp.h | 6 +-- src/mesa/swrast/s_span.c | 14 ++--- src/mesa/swrast/s_span.h | 14 ++--- src/mesa/swrast/s_texstore.c | 12 +++-- src/mesa/swrast/s_triangle.c | 119 ++++++++++++++++++++--------------------- src/mesa/swrast/s_tritemp.h | 71 ++++++++++++------------ src/mesa/swrast/s_zoom.c | 14 ++--- src/mesa/swrast/s_zoom.h | 8 +-- 14 files changed, 167 insertions(+), 185 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 9ab1abb292..53a2b55ddf 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -1,4 +1,4 @@ -/* $Id: s_aalinetemp.h,v 1.7 2001/03/12 00:48:41 gareth Exp $ */ +/* $Id: s_aalinetemp.h,v 1.8 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -41,7 +41,7 @@ NAME(plot)(GLcontext *ctx, const struct LineInfo *line, const GLfloat fy = (GLfloat) iy; const GLfloat coverage = compute_coveragef(line, ix, iy); GLdepth z; - GLfixed fog; + GLfloat fog; GLchan red, green, blue, alpha; GLint frac, indx, index; GLchan specRed, specGreen, specBlue; @@ -60,9 +60,9 @@ NAME(plot)(GLcontext *ctx, const struct LineInfo *line, z = 0.0; #endif #ifdef DO_FOG - fog = FloatToFixed( solve_plane(fx, fy, line->fPlane) ); + fog = solve_plane(fx, fy, line->fPlane); #else - fog = 0; + fog = 0.0; #endif #ifdef DO_RGBA red = solve_plane_chan(fx, fy, line->rPlane); diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 41ef99cbfb..ae5abfcd7e 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_aatritemp.h,v 1.9 2001/03/28 21:36:31 brianp Exp $ */ +/* $Id: s_aatritemp.h,v 1.10 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -56,7 +56,7 @@ GLfloat zPlane[4]; /* Z (depth) */ GLdepth z[MAX_WIDTH]; GLfloat fogPlane[4]; - GLfixed fog[MAX_WIDTH]; + GLfloat fog[MAX_WIDTH]; #endif #ifdef DO_RGBA GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; /* color */ @@ -270,7 +270,7 @@ while (coverage > 0.0F) { #ifdef DO_Z z[count] = (GLdepth) solve_plane(ix, iy, zPlane); - fog[count] = FloatToFixed(solve_plane(ix, iy, fogPlane)); + fog[count] = solve_plane(ix, iy, fogPlane); #endif #ifdef DO_RGBA rgba[count][RCOMP] = solve_plane_chan(ix, iy, rPlane); @@ -386,7 +386,7 @@ while (coverage > 0.0F) { #ifdef DO_Z z[ix] = (GLdepth) solve_plane(ix, iy, zPlane); - fog[ix] = FloatToFixed(solve_plane(ix, iy, fogPlane)); + fog[ix] = solve_plane(ix, iy, fogPlane); #endif #ifdef DO_RGBA rgba[ix][RCOMP] = solve_plane_chan(ix, iy, rPlane); diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index d22579c02f..d91319c01b 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -1,4 +1,4 @@ -/* $Id: s_bitmap.c,v 1.7 2001/03/19 02:25:36 keithw Exp $ */ +/* $Id: s_bitmap.c,v 1.8 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -49,7 +49,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, struct pixel_buffer *PB = swrast->PB; GLint row, col; GLdepth fragZ; - GLfixed fogCoord; + GLfloat fogCoord; ASSERT(ctx->RenderMode == GL_RENDER); ASSERT(bitmap); diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c index cc55913f37..4b8c4f0c71 100644 --- a/src/mesa/swrast/s_fog.c +++ b/src/mesa/swrast/s_fog.c @@ -1,4 +1,4 @@ -/* $Id: s_fog.c,v 1.11 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_fog.c,v 1.12 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -46,7 +46,7 @@ void _mesa_fog_rgba_pixels( const GLcontext *ctx, GLuint n, - const GLfixed fog[], + const GLfloat fog[], GLchan rgba[][4] ) { GLuint i; @@ -56,24 +56,13 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]); UNCLAMPED_FLOAT_TO_CHAN(bFog, ctx->Fog.Color[BCOMP]); -#if CHAN_TYPE == GL_FLOAT for (i = 0; i < n; i++) { - const GLfixed cf = CLAMP(fog[i], 0, FIXED_ONE); - const GLfloat f = FixedToFloat(cf); - const GLfloat g = 1.0F - f; + const GLfloat f = fog[i]; + const GLfloat g = 1.0 - f; rgba[i][RCOMP] = f * rgba[i][RCOMP] + g * rFog; rgba[i][GCOMP] = f * rgba[i][GCOMP] + g * gFog; rgba[i][BCOMP] = f * rgba[i][BCOMP] + g * bFog; } -#else - for (i = 0; i < n; i++) { - const GLfixed f = CLAMP(fog[i], 0, FIXED_ONE); - const GLfixed g = FIXED_ONE - f; - rgba[i][0] = (f * rgba[i][0] + g * rFog) >> FIXED_SHIFT; - rgba[i][1] = (f * rgba[i][1] + g * gFog) >> FIXED_SHIFT; - rgba[i][2] = (f * rgba[i][2] + g * bFog) >> FIXED_SHIFT; - } -#endif } @@ -87,14 +76,14 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, */ void _mesa_fog_ci_pixels( const GLcontext *ctx, - GLuint n, const GLfixed fog[], GLuint index[] ) + GLuint n, const GLfloat fog[], GLuint index[] ) { GLuint idx = (GLuint) ctx->Fog.Index; GLuint i; - for (i=0;iProjectionMatrix.m[15] != 0.0F); const GLfloat p10 = ctx->ProjectionMatrix.m[10]; @@ -165,7 +154,7 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx, GLfloat eyez = (ndcz - p14) / p10; if (eyez < 0.0) eyez = -eyez; - fogcoord[i] = FloatToFixed((fogEnd - eyez) * fogScale); + fogcoord[i] = (fogEnd - eyez) * fogScale; } } else { @@ -175,7 +164,7 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx, GLfloat eyez = p14 / (ndcz + p10); if (eyez < 0.0) eyez = -eyez; - fogcoord[i] = FloatToFixed((fogEnd - eyez) * fogScale); + fogcoord[i] = (fogEnd - eyez) * fogScale; } } } @@ -187,7 +176,7 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx, GLfloat eyez = (ndcz - p14) / p10; if (eyez < 0.0) eyez = -eyez; - fogcoord[i] = FloatToFixed(exp( -ctx->Fog.Density * eyez )); + fogcoord[i] = exp( -ctx->Fog.Density * eyez ); } } else { @@ -197,7 +186,7 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx, GLfloat eyez = p14 / (ndcz + p10); if (eyez < 0.0) eyez = -eyez; - fogcoord[i] = FloatToFixed(exp( -ctx->Fog.Density * eyez )); + fogcoord[i] = exp( -ctx->Fog.Density * eyez ); } } break; @@ -214,7 +203,7 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx, if (tmp < FLT_MIN_10_EXP) tmp = FLT_MIN_10_EXP; #endif - fogcoord[i] = FloatToFixed(exp( tmp )); + fogcoord[i] = exp( tmp ); } } else { @@ -228,7 +217,7 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx, if (tmp < FLT_MIN_10_EXP) tmp = FLT_MIN_10_EXP; #endif - fogcoord[i] = FloatToFixed(exp( tmp )); + fogcoord[i] = exp( tmp ); } } } @@ -251,7 +240,7 @@ void _mesa_depth_fog_rgba_pixels( const GLcontext *ctx, GLuint n, const GLdepth z[], GLchan rgba[][4] ) { - GLfixed fog[PB_SIZE]; + GLfloat fog[PB_SIZE]; ASSERT(n <= PB_SIZE); _mesa_win_fog_coords_from_z( ctx, n, z, fog ); _mesa_fog_rgba_pixels( ctx, n, fog, rgba ); @@ -269,7 +258,7 @@ void _mesa_depth_fog_ci_pixels( const GLcontext *ctx, GLuint n, const GLdepth z[], GLuint index[] ) { - GLfixed fog[PB_SIZE]; + GLfloat fog[PB_SIZE]; ASSERT(n <= PB_SIZE); _mesa_win_fog_coords_from_z( ctx, n, z, fog ); _mesa_fog_ci_pixels( ctx, n, fog, index ); diff --git a/src/mesa/swrast/s_fog.h b/src/mesa/swrast/s_fog.h index 9c487e13d1..88f9964cb5 100644 --- a/src/mesa/swrast/s_fog.h +++ b/src/mesa/swrast/s_fog.h @@ -1,4 +1,4 @@ -/* $Id: s_fog.h,v 1.3 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_fog.h,v 1.4 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -33,22 +33,20 @@ #include "swrast.h" - - extern void _mesa_fog_rgba_pixels( const GLcontext *ctx, - GLuint n, const GLfixed fog[], + GLuint n, const GLfloat fog[], GLchan rgba[][4] ); extern void _mesa_fog_ci_pixels( const GLcontext *ctx, - GLuint n, const GLfixed fog[], GLuint indx[] ); + GLuint n, const GLfloat fog[], GLuint indx[] ); extern void _mesa_win_fog_coords_from_z( const GLcontext *ctx, GLuint n, const GLdepth z[], - GLfixed fogcoord[] ); + GLfloat fogcoord[] ); extern void _mesa_depth_fog_rgba_pixels( const GLcontext *ctx, @@ -59,5 +57,4 @@ _mesa_depth_fog_ci_pixels( const GLcontext *ctx, GLuint n, const GLdepth z[], GLuint index[] ); - #endif diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 8971993ef5..eec354b84a 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -1,4 +1,4 @@ -/* $Id: s_lines.c,v 1.15 2001/03/29 16:50:32 brianp Exp $ */ +/* $Id: s_lines.c,v 1.16 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -239,7 +239,7 @@ static void smooth_rgba_z_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLchan (*pbrgba)[4] = PB->rgba; @@ -288,7 +288,7 @@ static void general_smooth_ci_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLuint *pbi = PB->index; PB->mono = GL_FALSE; @@ -371,7 +371,7 @@ static void general_flat_ci_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; PB_SET_INDEX( PB, vert0->index ); count = PB->count; @@ -446,7 +446,7 @@ static void general_smooth_rgba_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLchan (*pbrgba)[4] = PB->rgba; PB->mono = GL_FALSE; @@ -598,7 +598,7 @@ static void flat_textured_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLfloat *pbs = PB->s[0]; GLfloat *pbt = PB->t[0]; GLfloat *pbu = PB->u[0]; @@ -666,7 +666,7 @@ static void smooth_textured_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLfloat *pbs = PB->s[0]; GLfloat *pbt = PB->t[0]; GLfloat *pbu = PB->u[0]; @@ -747,7 +747,7 @@ static void smooth_multitextured_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLchan (*pbrgba)[4] = PB->rgba; GLchan (*pbspec)[3] = PB->spec; @@ -846,7 +846,7 @@ static void flat_multitextured_line( GLcontext *ctx, GLint *pbx = PB->x; GLint *pby = PB->y; GLdepth *pbz = PB->z; - GLfixed *pbfog = PB->fog; + GLfloat *pbfog = PB->fog; GLchan (*pbrgba)[4] = PB->rgba; GLchan (*pbspec)[3] = PB->spec; GLchan *color = (GLchan*) vert1->color; diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 5792b46a4a..f8fa310d76 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -1,4 +1,4 @@ -/* $Id: s_linetemp.h,v 1.7 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_linetemp.h,v 1.8 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -95,8 +95,8 @@ # endif #endif #ifdef INTERP_FOG - GLfixed fog0 = FloatToFixed(vert0->fog); - GLfixed dfog = FloatToFixed(vert1->fog) - fog0; + GLfloat fog0 = vert0->fog; + GLfloat dfog = vert1->fog - fog0; #endif #ifdef INTERP_RGB GLfixed r0 = IntToFixed(vert0->color[0]); diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index d26b042187..c0c47f82b1 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.12 2001/03/19 02:25:36 keithw Exp $ */ +/* $Id: s_span.c,v 1.13 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -180,7 +180,7 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n, */ void _mesa_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], GLuint indexIn[], GLenum primitive ) { const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT; @@ -272,7 +272,7 @@ void _mesa_write_index_span( GLcontext *ctx, void _mesa_write_monoindex_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], GLuint index, GLenum primitive ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); @@ -444,7 +444,7 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n, void _mesa_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, GLchan rgbaIn[][4], GLenum primitive ) { @@ -580,7 +580,7 @@ void _mesa_write_rgba_span( GLcontext *ctx, */ void _mesa_write_monocolor_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], const GLchan color[4], GLenum primitive ) { @@ -763,7 +763,7 @@ static void add_colors(GLuint n, GLchan rgba[][4], CONST GLchan specular[][4] ) */ void _mesa_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], const GLfloat s[], const GLfloat t[], const GLfloat u[], GLfloat lambda[], GLchan rgbaIn[][4], CONST GLchan spec[][4], @@ -906,7 +906,7 @@ void _mesa_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH], CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH], CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH], diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index aa7e3b3664..b1bb847bf6 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -1,4 +1,4 @@ -/* $Id: s_span.h,v 1.4 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_span.h,v 1.5 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -38,27 +38,27 @@ extern void _mesa_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], GLuint index[], GLenum primitive ); extern void _mesa_write_monoindex_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], GLuint index, GLenum primitive ); extern void _mesa_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], GLchan rgba[][4], GLenum primitive ); extern void _mesa_write_monocolor_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], const GLchan color[4], GLenum primitive ); @@ -66,7 +66,7 @@ extern void _mesa_write_monocolor_span( GLcontext *ctx, extern void _mesa_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], const GLfloat s[], const GLfloat t[], const GLfloat u[], GLfloat lambda[], GLchan rgba[][4], CONST GLchan spec[][4], @@ -77,7 +77,7 @@ extern void _mesa_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed fog[], + const GLfloat fog[], CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH], CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH], CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH], diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index f01dab5fdd..b7ca0abf35 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -1,4 +1,4 @@ -/* $Id: s_texstore.c,v 1.3 2001/04/13 00:13:51 brianp Exp $ */ +/* $Id: s_texstore.c,v 1.4 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -274,6 +274,7 @@ _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, return; } +#if 0 /* * XXX this is a bit of a hack. We need to be sure that the alpha * channel is 1.0 if the internal texture format is not supposed to @@ -289,7 +290,7 @@ _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, image[i + 3] = CHAN_MAX; } } - +#endif /* now call glTexSubImage1D to do the real work */ (*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width, GL_RGBA, CHAN_TYPE, image, @@ -342,6 +343,7 @@ _swrast_copy_texsubimage2d( GLcontext *ctx, return; } +#if 0 /* * XXX this is a bit of a hack. We need to be sure that the alpha * channel is 1.0 if the internal texture format is not supposed to @@ -357,7 +359,7 @@ _swrast_copy_texsubimage2d( GLcontext *ctx, image[i + 3] = CHAN_MAX; } } - +#endif /* now call glTexSubImage2D to do the real work */ (*ctx->Driver.TexSubImage2D)(ctx, target, level, xoffset, yoffset, width, height, @@ -411,7 +413,7 @@ _swrast_copy_texsubimage3d( GLcontext *ctx, _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" ); return; } - +#if 0 /* * XXX this is a bit of a hack. We need to be sure that the alpha * channel is 1.0 if the internal texture format is not supposed to @@ -427,7 +429,7 @@ _swrast_copy_texsubimage3d( GLcontext *ctx, image[i + 3] = CHAN_MAX; } } - +#endif /* now call glTexSubImage3D to do the real work */ (*ctx->Driver.TexSubImage3D)(ctx, target, level, xoffset, yoffset, zoffset, width, height, 1, diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index e61b576592..82c690502b 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1,4 +1,4 @@ -/* $Id: s_triangle.c,v 1.24 2001/03/29 16:50:32 brianp Exp $ */ +/* $Id: s_triangle.c,v 1.25 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -83,13 +83,13 @@ static void flat_ci_triangle( GLcontext *ctx, const GLint n = RIGHT-LEFT; \ GLint i; \ GLdepth zspan[MAX_WIDTH]; \ - GLfixed fogspan[MAX_WIDTH]; \ + GLfloat fogspan[MAX_WIDTH]; \ if (n>0) { \ for (i=0;iindex, GL_POLYGON ); \ @@ -118,7 +118,7 @@ static void smooth_ci_triangle( GLcontext *ctx, const GLint n = RIGHT-LEFT; \ GLint i; \ GLdepth zspan[MAX_WIDTH]; \ - GLfixed fogspan[MAX_WIDTH]; \ + GLfloat fogspan[MAX_WIDTH]; \ GLuint index[MAX_WIDTH]; \ if (n>0) { \ for (i=0;i0) { \ for (i=0;icolor, \ @@ -199,7 +199,7 @@ static void smooth_rgba_triangle( GLcontext *ctx, GLint i; \ GLdepth zspan[MAX_WIDTH]; \ GLchan rgba[MAX_WIDTH][4]; \ - GLfixed fogspan[MAX_WIDTH]; \ + GLfloat fogspan[MAX_WIDTH]; \ if (n>0) { \ for (i=0;i0) { \ ffs -= FIXED_HALF; /* off-by-one error? */ \ fft -= FIXED_HALF; \ @@ -505,9 +503,9 @@ static void affine_textured_triangle( GLcontext *ctx, GLint pos = (t << twidth_log2) + s; \ const GLchan *tex00 = texture + COMP * pos; \ zspan[i] = FixedToDepth(ffz); \ - fogspan[i] = fffog / 256; \ + fogspan[i] = ffog;; \ DO_TEX; \ - fffog += fdfogdx; \ + ffog += dfogdx; \ ffz += fdzdx; \ ffr += fdrdx; \ ffg += fdgdx; \ @@ -540,9 +538,9 @@ static void affine_textured_triangle( GLcontext *ctx, tex11 -= tbytesline; \ } \ zspan[i] = FixedToDepth(ffz); \ - fogspan[i] = fffog / 256; \ + fogspan[i] = ffog; \ DO_TEX; \ - fffog += fdfogdx; \ + ffog += dfogdx; \ ffz += fdzdx; \ ffr += fdrdx; \ ffg += fdgdx; \ @@ -559,7 +557,7 @@ static void affine_textured_triangle( GLcontext *ctx, CONST GLint n = RIGHT-LEFT; \ GLint i; \ GLdepth zspan[MAX_WIDTH]; \ - GLfixed fogspan[MAX_WIDTH]; \ + GLfloat fogspan[MAX_WIDTH]; \ GLchan rgba[MAX_WIDTH][4]; \ if (n>0) { \ GLchan *dest = rgba[0]; \ @@ -740,9 +738,9 @@ static void near_persp_textured_triangle(GLcontext *ctx, GLint pos = COMP * ((t << twidth_log2) + s); \ const GLchan *tex00 = texture + pos; \ zspan[i] = FixedToDepth(ffz); \ - fogspan[i] = fffog / 256; \ + fogspan[i] = ffog; \ DO_TEX; \ - fffog += fdfogdx; \ + ffog += dfogdx; \ ffz += fdzdx; \ ffr += fdrdx; \ ffg += fdgdx; \ @@ -910,9 +908,9 @@ static void near_persp_textured_triangle(GLcontext *ctx, j = n; \ while (i 0) { \ @@ -1510,9 +1508,9 @@ static void lin_persp_textured_triangle( GLcontext *ctx, tex11 -= tbytesline; \ } \ zspan[i] = FixedToDepth(ffz); \ - fogspan[i] = fffog / 256; \ + fogspan[i] = ffog; \ DO_TEX; \ - fffog += fdfogdx; \ + ffog += dfogdx; \ ffz += fdzdx; \ ffr += fdrdx; \ ffg += fdgdx; \ @@ -1529,7 +1527,7 @@ static void lin_persp_textured_triangle( GLcontext *ctx, GLint i; \ const GLint n = RIGHT-LEFT; \ GLdepth zspan[MAX_WIDTH]; \ - GLfixed fogspan[MAX_WIDTH]; \ + GLfloat fogspan[MAX_WIDTH]; \ GLchan rgba[MAX_WIDTH][4]; \ (void) uu; /* please GCC */ \ if (n > 0) { \ @@ -1625,7 +1623,7 @@ static void general_textured_triangle( GLcontext *ctx, GLint i; \ const GLint n = RIGHT-LEFT; \ GLdepth zspan[MAX_WIDTH]; \ - GLfixed fogspan[MAX_WIDTH]; \ + GLfloat fogspan[MAX_WIDTH]; \ GLchan rgba[MAX_WIDTH][4]; \ GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH]; \ if (n>0) { \ @@ -1633,7 +1631,7 @@ static void general_textured_triangle( GLcontext *ctx, for (i=0;i0) { \ @@ -1841,7 +1838,7 @@ static void lambda_textured_triangle1( GLcontext *ctx, for (i=0;i 0) { \ if (flat_shade) { \ for (i=0;iOcclusionResult = GL_TRUE; \ return; \ diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 062795debb..3bdb1537a0 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.14 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_tritemp.h,v 1.15 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -256,7 +256,7 @@ GLfloat dzdx, dzdy; GLfixed fdzdx; #endif #ifdef INTERP_FOG - GLfloat dfogdx, dfogdy; GLfixed fdfogdx; + GLfloat dfogdx, dfogdy; #endif #ifdef INTERP_RGB GLfloat drdx, drdy; GLfixed fdrdx; @@ -338,11 +338,9 @@ #endif #ifdef INTERP_FOG { - GLfloat eMaj_dfog, eBot_dfog; - eMaj_dfog = (vMax->fog - vMin->fog) * 256; - eBot_dfog = (vMid->fog - vMin->fog) * 256; + const GLfloat eMaj_dfog = vMax->fog - vMin->fog; + const GLfloat eBot_dfog = vMid->fog - vMin->fog; dfogdx = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog); - fdfogdx = SignedFloatToFixed(dfogdx); dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx); } #endif @@ -566,53 +564,54 @@ { int subTriangle; - GLfixed fx, fxLeftEdge, fxRightEdge, fdxLeftEdge, fdxRightEdge; + GLfixed fx; + GLfixed fxLeftEdge=0, fxRightEdge=0, fdxLeftEdge=0, fdxRightEdge=0; GLfixed fdxOuter; int idxOuter; float dxOuter; - GLfixed fError, fdError; + GLfixed fError=0, fdError=0; float adjx, adjy; GLfixed fy; - int iy; + int iy=0; #ifdef PIXEL_ADDRESS - PIXEL_TYPE *pRow; - int dPRowOuter, dPRowInner; /* offset in bytes */ + PIXEL_TYPE *pRow=NULL; + int dPRowOuter=0, dPRowInner=0; /* offset in bytes */ #endif #ifdef INTERP_Z # ifdef DEPTH_TYPE - DEPTH_TYPE *zRow; - int dZRowOuter, dZRowInner; /* offset in bytes */ + DEPTH_TYPE *zRow=NULL; + int dZRowOuter=0, dZRowInner=0; /* offset in bytes */ # endif - GLfixed fz, fdzOuter, fdzInner; + GLfixed fz=0, fdzOuter=0, fdzInner; #endif #ifdef INTERP_FOG - GLfixed ffog, fdfogOuter, fdfogInner; + GLfloat fogLeft, dfogOuter, dfogInner; #endif #ifdef INTERP_RGB - GLfixed fr, fdrOuter, fdrInner; - GLfixed fg, fdgOuter, fdgInner; - GLfixed fb, fdbOuter, fdbInner; + GLfixed fr=0, fdrOuter=0, fdrInner; + GLfixed fg=0, fdgOuter=0, fdgInner; + GLfixed fb=0, fdbOuter=0, fdbInner; #endif #ifdef INTERP_SPEC - GLfixed fsr, fdsrOuter, fdsrInner; - GLfixed fsg, fdsgOuter, fdsgInner; - GLfixed fsb, fdsbOuter, fdsbInner; + GLfixed fsr=0, fdsrOuter=0, fdsrInner; + GLfixed fsg=0, fdsgOuter=0, fdsgInner; + GLfixed fsb=0, fdsbOuter=0, fdsbInner; #endif #ifdef INTERP_ALPHA - GLfixed fa, fdaOuter, fdaInner; + GLfixed fa=0, fdaOuter=0, fdaInner; #endif #ifdef INTERP_INDEX - GLfixed fi, fdiOuter, fdiInner; + GLfixed fi=0, fdiOuter=0, fdiInner; #endif #ifdef INTERP_INT_TEX - GLfixed fs, fdsOuter, fdsInner; - GLfixed ft, fdtOuter, fdtInner; + GLfixed fs=0, fdsOuter=0, fdsInner; + GLfixed ft=0, fdtOuter=0, fdtInner; #endif #ifdef INTERP_TEX - GLfloat sLeft, dsOuter, dsInner; - GLfloat tLeft, dtOuter, dtInner; - GLfloat uLeft, duOuter, duInner; - GLfloat vLeft, dvOuter, dvInner; + GLfloat sLeft=0, dsOuter=0, dsInner; + GLfloat tLeft=0, dtOuter=0, dtInner; + GLfloat uLeft=0, duOuter=0, duInner; + GLfloat vLeft=0, dvOuter=0, dvInner; #endif #ifdef INTERP_MULTITEX GLfloat sLeft[MAX_TEXTURE_UNITS]; @@ -733,9 +732,9 @@ } #endif #ifdef INTERP_FOG - ffog = FloatToFixed(vLower->fog * 256 + dfogdx * adjx - + dfogdy * adjy) + FIXED_HALF; - fdfogOuter = SignedFloatToFixed(dfogdy + dxOuter * dfogdx); + fogLeft = vLower->fog + (dfogdx * adjx + dfogdy * adjy) + * (1.0F/FIXED_SCALE); + dfogOuter = dfogdy + dxOuter * dfogdx; #endif #ifdef INTERP_RGB fr = (GLfixed)(IntToFixed(vLower->color[0]) @@ -851,7 +850,7 @@ fdzInner = fdzOuter + fdzdx; #endif #ifdef INTERP_FOG - fdfogInner = fdfogOuter + fdfogdx; + dfogInner = dfogOuter + dfogdx; #endif #ifdef INTERP_RGB fdrInner = fdrOuter + fdrdx; @@ -902,7 +901,7 @@ GLfixed ffz = fz; #endif #ifdef INTERP_FOG - GLfixed fffog = ffog; + GLfloat ffog = fogLeft; #endif #ifdef INTERP_RGB GLfixed ffr = fr, ffg = fg, ffb = fb; @@ -1064,7 +1063,7 @@ fz += fdzOuter; #endif #ifdef INTERP_FOG - ffog += fdfogOuter; + fogLeft += dfogOuter; #endif #ifdef INTERP_RGB fr += fdrOuter; fg += fdgOuter; fb += fdbOuter; @@ -1112,7 +1111,7 @@ fz += fdzInner; #endif #ifdef INTERP_FOG - ffog += fdfogInner; + fogLeft += dfogInner; #endif #ifdef INTERP_RGB fr += fdrInner; fg += fdgInner; fb += fdbInner; diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index daace6920f..74053d0a5b 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -1,4 +1,4 @@ -/* $Id: s_zoom.c,v 1.4 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_zoom.c,v 1.5 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -46,7 +46,7 @@ void _mesa_write_zoomed_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, CONST GLchan rgba[][4], GLint y0 ) { GLint m; @@ -54,7 +54,7 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx, GLint i, j, skipcol; GLchan zrgba[MAX_WIDTH][4]; /* zoomed pixel colors */ GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */ - GLfixed zfog[MAX_WIDTH]; /* zoomed fog values */ + GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */ GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH ); const GLuint *srcRGBA32 = (const GLuint *) rgba; GLuint *dstRGBA32 = (GLuint *) zrgba; @@ -153,7 +153,7 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx, void _mesa_write_zoomed_rgb_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, CONST GLchan rgb[][3], GLint y0 ) { GLint m; @@ -161,7 +161,7 @@ _mesa_write_zoomed_rgb_span( GLcontext *ctx, GLint i, j, skipcol; GLchan zrgba[MAX_WIDTH][4]; /* zoomed pixel colors */ GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */ - GLfixed zfog[MAX_WIDTH]; /* zoomed fog values */ + GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */ GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH ); /* compute width of output row */ @@ -266,7 +266,7 @@ _mesa_write_zoomed_rgb_span( GLcontext *ctx, void _mesa_write_zoomed_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, const GLuint indexes[], GLint y0 ) { GLint m; @@ -274,7 +274,7 @@ _mesa_write_zoomed_index_span( GLcontext *ctx, GLint i, j, skipcol; GLuint zindexes[MAX_WIDTH]; /* zoomed color indexes */ GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */ - GLfixed zfog[MAX_WIDTH]; /* zoomed fog values */ + GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */ GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH ); /* compute width of output row */ diff --git a/src/mesa/swrast/s_zoom.h b/src/mesa/swrast/s_zoom.h index 170133c3df..940970d7ab 100644 --- a/src/mesa/swrast/s_zoom.h +++ b/src/mesa/swrast/s_zoom.h @@ -1,4 +1,4 @@ -/* $Id: s_zoom.h,v 1.4 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_zoom.h,v 1.5 2001/05/03 22:13:32 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -35,21 +35,21 @@ extern void _mesa_write_zoomed_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, CONST GLchan rgba[][4], GLint y0 ); extern void _mesa_write_zoomed_rgb_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, CONST GLchan rgb[][3], GLint y0 ); extern void _mesa_write_zoomed_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], - const GLfixed *fog, + const GLfloat *fog, const GLuint indexes[], GLint y0 ); -- cgit v1.2.3