[Mesa-dev] [PATCH 2/2] mesa: use F_TO_I() instead of IROUND()

Jose Fonseca jfonseca at vmware.com
Sat May 19 02:55:53 PDT 2012


The IROUND implementation fix looks good.

Concerning this F_TO_I thought, I wonder if rounding to nearest was the true intention below, and we just happened to be lucky so far.  Anyway, easy to revert to IROUND as needed, and not terribly important.

Jose

----- Original Message -----
> Use it where performance matters more and the exact method of
> float->int
> conversion/rounding isn't terribly important.  There should no net
> change
> here since F_TO_I() is the new name of the old IROUND() function.
> ---
>  src/mesa/main/macros.h          |   10 +-
>  src/mesa/main/pack.c            |  220
>  +++++++++++++++++++-------------------
>  src/mesa/main/pixeltransfer.c   |   10 +-
>  src/mesa/program/prog_execute.c |   20 ++--
>  4 files changed, 130 insertions(+), 130 deletions(-)
> 
> diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
> index dbe5b86..d1df2ce 100644
> --- a/src/mesa/main/macros.h
> +++ b/src/mesa/main/macros.h
> @@ -129,12 +129,12 @@ extern GLfloat
> _mesa_ubyte_to_float_color_tab[256];
>  #define INT_TO_USHORT(i)   ((i) < 0 ? 0 : ((GLushort) ((i) >> 15)))
>  #define UINT_TO_USHORT(i)  ((i) < 0 ? 0 : ((GLushort) ((i) >> 16)))
>  #define UNCLAMPED_FLOAT_TO_USHORT(us, f)  \
> -        us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F)
> )
> +        us = ( (GLushort) F_TO_I( CLAMP((f), 0.0F, 1.0F) * 65535.0F)
> )
>  #define CLAMPED_FLOAT_TO_USHORT(us, f)  \
> -        us = ( (GLushort) IROUND( (f) * 65535.0F) )
> +        us = ( (GLushort) F_TO_I( (f) * 65535.0F) )
>  
>  #define UNCLAMPED_FLOAT_TO_SHORT(s, f)  \
> -        s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F)
> )
> +        s = ( (GLshort) F_TO_I( CLAMP((f), -1.0F, 1.0F) * 32767.0F)
> )
>  
>  /***
>   *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte
>   in [0,255]
> @@ -166,9 +166,9 @@ extern GLfloat
> _mesa_ubyte_to_float_color_tab[256];
>          } while (0)
>  #else
>  #define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
> -	ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
> +	ub = ((GLubyte) F_TO_I(CLAMP((f), 0.0F, 1.0F) * 255.0F))
>  #define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
> -	ub = ((GLubyte) IROUND((f) * 255.0F))
> +	ub = ((GLubyte) F_TO_I((f) * 255.0F))
>  #endif
>  
>  /*@}*/
> diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
> index 4d4b4a8..c25a02e 100644
> --- a/src/mesa/main/pack.c
> +++ b/src/mesa/main/pack.c
> @@ -1726,9 +1726,9 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGB) {
>              GLubyte *dst = (GLubyte *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 7.0F) << 5)
> -                      | (IROUND(rgba[i][GCOMP] * 7.0F) << 2)
> -                      | (IROUND(rgba[i][BCOMP] * 3.0F)     );
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 7.0F) << 5)
> +                      | (F_TO_I(rgba[i][GCOMP] * 7.0F) << 2)
> +                      | (F_TO_I(rgba[i][BCOMP] * 3.0F)     );
>              }
>           }
>           break;
> @@ -1736,9 +1736,9 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGB) {
>              GLubyte *dst = (GLubyte *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 7.0F)     )
> -                      | (IROUND(rgba[i][GCOMP] * 7.0F) << 3)
> -                      | (IROUND(rgba[i][BCOMP] * 3.0F) << 6);
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 7.0F)     )
> +                      | (F_TO_I(rgba[i][GCOMP] * 7.0F) << 3)
> +                      | (F_TO_I(rgba[i][BCOMP] * 3.0F) << 6);
>              }
>           }
>           break;
> @@ -1746,9 +1746,9 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGB) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F) << 11)
> -                      | (IROUND(rgba[i][GCOMP] * 63.0F) <<  5)
> -                      | (IROUND(rgba[i][BCOMP] * 31.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 31.0F) << 11)
> +                      | (F_TO_I(rgba[i][GCOMP] * 63.0F) <<  5)
> +                      | (F_TO_I(rgba[i][BCOMP] * 31.0F)      );
>              }
>           }
>           break;
> @@ -1756,9 +1756,9 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGB) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 63.0F) <<  5)
> -                      | (IROUND(rgba[i][BCOMP] * 31.0F) << 11);
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 31.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 63.0F) <<  5)
> +                      | (F_TO_I(rgba[i][BCOMP] * 31.0F) << 11);
>              }
>           }
>           break;
> @@ -1766,28 +1766,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 15.0F) << 12)
> -                      | (IROUND(rgba[i][GCOMP] * 15.0F) <<  8)
> -                      | (IROUND(rgba[i][BCOMP] * 15.0F) <<  4)
> -                      | (IROUND(rgba[i][ACOMP] * 15.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 15.0F) << 12)
> +                      | (F_TO_I(rgba[i][GCOMP] * 15.0F) <<  8)
> +                      | (F_TO_I(rgba[i][BCOMP] * 15.0F) <<  4)
> +                      | (F_TO_I(rgba[i][ACOMP] * 15.0F)      );
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 15.0F) << 12)
> -                      | (IROUND(rgba[i][GCOMP] * 15.0F) <<  8)
> -                      | (IROUND(rgba[i][RCOMP] * 15.0F) <<  4)
> -                      | (IROUND(rgba[i][ACOMP] * 15.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 15.0F) << 12)
> +                      | (F_TO_I(rgba[i][GCOMP] * 15.0F) <<  8)
> +                      | (F_TO_I(rgba[i][RCOMP] * 15.0F) <<  4)
> +                      | (F_TO_I(rgba[i][ACOMP] * 15.0F)      );
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 15.0F) << 12)
> -                      | (IROUND(rgba[i][BCOMP] * 15.0F) <<  8)
> -                      | (IROUND(rgba[i][GCOMP] * 15.0F) <<  4)
> -                      | (IROUND(rgba[i][RCOMP] * 15.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 15.0F) << 12)
> +                      | (F_TO_I(rgba[i][BCOMP] * 15.0F) <<  8)
> +                      | (F_TO_I(rgba[i][GCOMP] * 15.0F) <<  4)
> +                      | (F_TO_I(rgba[i][RCOMP] * 15.0F)      );
>              }
>           }
>           break;
> @@ -1795,28 +1795,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 15.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 15.0F) <<  4)
> -                      | (IROUND(rgba[i][BCOMP] * 15.0F) <<  8)
> -                      | (IROUND(rgba[i][ACOMP] * 15.0F) << 12);
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 15.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 15.0F) <<  4)
> +                      | (F_TO_I(rgba[i][BCOMP] * 15.0F) <<  8)
> +                      | (F_TO_I(rgba[i][ACOMP] * 15.0F) << 12);
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 15.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 15.0F) <<  4)
> -                      | (IROUND(rgba[i][RCOMP] * 15.0F) <<  8)
> -                      | (IROUND(rgba[i][ACOMP] * 15.0F) << 12);
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 15.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 15.0F) <<  4)
> +                      | (F_TO_I(rgba[i][RCOMP] * 15.0F) <<  8)
> +                      | (F_TO_I(rgba[i][ACOMP] * 15.0F) << 12);
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 15.0F)      )
> -                      | (IROUND(rgba[i][BCOMP] * 15.0F) <<  4)
> -                      | (IROUND(rgba[i][GCOMP] * 15.0F) <<  8)
> -                      | (IROUND(rgba[i][RCOMP] * 15.0F) << 12);
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 15.0F)      )
> +                      | (F_TO_I(rgba[i][BCOMP] * 15.0F) <<  4)
> +                      | (F_TO_I(rgba[i][GCOMP] * 15.0F) <<  8)
> +                      | (F_TO_I(rgba[i][RCOMP] * 15.0F) << 12);
>              }
>           }
>           break;
> @@ -1824,28 +1824,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F) << 11)
> -                      | (IROUND(rgba[i][GCOMP] * 31.0F) <<  6)
> -                      | (IROUND(rgba[i][BCOMP] * 31.0F) <<  1)
> -                      | (IROUND(rgba[i][ACOMP] *  1.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 31.0F) << 11)
> +                      | (F_TO_I(rgba[i][GCOMP] * 31.0F) <<  6)
> +                      | (F_TO_I(rgba[i][BCOMP] * 31.0F) <<  1)
> +                      | (F_TO_I(rgba[i][ACOMP] *  1.0F)      );
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 31.0F) << 11)
> -                      | (IROUND(rgba[i][GCOMP] * 31.0F) <<  6)
> -                      | (IROUND(rgba[i][RCOMP] * 31.0F) <<  1)
> -                      | (IROUND(rgba[i][ACOMP] *  1.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 31.0F) << 11)
> +                      | (F_TO_I(rgba[i][GCOMP] * 31.0F) <<  6)
> +                      | (F_TO_I(rgba[i][RCOMP] * 31.0F) <<  1)
> +                      | (F_TO_I(rgba[i][ACOMP] *  1.0F)      );
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 31.0F) << 11)
> -                      | (IROUND(rgba[i][BCOMP] * 31.0F) <<  6)
> -                      | (IROUND(rgba[i][GCOMP] * 31.0F) <<  1)
> -                      | (IROUND(rgba[i][RCOMP] *  1.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 31.0F) << 11)
> +                      | (F_TO_I(rgba[i][BCOMP] * 31.0F) <<  6)
> +                      | (F_TO_I(rgba[i][GCOMP] * 31.0F) <<  1)
> +                      | (F_TO_I(rgba[i][RCOMP] *  1.0F)      );
>              }
>           }
>           break;
> @@ -1853,28 +1853,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 31.0F) <<  5)
> -                      | (IROUND(rgba[i][BCOMP] * 31.0F) << 10)
> -                      | (IROUND(rgba[i][ACOMP] *  1.0F) << 15);
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 31.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 31.0F) <<  5)
> +                      | (F_TO_I(rgba[i][BCOMP] * 31.0F) << 10)
> +                      | (F_TO_I(rgba[i][ACOMP] *  1.0F) << 15);
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 31.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 31.0F) <<  5)
> -                      | (IROUND(rgba[i][RCOMP] * 31.0F) << 10)
> -                      | (IROUND(rgba[i][ACOMP] *  1.0F) << 15);
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 31.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 31.0F) <<  5)
> +                      | (F_TO_I(rgba[i][RCOMP] * 31.0F) << 10)
> +                      | (F_TO_I(rgba[i][ACOMP] *  1.0F) << 15);
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLushort *dst = (GLushort *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 31.0F)      )
> -                      | (IROUND(rgba[i][BCOMP] * 31.0F) <<  5)
> -                      | (IROUND(rgba[i][GCOMP] * 31.0F) << 10)
> -                      | (IROUND(rgba[i][RCOMP] *  1.0F) << 15);
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 31.0F)      )
> +                      | (F_TO_I(rgba[i][BCOMP] * 31.0F) <<  5)
> +                      | (F_TO_I(rgba[i][GCOMP] * 31.0F) << 10)
> +                      | (F_TO_I(rgba[i][RCOMP] *  1.0F) << 15);
>              }
>           }
>           break;
> @@ -1882,28 +1882,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 255.F) << 24)
> -                      | (IROUND(rgba[i][GCOMP] * 255.F) << 16)
> -                      | (IROUND(rgba[i][BCOMP] * 255.F) <<  8)
> -                      | (IROUND(rgba[i][ACOMP] * 255.F)      );
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 255.F) << 24)
> +                      | (F_TO_I(rgba[i][GCOMP] * 255.F) << 16)
> +                      | (F_TO_I(rgba[i][BCOMP] * 255.F) <<  8)
> +                      | (F_TO_I(rgba[i][ACOMP] * 255.F)      );
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 255.F) << 24)
> -                      | (IROUND(rgba[i][GCOMP] * 255.F) << 16)
> -                      | (IROUND(rgba[i][RCOMP] * 255.F) <<  8)
> -                      | (IROUND(rgba[i][ACOMP] * 255.F)      );
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 255.F) << 24)
> +                      | (F_TO_I(rgba[i][GCOMP] * 255.F) << 16)
> +                      | (F_TO_I(rgba[i][RCOMP] * 255.F) <<  8)
> +                      | (F_TO_I(rgba[i][ACOMP] * 255.F)      );
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 255.F) << 24)
> -                      | (IROUND(rgba[i][BCOMP] * 255.F) << 16)
> -                      | (IROUND(rgba[i][GCOMP] * 255.F) <<  8)
> -                      | (IROUND(rgba[i][RCOMP] * 255.F)      );
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 255.F) << 24)
> +                      | (F_TO_I(rgba[i][BCOMP] * 255.F) << 16)
> +                      | (F_TO_I(rgba[i][GCOMP] * 255.F) <<  8)
> +                      | (F_TO_I(rgba[i][RCOMP] * 255.F)      );
>              }
>           }
>           break;
> @@ -1911,28 +1911,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 255.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 255.0F) <<  8)
> -                      | (IROUND(rgba[i][BCOMP] * 255.0F) << 16)
> -                      | (IROUND(rgba[i][ACOMP] * 255.0F) << 24);
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 255.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 255.0F) <<  8)
> +                      | (F_TO_I(rgba[i][BCOMP] * 255.0F) << 16)
> +                      | (F_TO_I(rgba[i][ACOMP] * 255.0F) << 24);
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 255.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 255.0F) <<  8)
> -                      | (IROUND(rgba[i][RCOMP] * 255.0F) << 16)
> -                      | (IROUND(rgba[i][ACOMP] * 255.0F) << 24);
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 255.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 255.0F) <<  8)
> +                      | (F_TO_I(rgba[i][RCOMP] * 255.0F) << 16)
> +                      | (F_TO_I(rgba[i][ACOMP] * 255.0F) << 24);
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 255.0F)      )
> -                      | (IROUND(rgba[i][BCOMP] * 255.0F) <<  8)
> -                      | (IROUND(rgba[i][GCOMP] * 255.0F) << 16)
> -                      | (IROUND(rgba[i][RCOMP] * 255.0F) << 24);
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 255.0F)      )
> +                      | (F_TO_I(rgba[i][BCOMP] * 255.0F) <<  8)
> +                      | (F_TO_I(rgba[i][GCOMP] * 255.0F) << 16)
> +                      | (F_TO_I(rgba[i][RCOMP] * 255.0F) << 24);
>              }
>           }
>           break;
> @@ -1940,28 +1940,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 1023.0F) << 22)
> -                      | (IROUND(rgba[i][GCOMP] * 1023.0F) << 12)
> -                      | (IROUND(rgba[i][BCOMP] * 1023.0F) <<  2)
> -                      | (IROUND(rgba[i][ACOMP] *    3.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 1023.0F) << 22)
> +                      | (F_TO_I(rgba[i][GCOMP] * 1023.0F) << 12)
> +                      | (F_TO_I(rgba[i][BCOMP] * 1023.0F) <<  2)
> +                      | (F_TO_I(rgba[i][ACOMP] *    3.0F)      );
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 1023.0F) << 22)
> -                      | (IROUND(rgba[i][GCOMP] * 1023.0F) << 12)
> -                      | (IROUND(rgba[i][RCOMP] * 1023.0F) <<  2)
> -                      | (IROUND(rgba[i][ACOMP] *    3.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 1023.0F) << 22)
> +                      | (F_TO_I(rgba[i][GCOMP] * 1023.0F) << 12)
> +                      | (F_TO_I(rgba[i][RCOMP] * 1023.0F) <<  2)
> +                      | (F_TO_I(rgba[i][ACOMP] *    3.0F)      );
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 1023.0F) << 22)
> -                      | (IROUND(rgba[i][BCOMP] * 1023.0F) << 12)
> -                      | (IROUND(rgba[i][GCOMP] * 1023.0F) <<  2)
> -                      | (IROUND(rgba[i][RCOMP] *    3.0F)      );
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 1023.0F) << 22)
> +                      | (F_TO_I(rgba[i][BCOMP] * 1023.0F) << 12)
> +                      | (F_TO_I(rgba[i][GCOMP] * 1023.0F) <<  2)
> +                      | (F_TO_I(rgba[i][RCOMP] *    3.0F)      );
>              }
>           }
>           break;
> @@ -1969,28 +1969,28 @@ _mesa_pack_rgba_span_float(struct gl_context
> *ctx, GLuint n, GLfloat rgba[][4],
>           if (dstFormat == GL_RGBA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][RCOMP] * 1023.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 1023.0F) << 10)
> -                      | (IROUND(rgba[i][BCOMP] * 1023.0F) << 20)
> -                      | (IROUND(rgba[i][ACOMP] *    3.0F) << 30);
> +               dst[i] = (F_TO_I(rgba[i][RCOMP] * 1023.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 1023.0F) << 10)
> +                      | (F_TO_I(rgba[i][BCOMP] * 1023.0F) << 20)
> +                      | (F_TO_I(rgba[i][ACOMP] *    3.0F) << 30);
>              }
>           }
>           else if (dstFormat == GL_BGRA) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][BCOMP] * 1023.0F)      )
> -                      | (IROUND(rgba[i][GCOMP] * 1023.0F) << 10)
> -                      | (IROUND(rgba[i][RCOMP] * 1023.0F) << 20)
> -                      | (IROUND(rgba[i][ACOMP] *    3.0F) << 30);
> +               dst[i] = (F_TO_I(rgba[i][BCOMP] * 1023.0F)      )
> +                      | (F_TO_I(rgba[i][GCOMP] * 1023.0F) << 10)
> +                      | (F_TO_I(rgba[i][RCOMP] * 1023.0F) << 20)
> +                      | (F_TO_I(rgba[i][ACOMP] *    3.0F) << 30);
>              }
>           }
>           else if (dstFormat == GL_ABGR_EXT) {
>              GLuint *dst = (GLuint *) dstAddr;
>              for (i=0;i<n;i++) {
> -               dst[i] = (IROUND(rgba[i][ACOMP] * 1023.0F)      )
> -                      | (IROUND(rgba[i][BCOMP] * 1023.0F) << 10)
> -                      | (IROUND(rgba[i][GCOMP] * 1023.0F) << 20)
> -                      | (IROUND(rgba[i][RCOMP] *    3.0F) << 30);
> +               dst[i] = (F_TO_I(rgba[i][ACOMP] * 1023.0F)      )
> +                      | (F_TO_I(rgba[i][BCOMP] * 1023.0F) << 10)
> +                      | (F_TO_I(rgba[i][GCOMP] * 1023.0F) << 20)
> +                      | (F_TO_I(rgba[i][RCOMP] *    3.0F) << 30);
>              }
>           }
>           break;
> @@ -3005,7 +3005,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
>  static inline GLuint
>  clamp_float_to_uint(GLfloat f)
>  {
> -   return f < 0.0F ? 0 : IROUND(f);
> +   return f < 0.0F ? 0 : F_TO_I(f);
>  }
>  
>  
> @@ -3013,7 +3013,7 @@ static inline GLuint
>  clamp_half_to_uint(GLhalfARB h)
>  {
>     GLfloat f = _mesa_half_to_float(h);
> -   return f < 0.0F ? 0 : IROUND(f);
> +   return f < 0.0F ? 0 : F_TO_I(f);
>  }
>  
>  
> diff --git a/src/mesa/main/pixeltransfer.c
> b/src/mesa/main/pixeltransfer.c
> index c6172b9..fa355eb 100644
> --- a/src/mesa/main/pixeltransfer.c
> +++ b/src/mesa/main/pixeltransfer.c
> @@ -93,10 +93,10 @@ _mesa_map_rgba( const struct gl_context *ctx,
> GLuint n, GLfloat rgba[][4] )
>        GLfloat g = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F);
>        GLfloat b = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F);
>        GLfloat a = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F);
> -      rgba[i][RCOMP] = rMap[IROUND(r * rscale)];
> -      rgba[i][GCOMP] = gMap[IROUND(g * gscale)];
> -      rgba[i][BCOMP] = bMap[IROUND(b * bscale)];
> -      rgba[i][ACOMP] = aMap[IROUND(a * ascale)];
> +      rgba[i][RCOMP] = rMap[F_TO_I(r * rscale)];
> +      rgba[i][GCOMP] = gMap[F_TO_I(g * gscale)];
> +      rgba[i][BCOMP] = bMap[F_TO_I(b * bscale)];
> +      rgba[i][ACOMP] = aMap[F_TO_I(a * ascale)];
>     }
>  }
>  
> @@ -235,7 +235,7 @@ _mesa_apply_ci_transfer_ops(const struct
> gl_context *ctx,
>        GLuint i;
>        for (i = 0; i < n; i++) {
>           const GLuint j = indexes[i] & mask;
> -         indexes[i] = IROUND(ctx->PixelMaps.ItoI.Map[j]);
> +         indexes[i] = F_TO_I(ctx->PixelMaps.ItoI.Map[j]);
>        }
>     }
>  }
> diff --git a/src/mesa/program/prog_execute.c
> b/src/mesa/program/prog_execute.c
> index 848c2fe..dd1706e 100644
> --- a/src/mesa/program/prog_execute.c
> +++ b/src/mesa/program/prog_execute.c
> @@ -1308,8 +1308,8 @@ _mesa_execute_program(struct gl_context * ctx,
>              fetch_vector4(&inst->SrcReg[0], machine, a);
>              a[0] = CLAMP(a[0], 0.0F, 1.0F);
>              a[1] = CLAMP(a[1], 0.0F, 1.0F);
> -            usx = IROUND(a[0] * 65535.0F);
> -            usy = IROUND(a[1] * 65535.0F);
> +            usx = F_TO_I(a[0] * 65535.0F);
> +            usy = F_TO_I(a[1] * 65535.0F);
>              result[0] =
>              result[1] =
>              result[2] =
> @@ -1326,10 +1326,10 @@ _mesa_execute_program(struct gl_context *
> ctx,
>              a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F);
>              a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F);
>              a[3] = CLAMP(a[3], -128.0F / 127.0F, 1.0F);
> -            ubx = IROUND(127.0F * a[0] + 128.0F);
> -            uby = IROUND(127.0F * a[1] + 128.0F);
> -            ubz = IROUND(127.0F * a[2] + 128.0F);
> -            ubw = IROUND(127.0F * a[3] + 128.0F);
> +            ubx = F_TO_I(127.0F * a[0] + 128.0F);
> +            uby = F_TO_I(127.0F * a[1] + 128.0F);
> +            ubz = F_TO_I(127.0F * a[2] + 128.0F);
> +            ubw = F_TO_I(127.0F * a[3] + 128.0F);
>              result[0] =
>              result[1] =
>              result[2] =
> @@ -1346,10 +1346,10 @@ _mesa_execute_program(struct gl_context *
> ctx,
>              a[1] = CLAMP(a[1], 0.0F, 1.0F);
>              a[2] = CLAMP(a[2], 0.0F, 1.0F);
>              a[3] = CLAMP(a[3], 0.0F, 1.0F);
> -            ubx = IROUND(255.0F * a[0]);
> -            uby = IROUND(255.0F * a[1]);
> -            ubz = IROUND(255.0F * a[2]);
> -            ubw = IROUND(255.0F * a[3]);
> +            ubx = F_TO_I(255.0F * a[0]);
> +            uby = F_TO_I(255.0F * a[1]);
> +            ubz = F_TO_I(255.0F * a[2]);
> +            ubw = F_TO_I(255.0F * a[3]);
>              result[0] =
>              result[1] =
>              result[2] =
> --
> 1.7.3.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list