summaryrefslogtreecommitdiff
path: root/src/radeon_textured_video.c
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2008-08-07 18:08:54 -0700
committerPierre Ossman <pierre@ossman.eu>2008-12-01 19:21:52 +0100
commit01ed5462fad56f5b7bf867041d00443bdf81c653 (patch)
tree4bc558e5640d67a37633ed9f805bf966a4c3e7e7 /src/radeon_textured_video.c
parent85bbe889045aa434f71a3eb0ba8153b7d2cc5023 (diff)
Switch to Mesa-style 24-bit float packing.
Seems like Mesa's got it right, so we should follow suit.
Diffstat (limited to 'src/radeon_textured_video.c')
-rw-r--r--src/radeon_textured_video.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index 8fc380e1..c7d06202 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -80,6 +80,32 @@ static __inline__ uint32_t F_TO_DW(float val)
return tmp.l;
}
+/* Borrowed from Mesa */
+static __inline__ uint32_t F_TO_24(float val)
+{
+ float mantissa;
+ int exponent;
+ uint32_t float24 = 0;
+
+ if (val == 0.0)
+ return 0;
+
+ mantissa = frexpf(val, &exponent);
+
+ /* Handle -ve */
+ if (mantissa < 0) {
+ float24 |= (1 << 23);
+ mantissa = mantissa * -1.0;
+ }
+ /* Handle exponent, bias of 63 */
+ exponent += 62;
+ float24 |= (exponent << 16);
+ /* Kill 7 LSB of mantissa */
+ float24 |= (F_TO_DW(mantissa) & 0x7FFFFF) >> 7;
+
+ return float24;
+}
+
#define ACCEL_MMIO
#define ACCEL_PREAMBLE() unsigned char *RADEONMMIO = info->MMIO
#define BEGIN_ACCEL(n) RADEONWaitForFifo(pScrn, (n))