anv: pCreateInfo->pApplicationInfo parameter to vkCreateInstance may be NULL
[mesa.git] / src / vulkan / gen_pack_header.py
index 8ed74581063d4c756ced46157e0d4cb7b6dc2c6a..3cabb5864aa384d6c233614055a4f429ae4cb090 100755 (executable)
@@ -206,7 +206,8 @@ class Field:
 
     def __init__(self, parser, attrs):
         self.parser = parser
-        self.name = safe_name(attrs["name"])
+        if "name" in attrs:
+            self.name = safe_name(attrs["name"])
         self.start = int(attrs["start"])
         self.end = int(attrs["end"])
         self.type = attrs["type"]
@@ -225,7 +226,7 @@ class Field:
         if ufixed_match:
             self.type = 'ufixed'
             self.fractional_size = int(ufixed_match.group(2))
-            
+
         sfixed_match = Field.sfixed_pattern.match(self.type)
         if sfixed_match:
             self.type = 'sfixed'
@@ -252,9 +253,11 @@ class Field:
             type = 'uint32_t'
         elif self.type in self.parser.structs:
             type = 'struct ' + self.parser.gen_prefix(safe_name(self.type))
+        elif self.type == 'mbo':
+            return
         else:
             print("#error unhandled type: %s" % self.type)
-            
+
         print("   %-36s %s%s;" % (type, self.name, dim))
 
         if len(self.values) > 0 and self.default == None:
@@ -317,13 +320,16 @@ class Group:
                 # assert dwords[index].address == None
                 dwords[index].address = field
 
-            # Does this field extend into the next dword?
-            if index < field.end // 32 and dwords[index].size == 32:
-                if index + 1 in dwords:
-                    assert dwords[index + 1].size == 32
+            # Coalesce all the dwords covered by this field. The two cases we
+            # handle are where multiple fields are in a 64 bit word (typically
+            # and address and a few bits) or where a single struct field
+            # completely covers multiple dwords.
+            while index < (start + field.end) // 32:
+                if index + 1 in dwords and not dwords[index] == dwords[index + 1]:
                     dwords[index].fields.extend(dwords[index + 1].fields)
                 dwords[index].size = 64
                 dwords[index + 1] = dwords[index]
+                index = index + 1
 
     def emit_pack_function(self, start):
         dwords = {}
@@ -395,7 +401,9 @@ class Group:
 
             field_index = 0
             for field in dw.fields:
-                name = field.name + field.dim
+                if field.type != "mbo":
+                    name = field.name + field.dim
+
                 if field.type == "mbo":
                     s = "__gen_mbo(%d, %d)" % \
                         (field.start - dword_start, field.end - dword_start)
@@ -534,7 +542,7 @@ class Parser:
         print("struct %s {" % self.gen_prefix(name))
         group.emit_template_struct("")
         print("};\n")
-        
+
     def emit_pack_function(self, name, group):
         name = self.gen_prefix(name)
         print("static inline void\n%s_pack(__gen_user_data *data, void * restrict dst,\n%sconst struct %s * restrict values)\n{" %
@@ -590,7 +598,7 @@ class Parser:
                 name = value.name
             print('#define %-36s %4d' % (name.upper(), value.value))
         print('')
-                        
+
     def parse(self, filename):
         file = open(filename, "rb")
         self.parser.ParseFile(file)