#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
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;
}
* 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))
/**
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:
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:
{
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:
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);
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:
/* 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:
/* 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:
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:
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:
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
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;
}
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;
{
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)
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
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;
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:
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;
+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;
{
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);
}
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);
}