summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/x11/xm_api.c11
-rw-r--r--src/mesa/main/colortab.c40
-rw-r--r--src/mesa/main/drawpix.c6
-rw-r--r--src/mesa/main/pixel.c58
-rw-r--r--src/mesa/swrast/s_accum.c15
-rw-r--r--src/mesa/swrast/s_drawpix.c4
-rw-r--r--src/mesa/swrast/s_texture.c46
7 files changed, 91 insertions, 89 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 96dfc4bfe47..b115c92295f 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -1,4 +1,4 @@
-/* $Id: xm_api.c,v 1.19 2001/03/19 02:25:36 keithw Exp $ */
+/* $Id: xm_api.c,v 1.20 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -71,6 +71,7 @@
#include "glthread.h"
#include "matrix.h"
#include "mem.h"
+#include "mmath.h"
#include "mtypes.h"
#ifdef HAVE_CONFIG_H
#include "conf.h"
@@ -264,7 +265,7 @@ static GLint gamma_adjust( GLfloat gamma, GLint value, GLint max )
}
else {
double x = (double) value / (double) max;
- return (GLint) ((GLfloat) max * pow( x, 1.0F/gamma ) + 0.5F);
+ return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma));
}
}
@@ -985,19 +986,19 @@ static void setup_8bit_hpcr( XMesaVisual v )
g = 1.0 / v->RedGamma;
for (i=0; i<256; i++) {
- GLint red = (GLint) (255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g ) + 0.5);
+ GLint red = IROUND_POS(255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g ));
v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 );
}
g = 1.0 / v->GreenGamma;
for (i=0; i<256; i++) {
- GLint green = (GLint) (255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g ) + 0.5);
+ GLint green = IROUND_POS(255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g ));
v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 );
}
g = 1.0 / v->BlueGamma;
for (i=0; i<256; i++) {
- GLint blue = (GLint) (255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g ) + 0.5);
+ GLint blue = IROUND_POS(255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g ));
v->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 );
}
v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 5a50ae50e66..61f93be2aad 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.38 2001/03/19 02:25:35 keithw Exp $ */
+/* $Id: colortab.c,v 1.39 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -683,7 +683,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
rgba[i][RCOMP] = 0;
rgba[i][GCOMP] = 0;
rgba[i][BCOMP] = 0;
- rgba[i][ACOMP] = (GLint) (tableF[i] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
}
}
else {
@@ -702,9 +702,9 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
rgba[i][ACOMP] = CHAN_MAX;
}
}
@@ -724,10 +724,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*2+0] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i*2+0] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i*2+0] * CHAN_MAXF);
- rgba[i][ACOMP] = (GLint) (tableF[i*2+1] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i*2+1] * CHAN_MAXF);
}
}
else {
@@ -746,10 +746,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][ACOMP] = (GLint) (tableF[i] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
}
}
else {
@@ -768,9 +768,9 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*3+0] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i*3+1] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i*3+2] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*3+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*3+1] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*3+2] * CHAN_MAXF);
rgba[i][ACOMP] = CHAN_MAX;
}
}
@@ -790,10 +790,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * CHAN_MAXF + 0.5F);
- rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * CHAN_MAXF + 0.5F);
- rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * CHAN_MAXF + 0.5F);
- rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * CHAN_MAXF + 0.5F);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*4+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*4+1] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*4+2] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i*4+3] * CHAN_MAXF);
}
}
else {
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 4b34ddd707a..d46ace0a655 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.51 2001/03/19 02:25:35 keithw Exp $ */
+/* $Id: drawpix.c,v 1.52 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -64,8 +64,8 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
_mesa_update_state(ctx);
}
- x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
- y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
+ x = IROUND(ctx->Current.RasterPos[0]);
+ y = IROUND(ctx->Current.RasterPos[1]);
ctx->OcclusionResult = GL_TRUE;
ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 6a31d5a59fe..dc8f5be3073 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.27 2001/03/12 00:48:38 gareth Exp $ */
+/* $Id: pixel.c,v 1.28 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -832,10 +832,10 @@ _mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
const GLfloat *aMap = ctx->Pixel.MapAtoA;
GLuint i;
for (i=0;i<n;i++) {
- rgba[i][RCOMP] = rMap[(GLint) (rgba[i][RCOMP] * rscale + 0.5F)];
- rgba[i][GCOMP] = gMap[(GLint) (rgba[i][GCOMP] * gscale + 0.5F)];
- rgba[i][BCOMP] = bMap[(GLint) (rgba[i][BCOMP] * bscale + 0.5F)];
- rgba[i][ACOMP] = aMap[(GLint) (rgba[i][ACOMP] * ascale + 0.5F)];
+ rgba[i][RCOMP] = rMap[IROUND(rgba[i][RCOMP] * rscale)];
+ rgba[i][GCOMP] = gMap[IROUND(rgba[i][GCOMP] * gscale)];
+ rgba[i][BCOMP] = bMap[IROUND(rgba[i][BCOMP] * bscale)];
+ rgba[i][ACOMP] = aMap[IROUND(rgba[i][ACOMP] * ascale)];
}
}
@@ -888,7 +888,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = CHAN_TO_FLOAT(lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
@@ -900,7 +900,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = lut[j];
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
@@ -914,7 +914,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = CHAN_TO_FLOAT(lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
@@ -924,7 +924,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = lut[j];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
@@ -937,7 +937,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[j]);
}
}
@@ -946,7 +946,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = lut[j];
}
}
@@ -958,8 +958,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jL = IROUND(rgba[i][RCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
GLfloat luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]);
GLfloat alpha = CHAN_TO_FLOAT(lut[jA * 2 + 1]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
@@ -971,8 +971,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jL = IROUND(rgba[i][RCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
GLfloat luminance = lut[jL * 2 + 0];
GLfloat alpha = lut[jA * 2 + 1];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
@@ -987,9 +987,9 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 3 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 3 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 3 + 2]);
@@ -1000,9 +1000,9 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
rgba[i][RCOMP] = lut[jR * 3 + 0];
rgba[i][GCOMP] = lut[jG * 3 + 1];
rgba[i][BCOMP] = lut[jB * 3 + 2];
@@ -1016,10 +1016,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 4 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 4 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 4 + 2]);
@@ -1031,10 +1031,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
rgba[i][RCOMP] = lut[jR * 4 + 0];
rgba[i][GCOMP] = lut[jG * 4 + 1];
rgba[i][BCOMP] = lut[jB * 4 + 2];
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index d93396677f1..f338886c9c7 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -1,4 +1,4 @@
-/* $Id: s_accum.c,v 1.9 2001/03/19 02:25:36 keithw Exp $ */
+/* $Id: s_accum.c,v 1.10 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -27,6 +27,7 @@
#include "context.h"
#include "macros.h"
+#include "mmath.h"
#include "mem.h"
#include "s_accum.h"
@@ -449,7 +450,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
GLint j;
if (mult != prevMult) {
for (j = 0; j < max; j++)
- multTable[j] = (GLint) ((GLfloat) j * mult + 0.5F);
+ multTable[j] = IROUND((GLfloat) j * mult);
prevMult = mult;
}
@@ -490,11 +491,11 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
for (j=0;j<height;j++) {
const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
for (i=0;i<width;i++) {
- GLint r, g, b, a;
- r = (GLint) ( (GLfloat) (*acc++) * rscale + 0.5F );
- g = (GLint) ( (GLfloat) (*acc++) * gscale + 0.5F );
- b = (GLint) ( (GLfloat) (*acc++) * bscale + 0.5F );
- a = (GLint) ( (GLfloat) (*acc++) * ascale + 0.5F );
+ GLint r = IROUND( (GLfloat) (acc[0]) * rscale );
+ GLint g = IROUND( (GLfloat) (acc[1]) * gscale );
+ GLint b = IROUND( (GLfloat) (acc[2]) * bscale );
+ GLint a = IROUND( (GLfloat) (acc[3]) * ascale );
+ acc += 4;
rgba[i][RCOMP] = CLAMP( r, 0, iChanMax );
rgba[i][GCOMP] = CLAMP( g, 0, iChanMax );
rgba[i][BCOMP] = CLAMP( b, 0, iChanMax );
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index cfc1383a63b..8432fe32758 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.15 2001/03/19 02:25:36 keithw Exp $ */
+/* $Id: s_drawpix.c,v 1.16 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -190,7 +190,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
zSpan[i] = z;
/* save Y value of first row */
- zoomY0 = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
+ zoomY0 = IROUND(ctx->Current.RasterPos[1]);
}
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 73e1b6718d1..55c5277fd33 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.21 2001/03/28 20:40:52 gareth Exp $ */
+/* $Id: s_texture.c,v 1.22 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -320,10 +320,10 @@ sample_1d_linear(GLcontext *ctx,
}
{
- const GLfloat a = FRAC(u);
+ const GLfloat a = FRAC(u + 1.0F);
/* compute sample weights in fixed point in [0,WEIGHT_SCALE] */
- const GLint w0 = IROUND((1.0F-a) * WEIGHT_SCALE);
- const GLint w1 = IROUND( a * WEIGHT_SCALE);
+ const GLint w0 = IROUND_POS((1.0F-a) * WEIGHT_SCALE);
+ const GLint w1 = IROUND_POS( a * WEIGHT_SCALE);
GLchan t0[4], t1[4]; /* texels */
@@ -612,13 +612,13 @@ sample_2d_linear(GLcontext *ctx,
}
{
- const GLfloat a = FRAC(u);
- const GLfloat b = FRAC(v);
+ const GLfloat a = FRAC(u + 1.0F); /* add one in case u is just below 0 */
+ const GLfloat b = FRAC(v + 1.0F);
/* compute sample weights in fixed point in [0,WEIGHT_SCALE] */
- const GLint w00 = IROUND((1.0F-a) * (1.0F-b) * WEIGHT_SCALE);
- const GLint w10 = IROUND( a * (1.0F-b) * WEIGHT_SCALE);
- const GLint w01 = IROUND((1.0F-a) * b * WEIGHT_SCALE);
- const GLint w11 = IROUND( a * b * WEIGHT_SCALE);
+ const GLint w00 = IROUND_POS((1.0F-a) * (1.0F-b) * WEIGHT_SCALE);
+ const GLint w10 = IROUND_POS( a * (1.0F-b) * WEIGHT_SCALE);
+ const GLint w01 = IROUND_POS((1.0F-a) * b * WEIGHT_SCALE);
+ const GLint w11 = IROUND_POS( a * b * WEIGHT_SCALE);
GLchan t00[4];
GLchan t10[4];
GLchan t01[4];
@@ -1032,18 +1032,18 @@ sample_3d_linear(GLcontext *ctx,
}
{
- const GLfloat a = FRAC(u);
- const GLfloat b = FRAC(v);
- const GLfloat c = FRAC(w);
+ const GLfloat a = FRAC(u + 1.0F);
+ const GLfloat b = FRAC(v + 1.0F);
+ const GLfloat c = FRAC(w + 1.0F);
/* compute sample weights in fixed point in [0,WEIGHT_SCALE] */
- GLint w000 = IROUND((1.0F-a) * (1.0F-b) * (1.0F-c) * WEIGHT_SCALE);
- GLint w100 = IROUND( a * (1.0F-b) * (1.0F-c) * WEIGHT_SCALE);
- GLint w010 = IROUND((1.0F-a) * b * (1.0F-c) * WEIGHT_SCALE);
- GLint w110 = IROUND( a * b * (1.0F-c) * WEIGHT_SCALE);
- GLint w001 = IROUND((1.0F-a) * (1.0F-b) * c * WEIGHT_SCALE);
- GLint w101 = IROUND( a * (1.0F-b) * c * WEIGHT_SCALE);
- GLint w011 = IROUND((1.0F-a) * b * c * WEIGHT_SCALE);
- GLint w111 = IROUND( a * b * c * WEIGHT_SCALE);
+ GLint w000 = IROUND_POS((1.0F-a) * (1.0F-b) * (1.0F-c) * WEIGHT_SCALE);
+ GLint w100 = IROUND_POS( a * (1.0F-b) * (1.0F-c) * WEIGHT_SCALE);
+ GLint w010 = IROUND_POS((1.0F-a) * b * (1.0F-c) * WEIGHT_SCALE);
+ GLint w110 = IROUND_POS( a * b * (1.0F-c) * WEIGHT_SCALE);
+ GLint w001 = IROUND_POS((1.0F-a) * (1.0F-b) * c * WEIGHT_SCALE);
+ GLint w101 = IROUND_POS( a * (1.0F-b) * c * WEIGHT_SCALE);
+ GLint w011 = IROUND_POS((1.0F-a) * b * c * WEIGHT_SCALE);
+ GLint w111 = IROUND_POS( a * b * c * WEIGHT_SCALE);
GLchan t000[4], t010[4], t001[4], t011[4];
GLchan t100[4], t110[4], t101[4], t111[4];
@@ -2531,8 +2531,8 @@ sample_depth_texture(const GLcontext *ctx,
if (0) {
/* compute a single weighted depth sample and do one comparison */
- const GLfloat a = FRAC(u);
- const GLfloat b = FRAC(v);
+ const GLfloat a = FRAC(u + 1.0F);
+ const GLfloat b = FRAC(v + 1.0F);
const GLfloat w00 = (1.0F - a) * (1.0F - b);
const GLfloat w10 = ( a) * (1.0F - b);
const GLfloat w01 = (1.0F - a) * ( b);