Mesa (master): util: Turn inv_swizzle into a global function

Jose Fonseca jrfonseca at kemper.freedesktop.org
Mon Apr 28 12:32:46 UTC 2014


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

Author: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
Date:   Wed Mar 19 17:09:14 2014 +0000

util: Turn inv_swizzle into a global function

With the big-endian changes, there can be two swizzle orders for each format.
This patch turns Format.inv_swizzle() into a global function that takes the
swizzle list as a parameter.

There is no change to the generated u_format_table.c.

Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
Signed-off-by: José Fonseca <jfonseca at vmware.com>

---

 src/gallium/auxiliary/util/u_format_pack.py  |   12 +++++++++++-
 src/gallium/auxiliary/util/u_format_parse.py |   10 ----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index 5c67810..8a3101f 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -40,6 +40,16 @@
 from u_format_parse import *
 
 
+def inv_swizzles(swizzles):
+    '''Return an array[4] of inverse swizzle terms'''
+    '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
+    inv_swizzle = [None]*4
+    for i in range(4):
+        swizzle = swizzles[i]
+        if swizzle < 4 and inv_swizzle[swizzle] == None:
+            inv_swizzle[swizzle] = i
+    return inv_swizzle
+
 def generate_format_type(format):
     '''Generate a structure that describes the format.'''
 
@@ -489,7 +499,7 @@ def generate_pack_kernel(format, src_channel, src_native_type):
 
     assert format.layout == PLAIN
 
-    inv_swizzle = format.inv_swizzles()
+    inv_swizzle = inv_swizzles(format.swizzles)
 
     if format.is_bitmask():
         depth = format.block_size()
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py
index 6b7b0f6..08c55c1 100755
--- a/src/gallium/auxiliary/util/u_format_parse.py
+++ b/src/gallium/auxiliary/util/u_format_parse.py
@@ -244,16 +244,6 @@ class Format:
     def has_stencil(self):
         return self.colorspace == ZS and self.has_channel(1)
 
-    def inv_swizzles(self):
-        '''Return an array[4] of inverse swizzle terms'''
-        '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
-        inv_swizzle = [None]*4
-        for i in range(4):
-            swizzle = self.swizzles[i]
-            if swizzle < 4 and inv_swizzle[swizzle] == None:
-                inv_swizzle[swizzle] = i
-        return inv_swizzle
-
     def stride(self):
         return self.block_size()/8
 




More information about the mesa-commit mailing list