Module: Mesa
Branch: main
Commit: b1a33789b8aa6cdfe7611e54167ec64d0b1dad3d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1a33789b8aa6cdfe7611e54167ec64d0b1dad3d

Author: Yonggang Luo <[email protected]>
Date:   Thu Dec 22 00:46:34 2022 +0800

util: Implement util_iround with lrintf unconditionally

Because the place that called util_iround are always ensured
that INT_MIN <= f <= INT_MAX

Signed-off-by: Yonggang Luo <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19978>

---

 src/gallium/drivers/virgl/ci/traces-virgl.yml |  2 +-
 src/util/u_math.h                             | 19 ++-----------------
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/virgl/ci/traces-virgl.yml 
b/src/gallium/drivers/virgl/ci/traces-virgl.yml
index 9d942d2af4a..8c0d980a53e 100644
--- a/src/gallium/drivers/virgl/ci/traces-virgl.yml
+++ b/src/gallium/drivers/virgl/ci/traces-virgl.yml
@@ -36,7 +36,7 @@ traces:
       checksum: aef0b32ce99a3b25d35304ca08032833
   gputest/plot3d-v2.trace:
     gl-virgl:
-      checksum: 817a36e53edccdf946061315596e9cdd
+      checksum: 96f9fdf530e6041a4f56762b8378f22e
   gputest/tessmark-v2.trace:
     gl-virgl:
       label: [skip, slow]
diff --git a/src/util/u_math.h b/src/util/u_math.h
index 23116ce9d38..bb639f40448 100644
--- a/src/util/u_math.h
+++ b/src/util/u_math.h
@@ -155,27 +155,12 @@ util_ifloor(float f)
 
 /**
  * Round float to nearest int.
+ * the range of f should be [INT_MIN, INT_MAX]
  */
 static inline int
 util_iround(float f)
 {
-#if DETECT_CC_GCC && DETECT_ARCH_X86
-   int r;
-   __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
-   return r;
-#elif DETECT_CC_MSVC && DETECT_ARCH_X86
-   int r;
-   _asm {
-      fld f
-      fistp r
-   }
-   return r;
-#else
-   if (f >= 0.0f)
-      return (int) (f + 0.5f);
-   else
-      return (int) (f - 0.5f);
-#endif
+   return (int)lrintf(f);
 }
 
 

Reply via email to