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

Author: José Fonseca <[email protected]>
Date:   Sat Mar  6 12:50:47 2010 +0000

util: Several fixes to clamping and test.

All tests pass here except util_format_b5g5r5a1_unorm_unpack_4ub, due to
apparently a gcc 4.4.3 bug.

---

 src/gallium/auxiliary/util/u_format_pack.py |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format_pack.py 
b/src/gallium/auxiliary/util/u_format_pack.py
index 3f33f7c..1fc58cd 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -252,9 +252,6 @@ def conversion_expr(src_channel, dst_channel, 
dst_native_type, value, clamp=True
     if src_channel.type == FLOAT and dst_channel.type == FLOAT:
         return '(%s)%s' % (dst_native_type, value)
     
-    if not src_channel.norm and not dst_channel.norm:
-        return '(%s)%s' % (dst_native_type, value)
-
     if clamp:
         value = clamp_expr(src_channel, dst_channel, dst_native_type, value)
 
@@ -280,15 +277,15 @@ def conversion_expr(src_channel, dst_channel, 
dst_native_type, value, clamp=True
             value = '(%s * %s)' % (value, scale)
         return '(%s)%s' % (dst_native_type, value)
 
-    if not src_channel.norm and not dst_channel.norm:
-        # neither is normalized -- just cast
-        return '(%s)%s' % (dst_native_type, value)
-
     if src_channel.type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, 
UNSIGNED):
+        if not src_channel.norm and not dst_channel.norm:
+            # neither is normalized -- just cast
+            return '(%s)%s' % (dst_native_type, value)
+
         src_one = get_one(src_channel)
         dst_one = get_one(dst_channel)
 
-        if src_one > dst_one and src_channel.norm:
+        if src_one > dst_one and src_channel.norm and dst_channel.norm:
             # We can just bitshift
             src_shift = get_one_shift(src_channel)
             dst_shift = get_one_shift(dst_channel)
@@ -296,7 +293,7 @@ def conversion_expr(src_channel, dst_channel, 
dst_native_type, value, clamp=True
         else:
             # We need to rescale using an intermediate type big enough to hold 
the multiplication of both
             tmp_native_type = intermediate_native_type(src_channel.size + 
dst_channel.size, src_channel.sign and dst_channel.sign)
-            value = '(%s)%s' % (tmp_native_type, value)
+            value = '((%s)%s)' % (tmp_native_type, value)
             value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one)
         value = '(%s)%s' % (dst_native_type, value)
         return value

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to