vulkan: Update Vulkan XML and headers to 1.2.148
[mesa.git] / src / vulkan / util / gen_enum_to_str.py
index 0983c4e50a528fd1b98f9405a6796391a20367b4..ebaf2a1a0ccb1e923122dedd7c367832ecfb24a4 100644 (file)
@@ -25,7 +25,7 @@ from __future__ import print_function
 import argparse
 import os
 import textwrap
-import xml.etree.cElementTree as et
+import xml.etree.ElementTree as et
 
 from mako.template import Template
 
@@ -90,6 +90,8 @@ C_TEMPLATE = Template(textwrap.dedent(u"""\
 
     size_t vk_structure_type_size(const struct VkBaseInStructure *item)
     {
+        #pragma GCC diagnostic push
+        #pragma GCC diagnostic ignored "-Wswitch"
         switch(item->sType) {
     % for struct in structs:
         % if struct.extension is not None and struct.extension.define is not None:
@@ -100,9 +102,9 @@ C_TEMPLATE = Template(textwrap.dedent(u"""\
         case ${struct.stype}: return sizeof(${struct.name});
         % endif
     %endfor
-        default:
-            unreachable("Undefined struct type.");
         }
+        #pragma GCC diagnostic pop
+        unreachable("Undefined struct type.");
     }
 
     void vk_load_instance_commands(VkInstance instance,
@@ -256,10 +258,23 @@ class VkEnum(object):
         self.values = values or dict()
         self.name_to_value = dict()
         self.guard = None
+        self.name_to_alias_list = {}
 
     def add_value(self, name, value=None,
-                  extnum=None, offset=None,
+                  extnum=None, offset=None, alias=None,
                   error=False):
+        if alias is not None:
+            assert value is None and offset is None
+            if alias not in self.name_to_value:
+                # We don't have this alias yet.  Just record the alias and
+                # we'll deal with it later.
+                alias_list = self.name_to_alias_list.get(alias, [])
+                alias_list.append(name);
+                return
+
+            # Use the value from the alias
+            value = self.name_to_value[alias]
+
         assert value is not None or extnum is not None
         if value is None:
             value = 1000000000 + (extnum - 1) * 1000 + offset
@@ -272,14 +287,19 @@ class VkEnum(object):
         elif len(self.values[value]) > len(name):
             self.values[value] = name
 
+        # Now that the value has been fully added, resolve aliases, if any.
+        if name in self.name_to_alias_list:
+            for alias in self.name_to_alias_list[name]:
+                add_value(alias, value)
+            del self.name_to_alias_list[name]
+
     def add_value_from_xml(self, elem, extension=None):
         self.extension = extension
         if 'value' in elem.attrib:
             self.add_value(elem.attrib['name'],
                            value=int(elem.attrib['value'], base=0))
         elif 'alias' in elem.attrib:
-            self.add_value(elem.attrib['name'],
-                           value=self.name_to_value[elem.attrib['alias']])
+            self.add_value(elem.attrib['name'], alias=elem.attrib['alias'])
         else:
             error = 'dir' in elem.attrib and elem.attrib['dir'] == '-'
             if 'extnumber' in elem.attrib: