Merge branch 'mesa_7_7_branch'
[mesa.git] / src / gallium / auxiliary / util / u_format_table.py
index c772a75e615ece46b9c4699983407e97408835e6..571cab55dc8ffa30361a8b355e2d5b04fa461553 100755 (executable)
@@ -35,12 +35,8 @@ import sys
 from u_format_parse import *
 
 
-layout_map = {
-    'arith': 'UTIL_FORMAT_LAYOUT_PLAIN',
-    'array': 'UTIL_FORMAT_LAYOUT_PLAIN',
-    'yuv':   'UTIL_FORMAT_LAYOUT_PLAIN',
-    'dxt':   'UTIL_FORMAT_LAYOUT_DXT',
-}
+def layout_map(layout):
+    return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper()
 
 
 def colorspace_map(colorspace):
@@ -48,11 +44,10 @@ def colorspace_map(colorspace):
 
 
 colorspace_channels_map = {
-    'rgb': 'rgba',
-    'rgba': 'rgba',
-    'zs': 'zs',
-    'yuv': ['y1', 'y2', 'u', 'v'],
-    'dxt': []
+    'rgb': ['r', 'g', 'b', 'a'],
+    'srgb': ['sr', 'sg', 'sb', 'a'],
+    'zs': ['z', 's'],
+    'yuv': ['y', 'u', 'v'],
 }
 
 
@@ -107,8 +102,8 @@ def write_format_table(formats):
         print "   {"
         print "      %s," % (format.name,)
         print "      \"%s\"," % (format.name,)
-        print "      {%u, %u, %u}, /* block */" % (format.block_width, format.block_height, format.block_size())
-        print "      %s," % (layout_map[format.layout],)
+        print "      {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
+        print "      %s," % (layout_map(format.layout),)
         print "      {"
         for i in range(4):
             type = format.in_types[i]
@@ -116,7 +111,7 @@ def write_format_table(formats):
                 sep = ","
             else:
                 sep = ""
-            print "         {%s, %s, %u}%s /* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i])
+            print "         {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i])
         print "      },"
         print "      {"
         for i in range(4):
@@ -126,10 +121,10 @@ def write_format_table(formats):
             else:
                 sep = ""
             try:
-                comment = layout_channels_map[format.layout][i]
-            except:
+                comment = colorspace_channels_map[format.colorspace][i]
+            except (KeyError, IndexError):
                 comment = 'ignored'
-            print "         %s%s /* %s */" % (swizzle_map[swizzle], sep, comment)
+            print "         %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
         print "      },"
         print "      %s," % (colorspace_map(format.colorspace),)
         print "   },"