[Mesa-dev] [PATCH 16/28] Replace IROUND_POS with _mesa_roundevenf
Erik Faye-Lund
erik.faye-lund at collabora.com
Mon Nov 12 12:51:47 UTC 2018
On Fri, 2018-11-09 at 10:40 -0800, Dylan Baker wrote:
> Which has the same behavior.
Does it? I'm not so sure... IROUND_POS seems to round to nearest
integer depending on the FPU rounding mode, _mesa_roundevenf rounds to
the nearest *even* value regardless of the FPU rounding mode, no?
I'm not sure if it matters or not, but *at least* point that out in the
commit message. Unless I'm missing something, of course...
> ---
> src/mesa/drivers/x11/xm_api.c | 2 +-
> src/mesa/main/imports.h | 10 ----------
> src/mesa/swrast/s_aaline.c | 3 +--
> src/mesa/swrast/s_aatriangle.c | 3 +--
> 4 files changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/src/mesa/drivers/x11/xm_api.c
> b/src/mesa/drivers/x11/xm_api.c
> index e8405950656..6ff1269d07d 100644
> --- a/src/mesa/drivers/x11/xm_api.c
> +++ b/src/mesa/drivers/x11/xm_api.c
> @@ -151,7 +151,7 @@ gamma_adjust( GLfloat gamma, GLint value, GLint
> max )
> }
> else {
> double x = (double) value / (double) max;
> - return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma));
> + return _mesa_roundevenf((GLfloat) max * pow(x, 1.0F/gamma));
> }
> }
>
> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> index 59133643442..fbb7e59ca06 100644
> --- a/src/mesa/main/imports.h
> +++ b/src/mesa/main/imports.h
> @@ -136,16 +136,6 @@ static inline GLint64 IROUND64(float f)
> }
>
>
> -/**
> - * Convert positive float to int by rounding to nearest integer.
> - */
> -static inline int IROUND_POS(float f)
> -{
> - assert(f >= 0.0F);
> - return (int) (f + 0.5F);
> -}
> -
> -
> /*******************************************************************
> ***
> * Functions
> */
> diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
> index de5b42b9f6b..e86d0b5015c 100644
> --- a/src/mesa/swrast/s_aaline.c
> +++ b/src/mesa/swrast/s_aaline.c
> @@ -25,7 +25,6 @@
>
> #include "c99_math.h"
> #include "main/glheader.h"
> -#include "main/imports.h"
> #include "main/macros.h"
> #include "main/mtypes.h"
> #include "main/teximage.h"
> @@ -181,7 +180,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const
> GLfloat plane[4])
> return 0;
> else if (z > CHAN_MAX)
> return CHAN_MAX;
> - return (GLchan) IROUND_POS(z);
> + return (GLchan) _mesa_roundevenf(z);
> #endif
> }
>
> diff --git a/src/mesa/swrast/s_aatriangle.c
> b/src/mesa/swrast/s_aatriangle.c
> index b5109870437..20d0a9d3043 100644
> --- a/src/mesa/swrast/s_aatriangle.c
> +++ b/src/mesa/swrast/s_aatriangle.c
> @@ -31,7 +31,6 @@
> #include "main/glheader.h"
> #include "main/context.h"
> #include "main/macros.h"
> -#include "main/imports.h"
> #include "main/state.h"
> #include "s_aatriangle.h"
> #include "s_context.h"
> @@ -124,7 +123,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const
> GLfloat plane[4])
> return 0;
> else if (z > CHAN_MAX)
> return CHAN_MAX;
> - return (GLchan) IROUND_POS(z);
> + return (GLchan) _mesa_roundevenf(z);
> #endif
> }
>
More information about the mesa-dev
mailing list