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

Author: José Fonseca <jfons...@vmware.com>
Date:   Wed Mar 31 14:31:29 2010 +0100

util: Make util_format_xxx_pack_xxx take pointer as arguments.

---

 progs/gallium/unit/u_format_test.c          |    8 ++++++--
 src/gallium/auxiliary/util/u_format_pack.py |   12 ++++++------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/progs/gallium/unit/u_format_test.c 
b/progs/gallium/unit/u_format_test.c
index 5274311..1aef416 100644
--- a/progs/gallium/unit/u_format_test.c
+++ b/progs/gallium/unit/u_format_test.c
@@ -60,13 +60,17 @@ test_format_unpack_4f(const struct util_format_test_case 
*test)
 static boolean
 test_format_pack_4f(const struct util_format_test_case *test)
 {
+   float unpacked[4];
    uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
    unsigned i;
    boolean success;
 
    memset(packed, 0, sizeof packed);
 
-   util_format_pack_4f(test->format, packed, test->unpacked[0], 
test->unpacked[1], test->unpacked[2], test->unpacked[3]);
+   for (i = 0; i < 4; ++i)
+      unpacked[i] = (float) test->unpacked[i];
+
+   util_format_pack_4f(test->format, packed, unpacked);
 
    success = TRUE;
    for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i)
@@ -158,7 +162,7 @@ test_format_pack_4ub(const struct util_format_test_case 
*test)
 
    memset(packed, 0, sizeof packed);
 
-   util_format_pack_4ub(test->format, packed, unpacked[0], unpacked[1], 
unpacked[2], unpacked[3]);
+   util_format_pack_4ub(test->format, packed, unpacked);
 
    success = TRUE;
    for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i)
diff --git a/src/gallium/auxiliary/util/u_format_pack.py 
b/src/gallium/auxiliary/util/u_format_pack.py
index e9d2573..43468ec 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -423,7 +423,7 @@ def generate_format_pack(format, src_channel, 
src_native_type, src_suffix):
     inv_swizzle = format.inv_swizzles()
     
     print 'static INLINE void'
-    print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, 
src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
+    print 'util_format_%s_pack_%s(void *dst, const %s *src)' % (name, 
src_suffix, src_native_type)
     print '{'
     
     if format.is_bitmask():
@@ -434,7 +434,7 @@ def generate_format_pack(format, src_channel, 
src_native_type, src_suffix):
         for i in range(4):
             dst_channel = format.channels[i]
             if inv_swizzle[i] is not None:
-                value = 'rgba'[inv_swizzle[i]]
+                value ='src[%u]' % inv_swizzle[i]
                 value = conversion_expr(src_channel, dst_channel, 
dst_native_type, value)
                 if format.colorspace == ZS:
                     if i == 3:
@@ -470,7 +470,7 @@ def generate_format_pack(format, src_channel, 
src_native_type, src_suffix):
             width = dst_channel.size
             if inv_swizzle[i] is None:
                 continue
-            value = 'rgba'[inv_swizzle[i]]
+            value ='src[%u]' % inv_swizzle[i]
             value = conversion_expr(src_channel, dst_channel, dst_native_type, 
value)
             if format.colorspace == ZS:
                 if i == 3:
@@ -520,9 +520,9 @@ def generate_pack(formats, src_channel, src_native_type, 
src_suffix):
             generate_format_pack(format, src_channel, src_native_type, 
src_suffix)
 
     print 'static INLINE void'
-    print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, 
%s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, 
src_native_type)
+    print 'util_format_pack_%s(enum pipe_format format, void *dst, %s *src)' % 
(src_suffix, src_native_type)
     print '{'
-    print '   void (*func)(void *dst, %s r, %s g, %s b, %s a);' % 
(src_native_type, src_native_type, src_native_type, src_native_type)
+    print '   void (*func)(void *dst, const %s *src);' % (src_native_type,)
     print '   switch(format) {'
     for format in formats:
         if is_format_supported(format):
@@ -533,7 +533,7 @@ def generate_pack(formats, src_channel, src_native_type, 
src_suffix):
     print '      debug_printf("%s: unsupported format\\n", __FUNCTION__);'
     print '      return;'
     print '   }'
-    print '   func(dst, r, g, b, a);'
+    print '   func(dst, src);'
     print '}'
     print
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to