summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-08-22 15:51:02 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-08-22 15:51:02 -0600
commit9935e3b7303da656e258d4bd5bc799ffbfbc737b (patch)
treec37b72bf0e4b1838745a6aa8d5b1cfee93cd285c
parent120270def74149b240926f827b80ca073536d462 (diff)
gallium: stop using ifloor(), FABSF(), etc
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c72
2 files changed, 44 insertions, 42 deletions
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index dd0562e7ef..c8c55fa6e8 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -44,6 +44,8 @@
#include "draw/draw_vertex.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+
#define DEBUG_VERTS 0
#define DEBUG_FRAGS 0
@@ -611,18 +613,18 @@ static void setup_tri_edges( struct setup_context *setup )
float vmid_y = setup->vmid[0][1] - 0.5f;
float vmax_y = setup->vmax[0][1] - 0.5f;
- setup->emaj.sy = CEILF(vmin_y);
- setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy);
+ setup->emaj.sy = ceilf(vmin_y);
+ setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy);
setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy;
setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy;
- setup->etop.sy = CEILF(vmid_y);
- setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy);
+ setup->etop.sy = ceilf(vmid_y);
+ setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy);
setup->etop.dxdy = setup->etop.dx / setup->etop.dy;
setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy;
- setup->ebot.sy = CEILF(vmin_y);
- setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy);
+ setup->ebot.sy = ceilf(vmin_y);
+ setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy);
setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy;
setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index d7680ffa81..58a95d13e1 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -51,7 +51,7 @@
* Also note, FRAC(x) doesn't truly return the fractional part of x for x < 0.
* Instead, if x < 0 then FRAC(x) = 1 - true_frac(x).
*/
-#define FRAC(f) ((f) - ifloor(f))
+#define FRAC(f) ((f) - util_ifloor(f))
/**
@@ -100,7 +100,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
case PIPE_TEX_WRAP_REPEAT:
/* s limited to [0,1) */
/* i limited to [0,size-1] */
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
i = REMAINDER(i, size);
return i;
case PIPE_TEX_WRAP_CLAMP:
@@ -111,7 +111,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s >= 1.0F)
i = size - 1;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
return i;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
{
@@ -124,7 +124,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s > max)
i = size - 1;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
}
return i;
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
@@ -138,14 +138,14 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s >= max)
i = size;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
{
const float min = 1.0F / (2.0F * size);
const float max = 1.0F - min;
- const int flr = ifloor(s);
+ const int flr = util_ifloor(s);
float u;
if (flr & 1)
u = 1.0F - (s - (float) flr);
@@ -156,20 +156,20 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (u > max)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
{
/* s limited to [0,1] */
/* i limited to [0,size-1] */
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u <= 0.0F)
i = 0;
else if (u >= 1.0F)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
@@ -178,13 +178,13 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
/* i limited to [0, size-1] */
const float min = 1.0F / (2.0F * size);
const float max = 1.0F - min;
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u < min)
i = 0;
else if (u > max)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
@@ -193,13 +193,13 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
/* i limited to [0, size-1] */
const float min = -1.0F / (2.0F * size);
const float max = 1.0F - min;
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u < min)
i = -1;
else if (u > max)
i = size;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
default:
@@ -226,7 +226,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
switch (wrapMode) {
case PIPE_TEX_WRAP_REPEAT:
u = s * size - 0.5F;
- *i0 = REMAINDER(ifloor(u), size);
+ *i0 = REMAINDER(util_ifloor(u), size);
*i1 = REMAINDER(*i0 + 1, size);
break;
case PIPE_TEX_WRAP_CLAMP:
@@ -237,7 +237,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -248,7 +248,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -266,19 +266,19 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
{
- const int flr = ifloor(s);
+ const int flr = util_ifloor(s);
if (flr & 1)
u = 1.0F - (s - (float) flr);
else
u = s - (float) flr;
u = (u * size) - 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -287,23 +287,23 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
}
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (float) size;
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (float) size;
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -314,7 +314,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
{
const float min = -1.0F / (2.0F * size);
const float max = 1.0F - min;
- u = FABSF(s);
+ u = fabsf(s);
if (u <= min)
u = min * size;
else if (u >= max)
@@ -322,7 +322,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
@@ -343,12 +343,12 @@ nearest_texcoord_unnorm(unsigned wrapMode, float s, unsigned size)
int i;
switch (wrapMode) {
case PIPE_TEX_WRAP_CLAMP:
- i = ifloor(s);
+ i = util_ifloor(s);
return CLAMP(i, 0, (int) size-1);
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
/* fall-through */
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- return ifloor( CLAMP(s, 0.5F, (float) size - 0.5F) );
+ return util_ifloor( CLAMP(s, 0.5F, (float) size - 0.5F) );
default:
assert(0);
return 0;
@@ -368,7 +368,7 @@ linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
case PIPE_TEX_WRAP_CLAMP:
/* Not exactly what the spec says, but it matches NVIDIA output */
s = CLAMP(s - 0.5F, 0.0f, (float) size - 1.0f);
- *i0 = ifloor(s);
+ *i0 = util_ifloor(s);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -376,7 +376,7 @@ linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
s = CLAMP(s, 0.5F, (float) size - 0.5F);
s -= 0.5F;
- *i0 = ifloor(s);
+ *i0 = util_ifloor(s);
*i1 = *i0 + 1;
if (*i1 > (int) size - 1)
*i1 = size - 1;
@@ -402,7 +402,7 @@ choose_cube_face(float rx, float ry, float rz, float *newS, float *newT)
+rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz
-rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz
*/
- const float arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
unsigned face;
float sc, tc, ma;
@@ -477,16 +477,16 @@ compute_lambda(struct tgsi_sampler *sampler,
{
float dsdx = s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT];
float dsdy = s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT];
- dsdx = FABSF(dsdx);
- dsdy = FABSF(dsdy);
+ dsdx = fabsf(dsdx);
+ dsdy = fabsf(dsdy);
rho = MAX2(dsdx, dsdy) * sampler->texture->width[0];
}
if (t) {
float dtdx = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT];
float dtdy = t[QUAD_TOP_LEFT] - t[QUAD_BOTTOM_LEFT];
float max;
- dtdx = FABSF(dtdx);
- dtdy = FABSF(dtdy);
+ dtdx = fabsf(dtdx);
+ dtdy = fabsf(dtdy);
max = MAX2(dtdx, dtdy) * sampler->texture->height[0];
rho = MAX2(rho, max);
}
@@ -494,8 +494,8 @@ compute_lambda(struct tgsi_sampler *sampler,
float dpdx = p[QUAD_BOTTOM_RIGHT] - p[QUAD_BOTTOM_LEFT];
float dpdy = p[QUAD_TOP_LEFT] - p[QUAD_BOTTOM_LEFT];
float max;
- dpdx = FABSF(dpdx);
- dpdy = FABSF(dpdy);
+ dpdx = fabsf(dpdx);
+ dpdy = fabsf(dpdy);
max = MAX2(dpdx, dpdy) * sampler->texture->depth[0];
rho = MAX2(rho, max);
}