[Mesa-dev] [PATCH 3/4] mesa: Replace IROUND_POS() with lroundf().

Matt Turner mattst88 at gmail.com
Thu May 26 18:28:49 UTC 2016


---
 src/mesa/drivers/x11/xm_api.c   | 2 +-
 src/mesa/main/imports.h         | 9 ---------
 src/mesa/program/prog_execute.c | 4 ----
 src/mesa/swrast/s_aaline.c      | 2 +-
 src/mesa/swrast/s_aatriangle.c  | 2 +-
 5 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 82c4d18..3eaa6cf 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -150,7 +150,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 lroundf(max * pow(x, 1.0F/gamma));
    }
 }
 
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 5ed83e9..ea27194 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -140,15 +140,6 @@ static inline GLfloat LOG2(GLfloat x)
 #endif
 
 
-/**
- * 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);
-}
-
 /** Return (as an integer) floor of float */
 static inline int IFLOOR(float f)
 {
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index cb06e62..85b9315 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -1149,10 +1149,6 @@ _mesa_execute_program(struct gl_context * ctx,
             GLfloat texcoord[4], color[4];
 
             fetch_vector4(&inst->SrcReg[0], machine, texcoord);
-            /* Not so sure about this test - if texcoord[3] is
-             * zero, we'd probably be fine except for an assert in
-             * IROUND_POS() which gets triggered by the inf values created.
-             */
             if (texcoord[3] != 0.0F) {
                texcoord[0] /= texcoord[3];
                texcoord[1] /= texcoord[3];
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index de5b42b..e9e1750 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -181,7 +181,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) lroundf(z);
 #endif
 }
 
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index b510987..b1ceefb 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -124,7 +124,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) lroundf(z);
 #endif
 }
 
-- 
2.7.3



More information about the mesa-dev mailing list