summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/glide/fxdrv.h2
-rw-r--r--src/mesa/main/colormac.h23
-rw-r--r--src/mesa/main/image.c14
-rw-r--r--src/mesa/main/pixel.c18
-rw-r--r--src/mesa/swrast/s_drawpix.c11
-rw-r--r--src/mesa/swrast/s_fog.c10
-rw-r--r--src/mesa/swrast/s_texture.c13
-rw-r--r--src/mesa/tnl/t_imm_eval.c13
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h26
-rw-r--r--src/mesa/tnl/t_vb_render.c8
10 files changed, 75 insertions, 63 deletions
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index 3e3147e3632..38ce0ce2dab 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -93,8 +93,6 @@ extern float gl_ubyte_to_float_255_color_tab[256];
(*(int *)&(f)) = ((int *)gl_ubyte_to_float_255_color_tab)[c]
-#define LINTERP(T, A, B) ((A) + (T) * ((B) - (A)))
-
/* Should have size == 16 * sizeof(float).
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index 6101ab02256..94e4af51ece 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,4 +1,4 @@
-/* $Id: colormac.h,v 1.5 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: colormac.h,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -52,7 +52,6 @@
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))
#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)
-#define FLOAT_TO_CHAN(f) ( (GLchan) IROUND((f) * CHAN_MAXF) )
#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f)
@@ -72,7 +71,6 @@
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF) + 0.5F))
-#define FLOAT_TO_CHAN(f) ((GLchan) IROUND((f) * CHAN_MAXF))
#define CLAMPED_FLOAT_TO_CHAN(c, f) \
c = ((GLchan) IROUND((f) * CHAN_MAXF))
@@ -95,9 +93,8 @@
#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
#define CHAN_TO_FLOAT(c) (c)
-#define FLOAT_TO_CHAN(f) (f)
-#define CLAMPED_FLOAT_COLOR_TO_CHAN(c, f) c = (f)
+#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
@@ -115,12 +112,24 @@
/*
* Convert 3 channels at once.
*/
-#define FLOAT_RGB_TO_CHAN_RGB(dst, f) \
+#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \
do { \
UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
-} while(0)
+} while (0)
+
+
+/*
+ * Convert 4 channels at once.
+ */
+#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]); \
+} while (0)
#endif /* COLORMAC_H */
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 6c50fed23e4..de56f0be9d0 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.51 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: image.c,v 1.52 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -2721,7 +2721,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstRedIndex] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstRedIndex], rgba[i][RCOMP]);
dst += dstComponents;
}
}
@@ -2730,7 +2730,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstGreenIndex] = FLOAT_TO_CHAN(rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstGreenIndex], rgba[i][GCOMP]);
dst += dstComponents;
}
}
@@ -2739,7 +2739,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstBlueIndex] = FLOAT_TO_CHAN(rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstBlueIndex], rgba[i][BCOMP]);
dst += dstComponents;
}
}
@@ -2748,7 +2748,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstAlphaIndex] = FLOAT_TO_CHAN(rgba[i][ACOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstAlphaIndex], rgba[i][ACOMP]);
dst += dstComponents;
}
}
@@ -2760,7 +2760,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
assert(dstComponents == 1);
for (i = 0; i < n; i++) {
/* Intensity comes from red channel */
- dst[i] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]);
}
}
@@ -2770,7 +2770,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
assert(dstLuminanceIndex == 0);
for (i = 0; i < n; i++) {
/* Luminance comes from red channel */
- dst[0] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]);
dst += dstComponents;
}
}
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 6bbbbdfe3ec..270cbc7e8cb 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.22 2000/12/26 05:09:29 keithw Exp $ */
+/* $Id: pixel.c,v 1.23 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1126,10 +1126,10 @@ _mesa_map_ci_to_rgba_chan( const GLcontext *ctx, GLuint n,
const GLfloat *aMap = ctx->Pixel.MapItoA;
GLuint i;
for (i=0;i<n;i++) {
- rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]);
- rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]);
- rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]);
- rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
}
#endif
}
@@ -1194,10 +1194,10 @@ _mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
const GLfloat *aMap = ctx->Pixel.MapItoA;
GLuint i;
for (i=0;i<n;i++) {
- rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]);
- rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]);
- rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]);
- rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
}
#endif
}
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index ccb48a7ef95..63281b2f730 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.5 2000/12/26 05:09:32 keithw Exp $ */
+/* $Id: s_drawpix.c,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -605,11 +605,12 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
/* Colors or indexes */
if (ctx->Visual.RGBAflag) {
- GLint r = FLOAT_TO_CHAN(ctx->Current.RasterColor[0]);
- GLint g = FLOAT_TO_CHAN(ctx->Current.RasterColor[1]);
- GLint b = FLOAT_TO_CHAN(ctx->Current.RasterColor[2]);
- GLint a = FLOAT_TO_CHAN(ctx->Current.RasterColor[3]);
GLint i;
+ GLint r, g, b, a;
+ UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]);
for (i = 0; i < drawWidth; i++) {
rgba[i][RCOMP] = r;
rgba[i][GCOMP] = g;
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 0e65f784f8e..6e6c207aa4a 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.6 2001/01/02 21:09:50 brianp Exp $ */
+/* $Id: s_fog.c,v 1.7 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,10 +49,12 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx,
const GLfixed fog[],
GLchan rgba[][4] )
{
- const GLchan rFog = FLOAT_TO_CHAN(ctx->Fog.Color[RCOMP]);
- const GLchan gFog = FLOAT_TO_CHAN(ctx->Fog.Color[GCOMP]);
- const GLchan bFog = FLOAT_TO_CHAN(ctx->Fog.Color[BCOMP]);
GLuint i;
+ GLchan rFog, gFog, bFog;
+
+ UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
+ 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++) {
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index bcc5f2677d9..29d6b46f4db 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.5 2001/01/02 22:02:52 brianp Exp $ */
+/* $Id: s_texture.c,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1841,8 +1841,8 @@ _mesa_texture_combine(const GLcontext *ctx,
break;
case GL_CONSTANT_EXT:
{
- GLchan (*c)[4] = ccolor[j];
- GLchan alpha = FLOAT_TO_CHAN(textureUnit->EnvColor[3]);
+ GLchan alpha, (*c)[4] = ccolor[j];
+ UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]);
for (i = 0; i < n; i++)
c[i][ACOMP] = alpha;
argA[j] = ccolor[j];
@@ -1865,9 +1865,10 @@ _mesa_texture_combine(const GLcontext *ctx,
case GL_CONSTANT_EXT:
{
GLchan (*c)[4] = ccolor[j];
- const GLchan red = FLOAT_TO_CHAN(textureUnit->EnvColor[0]);
- const GLchan green = FLOAT_TO_CHAN(textureUnit->EnvColor[1]);
- const GLchan blue = FLOAT_TO_CHAN(textureUnit->EnvColor[2]);
+ GLchan red, green, blue;
+ UNCLAMPED_FLOAT_TO_CHAN(red, textureUnit->EnvColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(green, textureUnit->EnvColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(blue, textureUnit->EnvColor[2]);
for (i = 0; i < n; i++) {
c[i][RCOMP] = red;
c[i][GCOMP] = green;
diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c
index 419f449f033..235baa38b8b 100644
--- a/src/mesa/tnl/t_imm_eval.c
+++ b/src/mesa/tnl/t_imm_eval.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_eval.c,v 1.2 2000/12/27 22:30:29 keithw Exp $ */
+/* $Id: t_imm_eval.c,v 1.3 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -154,13 +154,14 @@ static void eval1_color( GLvector4ub *dest,
GLubyte (*to)[4] = dest->data;
GLuint i;
- for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++)
+ for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) {
if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
GLfloat u = (coord[i][0] - u1) * du;
GLfloat fcolor[4];
_math_horner_bezier_curve(map->Points, fcolor, u, 4, map->Order);
- FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN(to[i], fcolor);
}
+ }
}
@@ -287,16 +288,16 @@ static void eval2_color( GLvector4ub *dest,
GLubyte (*to)[4] = dest->data;
GLuint i;
- for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++)
+ for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) {
if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
GLfloat u = (coord[i][0] - u1) * du;
GLfloat v = (coord[i][1] - v1) * dv;
GLfloat fcolor[4];
_math_horner_bezier_surf(map->Points, fcolor, u, v, 4,
map->Uorder, map->Vorder);
- FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN(to[i], fcolor);
}
-
+ }
}
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index f2bcde67148..656fffff1ad 100644
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ b/src/mesa/tnl/t_vb_lighttmp.h
@@ -1,4 +1,4 @@
-/* $Id: t_vb_lighttmp.h,v 1.1 2000/12/26 05:09:33 keithw Exp $ */
+/* $Id: t_vb_lighttmp.h,v 1.2 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -269,13 +269,13 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
}
} /*loop over lights*/
- FLOAT_RGB_TO_CHAN_RGB( Fcolor[j], sum[0] );
- FLOAT_RGB_TO_CHAN_RGB( Fspec[j], spec[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fspec[j], spec[0] );
Fcolor[j][3] = sumA[0];
if (IDX & LIGHT_TWOSIDE) {
- FLOAT_RGB_TO_CHAN_RGB( Bcolor[j], sum[1] );
- FLOAT_RGB_TO_CHAN_RGB( Bspec[j], spec[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bspec[j], spec[1] );
Bcolor[j][3] = sumA[1];
}
}
@@ -475,11 +475,11 @@ static void TAG(light_rgba)( GLcontext *ctx,
ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
}
- FLOAT_RGB_TO_CHAN_RGB( Fcolor[j], sum[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
Fcolor[j][3] = sumA[0];
if (IDX & LIGHT_TWOSIDE) {
- FLOAT_RGB_TO_CHAN_RGB( Bcolor[j], sum[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
Bcolor[j][3] = sumA[1];
}
}
@@ -556,12 +556,12 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
{
COPY_3V(base[0], light->_MatAmbient[0]);
ACC_3V(base[0], ctx->Light._BaseColor[0] );
- FLOAT_RGB_TO_CHAN_RGB( baseubyte[0], base[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[0], base[0] );
if (IDX & LIGHT_TWOSIDE) {
COPY_3V(base[1], light->_MatAmbient[1]);
ACC_3V(base[1], ctx->Light._BaseColor[1]);
- FLOAT_RGB_TO_CHAN_RGB( baseubyte[1], base[1]);
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[1], base[1]);
}
}
@@ -582,7 +582,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
}
- FLOAT_RGB_TO_CHAN_RGB(Bcolor[j], sum );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN(Bcolor[j], sum );
}
} else {
GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm);
@@ -595,7 +595,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
}
- FLOAT_RGB_TO_CHAN_RGB(Fcolor[j], sum );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN(Fcolor[j], sum );
}
j++;
@@ -709,11 +709,11 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
}
}
- FLOAT_RGB_TO_CHAN_RGB( Fcolor[j], sum[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
Fcolor[j][3] = sumA[0];
if (IDX & LIGHT_TWOSIDE) {
- FLOAT_RGB_TO_CHAN_RGB( Bcolor[j], sum[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
Bcolor[j][3] = sumA[1];
}
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index 1d0a1aaf152..b3fef235019 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.4 2000/12/28 22:11:06 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.5 2001/01/03 15:59:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -119,19 +119,19 @@ do { \
#if 1
-#define LINTERP_RGBA(nr, t, out, a, b) { \
+#define LINTERP_RGBA(nr, t, out, a, b) { \
int i; \
for (i = 0; i < nr; i++) { \
GLfloat fa = CHAN_TO_FLOAT(a[i]); \
GLfloat fb = CHAN_TO_FLOAT(b[i]); \
GLfloat fo = LINTERP(t, fa, fb); \
- FLOAT_COLOR_TO_CHAN(out[i], fo); \
+ CLAMPED_FLOAT_TO_CHAN(out[i], fo); \
} \
}
#else
-#define LINTERP_RGBA(nr, t, out, a, b) { \
+#define LINTERP_RGBA(nr, t, out, a, b) { \
int n; \
const GLuint ti = FloatToInt(t*256.0F); \
const GLubyte *Ib = (const GLubyte *)&a[0]; \