Because the place that called util_iround are always ensured
that INT_MIN <= f <= INT_MAX
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19978>
checksum: aef0b32ce99a3b25d35304ca08032833
gputest/plot3d-v2.trace:
gl-virgl:
- checksum: 817a36e53edccdf946061315596e9cdd
+ checksum: 96f9fdf530e6041a4f56762b8378f22e
gputest/tessmark-v2.trace:
gl-virgl:
label: [skip, slow]
/**
* 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);
}