diff options
author | Brian Paul <[email protected]> | 2012-05-18 14:45:20 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-05-19 08:28:57 -0600 |
commit | c9cb9cf0502f4ca179ed1b4dd763c94912843d38 (patch) | |
tree | f518f7d395fe4919d8db078c7613a8d0316107af /src/mesa/main/pack.c | |
parent | 699c1894eea6a42a747ebbc3974bf0abf3d1dd88 (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/pack.c')
-rw-r--r-- | src/mesa/main/pack.c | 220 |
1 files changed, 110 insertions, 110 deletions
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); } |