Mesa (master): util: ubyte_to_float and float_to_ubyte whenever possible.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Fri Apr 9 15:53:30 UTC 2010
Module: Mesa
Branch: master
Commit: 142fb27c3b4c530174968c5f84fd1bd787b8e3de
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=142fb27c3b4c530174968c5f84fd1bd787b8e3de
Author: José Fonseca <jfonseca at vmware.com>
Date: Fri Apr 9 16:53:07 2010 +0100
util: ubyte_to_float and float_to_ubyte whenever possible.
More accurate results.
We should probably generalize these functions for more cases.
---
src/gallium/auxiliary/util/u_format_pack.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index a92a5bc..a607093 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -299,6 +299,13 @@ def conversion_expr(src_channel,
value = 'util_half_to_float(%s)' % value
src_size = 32
+ # Special case for float <-> ubytes for more accurate results
+ # Done before clamping since these functions already take care of that
+ if src_type == UNSIGNED and src_norm and src_size == 8 and dst_channel.type == FLOAT and dst_channel.size == 32:
+ return 'ubyte_to_float(%s)' % value
+ if src_type == FLOAT and src_type == 32 and dst_channel.type == UNSIGNED and dst_channel.norm and dst_channel.size == 8:
+ return 'float_to_ubyte(%s)' % value
+
if clamp:
if dst_channel.type != FLOAT or src_type != FLOAT:
value = clamp_expr(src_channel, dst_channel, dst_native_type, value)
More information about the mesa-commit
mailing list