[Mesa-dev] [PATCH] mesa: fix UNCLAMPED_FLOAT_TO_UBYTE() macro for MSVC
Ian Romanick
idr at freedesktop.org
Wed Sep 10 11:02:50 PDT 2014
On 09/10/2014 07:21 AM, Brian Paul wrote:
> MSVC replaces the "F" in "255.0F" with the macro argument which leads
> to an error. s/F/FLT/ to avoid that.
>
> It turns out we weren't using this macro at all on MSVC until the
> recent "mesa: Drop USE_IEEE define." change.
> ---
> src/mesa/main/macros.h | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
> index 7b6148d..b3e214f 100644
> --- a/src/mesa/main/macros.h
> +++ b/src/mesa/main/macros.h
> @@ -144,23 +144,24 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
> /* This function/macro is sensitive to precision. Test very carefully
> * if you change it!
> */
> -#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
> +#define UNCLAMPED_FLOAT_TO_UBYTE(UB, FLT) \
> do { \
> fi_type __tmp; \
> - __tmp.f = (F); \
> + __tmp.f = (FLT); \
> if (__tmp.i < 0) \
> UB = (GLubyte) 0; \
> else if (__tmp.i >= IEEE_ONE) \
> UB = (GLubyte) 255; \
> else { \
> __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \
> + __tmp.f = __tmp.f * (float) ((255.0/256.0) + 32768.0); \
Something looks fishy here. Do you need the addition? Or should the
previous line be removed?
> UB = (GLubyte) __tmp.i; \
> } \
> } while (0)
> -#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \
> +#define CLAMPED_FLOAT_TO_UBYTE(UB, FLT) \
> do { \
> fi_type __tmp; \
> - __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \
> + __tmp.f = (FLT) * (255.0F/256.0F) + 32768.0F; \
> UB = (GLubyte) __tmp.i; \
> } while (0)
> #else
>
More information about the mesa-dev
mailing list