Mesa (master): gallivm: simpler uint8->float conversions

Keith Whitwell keithw at kemper.freedesktop.org
Sat Oct 9 10:46:37 UTC 2010


Module: Mesa
Branch: master
Commit: 2ef6f75ab410bb188e028024e18891d7877febad
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ef6f75ab410bb188e028024e18891d7877febad

Author: Keith Whitwell <keithw at vmware.com>
Date:   Wed Oct  6 19:09:03 2010 +0100

gallivm: simpler uint8->float conversions

LLVM seems to finds it easier to reason about these than our
mantissa-manipulation code.

---

 src/gallium/auxiliary/gallivm/lp_bld_conv.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index 3abb192..20aa257 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -178,6 +178,16 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
 
    assert(dst_type.floating);
 
+   /* Special-case int8->float, though most cases could be handled
+    * this way:
+    */
+   if (src_width == 8) {
+      scale = 1.0/255.0;
+      res = LLVMBuildSIToFP(builder, src, vec_type, "");
+      res = LLVMBuildFMul(builder, res, lp_build_const_vec(dst_type, scale), "");
+      return res;
+   }
+
    mantissa = lp_mantissa(dst_type);
 
    n = MIN2(mantissa, src_width);




More information about the mesa-commit mailing list