aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-05-18 14:45:20 -0600
committerBrian Paul <[email protected]>2012-05-19 08:28:57 -0600
commitc9cb9cf0502f4ca179ed1b4dd763c94912843d38 (patch)
treef518f7d395fe4919d8db078c7613a8d0316107af /src/mesa/main
parent699c1894eea6a42a747ebbc3974bf0abf3d1dd88 (diff)
mesa: use F_TO_I() instead of IROUND()
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. Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/macros.h10
-rw-r--r--src/mesa/main/pack.c220
-rw-r--r--src/mesa/main/pixeltransfer.c10
3 files changed, 120 insertions, 120 deletions
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index dbe5b867c29..d1df2ce1b0a 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 4d4b4a82569..c25a02e8552 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 c6172b9fd40..fa355eb4a93 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]);
}
}
}