summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/drawpix.c24
-rw-r--r--src/mesa/main/eval.c21
-rw-r--r--src/mesa/main/get.c44
-rw-r--r--src/mesa/main/light.c27
-rw-r--r--src/mesa/main/pixel.c3
-rw-r--r--src/mesa/main/pixelstore.c5
-rw-r--r--src/mesa/main/samplerobj.c14
-rw-r--r--src/mesa/main/texparam.c10
-rw-r--r--src/mesa/swrast/s_blit.c6
-rw-r--r--src/mesa/swrast/s_context.h3
-rw-r--r--src/util/imports.h17
-rw-r--r--src/util/rounding.h1
12 files changed, 80 insertions, 95 deletions
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 45896c15552..828199ea5dd 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -23,7 +23,6 @@
*/
#include "glheader.h"
-#include "util/imports.h"
#include "draw_validate.h"
#include "bufferobj.h"
#include "context.h"
@@ -37,6 +36,7 @@
#include "glformats.h"
#include "fbobject.h"
#include "util/u_math.h"
+#include "util/rounding.h"
/*
@@ -52,14 +52,14 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glDrawPixels(%d, %d, %s, %s, %p) // to %s at %d, %d\n",
+ _mesa_debug(ctx, "glDrawPixels(%d, %d, %s, %s, %p) // to %s at %ld, %ld\n",
width, height,
_mesa_enum_to_string(format),
_mesa_enum_to_string(type),
pixels,
_mesa_enum_to_string(ctx->DrawBuffer->ColorDrawBuffer[0]),
- IROUND(ctx->Current.RasterPos[0]),
- IROUND(ctx->Current.RasterPos[1]));
+ lroundf(ctx->Current.RasterPos[0]),
+ lroundf(ctx->Current.RasterPos[1]));
if (width < 0 || height < 0) {
@@ -141,8 +141,8 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
if (ctx->RenderMode == GL_RENDER) {
if (width > 0 && height > 0) {
/* Round, to satisfy conformance tests (matches SGI's OpenGL) */
- GLint x = IROUND(ctx->Current.RasterPos[0]);
- GLint y = IROUND(ctx->Current.RasterPos[1]);
+ GLint x = lroundf(ctx->Current.RasterPos[0]);
+ GLint y = lroundf(ctx->Current.RasterPos[1]);
if (ctx->Unpack.BufferObj) {
/* unpack from PBO */
@@ -197,13 +197,13 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx,
- "glCopyPixels(%d, %d, %d, %d, %s) // from %s to %s at %d, %d\n",
+ "glCopyPixels(%d, %d, %d, %d, %s) // from %s to %s at %ld, %ld\n",
srcx, srcy, width, height,
_mesa_enum_to_string(type),
_mesa_enum_to_string(ctx->ReadBuffer->ColorReadBuffer),
_mesa_enum_to_string(ctx->DrawBuffer->ColorDrawBuffer[0]),
- IROUND(ctx->Current.RasterPos[0]),
- IROUND(ctx->Current.RasterPos[1]));
+ lroundf(ctx->Current.RasterPos[0]),
+ lroundf(ctx->Current.RasterPos[1]));
if (width < 0 || height < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)");
@@ -265,8 +265,8 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
if (ctx->RenderMode == GL_RENDER) {
/* Round to satisfy conformance tests (matches SGI's OpenGL) */
if (width > 0 && height > 0) {
- GLint destx = IROUND(ctx->Current.RasterPos[0]);
- GLint desty = IROUND(ctx->Current.RasterPos[1]);
+ GLint destx = lroundf(ctx->Current.RasterPos[0]);
+ GLint desty = lroundf(ctx->Current.RasterPos[1]);
ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty,
type );
}
@@ -274,7 +274,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
else if (ctx->RenderMode == GL_FEEDBACK) {
FLUSH_CURRENT( ctx, 0 );
_mesa_feedback_token( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN );
- _mesa_feedback_vertex( ctx,
+ _mesa_feedback_vertex( ctx,
ctx->Current.RasterPos,
ctx->Current.RasterColor,
ctx->Current.RasterTexCoords[0] );
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index e970265e2c3..f6bdc29a89c 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -38,7 +38,6 @@
#include "glheader.h"
-#include "util/imports.h"
#include "context.h"
#include "eval.h"
#include "macros.h"
@@ -480,7 +479,7 @@ _mesa_Map2d( GLenum target,
GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
const GLdouble *points )
{
- map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder,
+ map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder,
(GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE);
}
@@ -704,7 +703,7 @@ _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v )
if (bufSize < numBytes)
goto overflow;
for (i=0;i<n;i++) {
- v[i] = IROUND(data[i]);
+ v[i] = lroundf(data[i]);
}
}
break;
@@ -728,17 +727,17 @@ _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v )
numBytes = 2 * sizeof *v;
if (bufSize < numBytes)
goto overflow;
- v[0] = IROUND(map1d->u1);
- v[1] = IROUND(map1d->u2);
+ v[0] = lroundf(map1d->u1);
+ v[1] = lroundf(map1d->u2);
}
else {
numBytes = 4 * sizeof *v;
if (bufSize < numBytes)
goto overflow;
- v[0] = IROUND(map2d->u1);
- v[1] = IROUND(map2d->u2);
- v[2] = IROUND(map2d->v1);
- v[3] = IROUND(map2d->v2);
+ v[0] = lroundf(map2d->u1);
+ v[1] = lroundf(map2d->u2);
+ v[2] = lroundf(map2d->v1);
+ v[3] = lroundf(map2d->v2);
}
break;
default:
@@ -815,7 +814,7 @@ void GLAPIENTRY
_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
GLint vn, GLdouble v1, GLdouble v2 )
{
- _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2,
+ _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2,
vn, (GLfloat) v1, (GLfloat) v2 );
}
@@ -856,7 +855,7 @@ init_1d_map( struct gl_1d_map *map, int n, const float *initial )
/**
- * Initialize a 2-D evaluator map
+ * Initialize a 2-D evaluator map
*/
static void
init_2d_map( struct gl_2d_map *map, int n, const float *initial )
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 48f43cb55f3..f03685f33ac 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1959,18 +1959,18 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
break;
case TYPE_FLOAT_8:
- params[7] = IROUND(((GLfloat *) p)[7]);
- params[6] = IROUND(((GLfloat *) p)[6]);
- params[5] = IROUND(((GLfloat *) p)[5]);
- params[4] = IROUND(((GLfloat *) p)[4]);
+ params[7] = lroundf(((GLfloat *) p)[7]);
+ params[6] = lroundf(((GLfloat *) p)[6]);
+ params[5] = lroundf(((GLfloat *) p)[5]);
+ params[4] = lroundf(((GLfloat *) p)[4]);
case TYPE_FLOAT_4:
- params[3] = IROUND(((GLfloat *) p)[3]);
+ params[3] = lroundf(((GLfloat *) p)[3]);
case TYPE_FLOAT_3:
- params[2] = IROUND(((GLfloat *) p)[2]);
+ params[2] = lroundf(((GLfloat *) p)[2]);
case TYPE_FLOAT_2:
- params[1] = IROUND(((GLfloat *) p)[1]);
+ params[1] = lroundf(((GLfloat *) p)[1]);
case TYPE_FLOAT:
- params[0] = IROUND(((GLfloat *) p)[0]);
+ params[0] = lroundf(((GLfloat *) p)[0]);
break;
case TYPE_FLOATN_4:
@@ -2074,18 +2074,18 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params)
break;
case TYPE_FLOAT_8:
- params[7] = IROUND64(((GLfloat *) p)[7]);
- params[6] = IROUND64(((GLfloat *) p)[6]);
- params[5] = IROUND64(((GLfloat *) p)[5]);
- params[4] = IROUND64(((GLfloat *) p)[4]);
+ params[7] = llround(((GLfloat *) p)[7]);
+ params[6] = llround(((GLfloat *) p)[6]);
+ params[5] = llround(((GLfloat *) p)[5]);
+ params[4] = llround(((GLfloat *) p)[4]);
case TYPE_FLOAT_4:
- params[3] = IROUND64(((GLfloat *) p)[3]);
+ params[3] = llround(((GLfloat *) p)[3]);
case TYPE_FLOAT_3:
- params[2] = IROUND64(((GLfloat *) p)[2]);
+ params[2] = llround(((GLfloat *) p)[2]);
case TYPE_FLOAT_2:
- params[1] = IROUND64(((GLfloat *) p)[1]);
+ params[1] = llround(((GLfloat *) p)[1]);
case TYPE_FLOAT:
- params[0] = IROUND64(((GLfloat *) p)[0]);
+ params[0] = llround(((GLfloat *) p)[0]);
break;
case TYPE_FLOATN_4:
@@ -2922,22 +2922,22 @@ _mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params )
switch (type) {
case TYPE_FLOAT_4:
case TYPE_FLOATN_4:
- params[3] = IROUND(v.value_float_4[3]);
+ params[3] = lroundf(v.value_float_4[3]);
case TYPE_FLOAT_3:
case TYPE_FLOATN_3:
- params[2] = IROUND(v.value_float_4[2]);
+ params[2] = lroundf(v.value_float_4[2]);
case TYPE_FLOAT_2:
case TYPE_FLOATN_2:
- params[1] = IROUND(v.value_float_4[1]);
+ params[1] = lroundf(v.value_float_4[1]);
case TYPE_FLOAT:
case TYPE_FLOATN:
- params[0] = IROUND(v.value_float_4[0]);
+ params[0] = lroundf(v.value_float_4[0]);
break;
case TYPE_DOUBLEN_2:
- params[1] = IROUND(v.value_double_2[1]);
+ params[1] = lroundf(v.value_double_2[1]);
case TYPE_DOUBLEN:
- params[0] = IROUND(v.value_double_2[0]);
+ params[0] = lroundf(v.value_double_2[0]);
break;
case TYPE_INT:
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index bae17c76f60..0883832dbd6 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -26,7 +26,6 @@
#include "c99_math.h"
#include "glheader.h"
-#include "util/imports.h"
#include "context.h"
#include "enums.h"
#include "light.h"
@@ -613,7 +612,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
{
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
- if (MESA_VERBOSE & VERBOSE_MATERIAL)
+ if (MESA_VERBOSE & VERBOSE_MATERIAL)
_mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask);
if (!bitmask)
@@ -625,7 +624,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *light = &ctx->Light.Light[i];
- SCALE_3V( light->_MatAmbient[0], light->Ambient,
+ SCALE_3V( light->_MatAmbient[0], light->Ambient,
mat[MAT_ATTRIB_FRONT_AMBIENT]);
}
}
@@ -635,7 +634,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *light = &ctx->Light.Light[i];
- SCALE_3V( light->_MatAmbient[1], light->Ambient,
+ SCALE_3V( light->_MatAmbient[1], light->Ambient,
mat[MAT_ATTRIB_BACK_AMBIENT]);
}
}
@@ -659,7 +658,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *light = &ctx->Light.Light[i];
- SCALE_3V( light->_MatDiffuse[0], light->Diffuse,
+ SCALE_3V( light->_MatDiffuse[0], light->Diffuse,
mat[MAT_ATTRIB_FRONT_DIFFUSE] );
}
}
@@ -669,7 +668,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *light = &ctx->Light.Light[i];
- SCALE_3V( light->_MatDiffuse[1], light->Diffuse,
+ SCALE_3V( light->_MatDiffuse[1], light->Diffuse,
mat[MAT_ATTRIB_BACK_DIFFUSE] );
}
}
@@ -680,7 +679,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
while (mask) {
const int i = u_bit_scan(&mask);
struct gl_light *light = &ctx->Light.Light[i];
- SCALE_3V( light->_MatSpecular[0], light->Specular,
+ SCALE_3V( light->_MatSpecular[0], light->Specular,
mat[MAT_ATTRIB_FRONT_SPECULAR]);
}
}
@@ -857,12 +856,12 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][3] );
break;
case GL_SHININESS:
- *params = IROUND( mat[MAT_ATTRIB_SHININESS(f)][0] );
+ *params = lroundf( mat[MAT_ATTRIB_SHININESS(f)][0] );
break;
case GL_COLOR_INDEXES:
- params[0] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][0] );
- params[1] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][1] );
- params[2] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][2] );
+ params[0] = lroundf( mat[MAT_ATTRIB_INDEXES(f)][0] );
+ params[1] = lroundf( mat[MAT_ATTRIB_INDEXES(f)][1] );
+ params[2] = lroundf( mat[MAT_ATTRIB_INDEXES(f)][2] );
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
@@ -1117,7 +1116,7 @@ _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag )
* Initialize the n-th light data structure.
*
* \param l pointer to the gl_light structure to be initialized.
- * \param n number of the light.
+ * \param n number of the light.
* \note The defaults for light 0 are different than the other lights.
*/
static void
@@ -1161,7 +1160,7 @@ init_lightmodel( struct gl_lightmodel *lm )
/**
* Initialize the material data structure.
- *
+ *
* \param m pointer to the gl_material structure to be initialized.
*/
static void
@@ -1173,7 +1172,7 @@ init_material( struct gl_material *m )
ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F );
ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F );
ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F );
-
+
ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F );
ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F );
ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F );
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 3623030071f..a5cb6d85ef5 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -28,6 +28,7 @@
* Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer)
*/
+#include "c99_math.h"
#include "glheader.h"
#include "bufferobj.h"
#include "context.h"
@@ -113,7 +114,7 @@ store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize,
/* special case */
ctx->PixelMaps.StoS.Size = mapsize;
for (i = 0; i < mapsize; i++) {
- ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]);
+ ctx->PixelMaps.StoS.Map[i] = roundf(values[i]);
}
break;
case GL_PIXEL_MAP_I_TO_I:
diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c
index a7c3492b604..f190c0b2bc1 100644
--- a/src/mesa/main/pixelstore.c
+++ b/src/mesa/main/pixelstore.c
@@ -33,6 +33,7 @@
#include "context.h"
#include "pixelstore.h"
#include "mtypes.h"
+#include "util/rounding.h"
static ALWAYS_INLINE void
@@ -234,7 +235,7 @@ _mesa_PixelStorei(GLenum pname, GLint param)
void GLAPIENTRY
_mesa_PixelStoref(GLenum pname, GLfloat param)
{
- _mesa_PixelStorei(pname, IROUND(param));
+ _mesa_PixelStorei(pname, lroundf(param));
}
@@ -248,7 +249,7 @@ _mesa_PixelStorei_no_error(GLenum pname, GLint param)
void GLAPIENTRY
_mesa_PixelStoref_no_error(GLenum pname, GLfloat param)
{
- _mesa_PixelStorei_no_error(pname, IROUND(param));
+ _mesa_PixelStorei_no_error(pname, lroundf(param));
}
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 6656cf5022a..449695dbac7 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -242,7 +242,7 @@ delete_samplers(struct gl_context *ctx, GLsizei count, const GLuint *samplers)
GLuint j;
struct gl_sampler_object *sampObj =
lookup_samplerobj_locked(ctx, samplers[i]);
-
+
if (sampObj) {
/* If the sampler is currently bound, unbind it. */
for (j = 0; j < ctx->Const.MaxCombinedTextureImageUnits; j++) {
@@ -326,7 +326,7 @@ bind_sampler(struct gl_context *ctx, GLuint unit, GLuint sampler, bool no_error)
return;
}
}
-
+
/* bind new sampler */
_mesa_bind_sampler(ctx, unit, sampObj);
}
@@ -472,7 +472,7 @@ _mesa_BindSamplers(GLuint first, GLsizei count, const GLuint *samplers)
* Check if a coordinate wrap mode is legal.
* \return GL_TRUE if legal, GL_FALSE otherwise
*/
-static GLboolean
+static GLboolean
validate_texture_wrap_mode(struct gl_context *ctx, GLenum wrap)
{
const struct gl_extensions * const e = &ctx->Extensions;
@@ -1421,19 +1421,19 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(sampObj->MinLod);
+ *params = lroundf(sampObj->MinLod);
break;
case GL_TEXTURE_MAX_LOD:
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(sampObj->MaxLod);
+ *params = lroundf(sampObj->MaxLod);
break;
case GL_TEXTURE_LOD_BIAS:
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(sampObj->LodBias);
+ *params = lroundf(sampObj->LodBias);
break;
case GL_TEXTURE_COMPARE_MODE:
*params = sampObj->CompareMode;
@@ -1445,7 +1445,7 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(sampObj->MaxAnisotropy);
+ *params = lroundf(sampObj->MaxAnisotropy);
break;
case GL_TEXTURE_BORDER_COLOR:
params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]);
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index ced2da8496c..7e062403bb9 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1649,7 +1649,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
}
if (*params == 0 && pname == GL_TEXTURE_INTENSITY_SIZE) {
/* Gallium may store intensity as LA */
- *params = _mesa_get_format_bits(texFormat,
+ *params = _mesa_get_format_bits(texFormat,
GL_TEXTURE_ALPHA_SIZE);
}
}
@@ -2424,7 +2424,7 @@ get_tex_parameteriv(struct gl_context *ctx,
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(obj->Sampler.MinLod);
+ *params = lroundf(obj->Sampler.MinLod);
break;
case GL_TEXTURE_MAX_LOD:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
@@ -2432,7 +2432,7 @@ get_tex_parameteriv(struct gl_context *ctx,
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(obj->Sampler.MaxLod);
+ *params = lroundf(obj->Sampler.MaxLod);
break;
case GL_TEXTURE_BASE_LEVEL:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
@@ -2449,7 +2449,7 @@ get_tex_parameteriv(struct gl_context *ctx,
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(obj->Sampler.MaxAnisotropy);
+ *params = lroundf(obj->Sampler.MaxAnisotropy);
break;
case GL_GENERATE_MIPMAP_SGIS:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
@@ -2487,7 +2487,7 @@ get_tex_parameteriv(struct gl_context *ctx,
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
*/
- *params = IROUND(obj->Sampler.LodBias);
+ *params = lroundf(obj->Sampler.LodBias);
break;
case GL_TEXTURE_CROP_RECT_OES:
if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index 362d4daad17..6b7e5e45333 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -298,7 +298,7 @@ blit_nearest(struct gl_context *ctx,
for (dstRow = 0; dstRow < dstHeight; dstRow++) {
GLfloat srcRowF = (dstRow + 0.5F) / dstHeight * srcHeight - 0.5F;
- GLint srcRow = IROUND(srcRowF);
+ GLint srcRow = lroundf(srcRowF);
GLubyte *dstRowStart = dstMap + dstRowStride * dstRow;
assert(srcRow >= 0);
@@ -440,7 +440,7 @@ resample_linear_row_ub(GLint srcWidth, GLint dstWidth,
alpha = lerp_2d(colWeight, rowWeight,
srcColor0[srcCol0][ACOMP], srcColor0[srcCol1][ACOMP],
srcColor1[srcCol0][ACOMP], srcColor1[srcCol1][ACOMP]);
-
+
dstColor[dstCol][RCOMP] = util_ifloor(red);
dstColor[dstCol][GCOMP] = util_ifloor(green);
dstColor[dstCol][BCOMP] = util_ifloor(blue);
@@ -495,7 +495,7 @@ resample_linear_row_float(GLint srcWidth, GLint dstWidth,
alpha = lerp_2d(colWeight, rowWeight,
srcColor0[srcCol0][ACOMP], srcColor0[srcCol1][ACOMP],
srcColor1[srcCol0][ACOMP], srcColor1[srcCol1][ACOMP]);
-
+
dstColor[dstCol][RCOMP] = red;
dstColor[dstCol][GCOMP] = green;
dstColor[dstCol][BCOMP] = blue;
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index dd700183c88..9ccba6b2276 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -49,6 +49,7 @@
#include "swrast.h"
#include "s_fragprog.h"
#include "s_span.h"
+#include "util/rounding.h"
typedef void (*texture_sample_func)(struct gl_context *ctx,
@@ -433,7 +434,7 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx);
#define FIXED_EPSILON 1
#define FIXED_SCALE ((float) FIXED_ONE)
#define FIXED_DBL_SCALE ((double) FIXED_ONE)
-#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
+#define FloatToFixed(X) (lroundf((X) * FIXED_SCALE))
#define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
#define IntToFixed(I) ((I) << FIXED_SHIFT)
#define FixedToInt(X) ((X) >> FIXED_SHIFT)
diff --git a/src/util/imports.h b/src/util/imports.h
index 3a73275ffd6..149bb225ad4 100644
--- a/src/util/imports.h
+++ b/src/util/imports.h
@@ -95,23 +95,6 @@ typedef union { float f; int i; unsigned u; } fi_type;
#endif
-/**
- * Convert float to int by rounding to nearest integer, away from zero.
- */
-static inline int IROUND(float f)
-{
- return (int) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F));
-}
-
-/**
- * Convert float to int64 by rounding to nearest integer.
- */
-static inline int64_t IROUND64(float f)
-{
- return (int64_t) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F));
-}
-
-
/**********************************************************************
* Functions
*/
diff --git a/src/util/rounding.h b/src/util/rounding.h
index d3fe8edb7f8..e329d438244 100644
--- a/src/util/rounding.h
+++ b/src/util/rounding.h
@@ -108,6 +108,7 @@ _mesa_lroundevenf(float x)
#endif
}
+
/**
* \brief Rounds \c x to the nearest integer, with ties to the even integer,
* and returns the value as a long int.