aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/r300/r300_context.h
diff options
context:
space:
mode:
authorOliver McFadden <[email protected]>2007-05-11 23:32:03 +0000
committerOliver McFadden <[email protected]>2007-05-11 23:32:03 +0000
commitdac5303692726582d2fac2d9e9b620e3105ff8c3 (patch)
treec016eab556e82c59cd4e2cf6753cd52a78aabd6d /src/mesa/drivers/dri/r300/r300_context.h
parent64b03f33eeb2f57f1c7a528d011137c6f2612fb0 (diff)
r300: Moved r300PackFloat24 near r300PackFloat32.
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_context.h')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index c287871b370..2408497c483 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -102,6 +102,37 @@ static __inline__ uint32_t r300PackFloat32(float fl)
return u.u;
}
+/* This is probably wrong for some values, I need to test this
+ * some more. Range checking would be a good idea also..
+ *
+ * But it works for most things. I'll fix it later if someone
+ * else with a better clue doesn't
+ */
+static __inline__ uint32_t r300PackFloat24(float f)
+{
+ float mantissa;
+ int exponent;
+ uint32_t float24 = 0;
+
+ if (f == 0.0)
+ return 0;
+
+ mantissa = frexpf(f, &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 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
+
+ return float24;
+}
+
/************ DMA BUFFERS **************/
/* Need refcounting on dma buffers: