gallium: Don't emit identical endian-dependent pack/unpack code.
authorEric Anholt <eric@anholt.net>
Wed, 14 Aug 2019 21:40:03 +0000 (14:40 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 28 Aug 2019 17:39:36 +0000 (10:39 -0700)
Reduces the size of the u_format_table.c file by 140k (out of 1.64M)
and makes me less confused about endianness in gallium.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_format_pack.py

index 75bda428e9345fa54a637011a7b102ce66400997..aae6b5ab9f016541154c5203bab357410526abf2 100644 (file)
@@ -64,11 +64,17 @@ def print_channels(format, func):
     if format.nr_channels() <= 1:
         func(format.le_channels, format.le_swizzles)
     else:
-        print('#ifdef PIPE_ARCH_BIG_ENDIAN')
-        func(format.be_channels, format.be_swizzles)
-        print('#else')
-        func(format.le_channels, format.le_swizzles)
-        print('#endif')
+        if (format.le_channels == format.be_channels and
+            [c.shift for c in format.le_channels] ==
+            [c.shift for c in format.be_channels] and
+            format.le_swizzles == format.be_swizzles):
+            func(format.le_channels, format.le_swizzles)
+        else:
+            print('#ifdef PIPE_ARCH_BIG_ENDIAN')
+            func(format.be_channels, format.be_swizzles)
+            print('#else')
+            func(format.le_channels, format.le_swizzles)
+            print('#endif')
 
 def generate_format_type(format):
     '''Generate a structure that describes the format.'''