aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-29 03:51:46 -0700
committerChris Robinson <[email protected]>2011-09-29 03:51:46 -0700
commitb6b3ca6e6ffab6aa943c760be1290954190ae66e (patch)
treec5281372ec06e7995aa412266205b62d596d1b49 /OpenAL32
parent53572da7de8d2cf22ed996dec4b992ca378f371c (diff)
Use inline assembly for fast float-to-int conversions
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 9615ec8b..88478a88 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -465,6 +465,30 @@ static __inline ALuint NextPowerOf2(ALuint value)
return powerOf2;
}
+/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
+ * mode. */
+static __inline ALint fastf2i(ALfloat f)
+{
+ ALint i;
+#if defined(_MSC_VER)
+ __asm fld f
+ __asm fistp i
+#elif defined(__GNUC__)
+ __asm__ __volatile__("flds %1\n\t"
+ "fistpl %0\n\t"
+ : "=m" (i)
+ : "m" (f));
+#else
+ i = (ALint)f;
+#endif
+ return i;
+}
+
+/* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
+ * mode. */
+static __inline ALuint fastf2u(ALfloat f)
+{ return fastf2i(f); }
+
enum DevProbe {
DEVICE_PROBE,