anv: Handle dwords that are all MBZ correctly
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 11 Feb 2016 00:35:28 +0000 (16:35 -0800)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 11 Feb 2016 00:36:47 +0000 (16:36 -0800)
A few packets have dwords in them that are all MBZ and we failed to
write those. This change makes sure we iterate through all dwords and
write them all.

src/vulkan/gen_pack_header.py

index 58da0184faf1f16880b971e1cda4d865e5a9a7da..8ed74581063d4c756ced46157e0d4cb7b6dc2c6a 100755 (executable)
@@ -329,11 +329,27 @@ class Group:
         dwords = {}
         self.collect_dwords(dwords, 0, "")
 
-        for index, dw in dwords.items():
+        # Determine number of dwords in this group. If we have a size, use
+        # that, since that'll account for MBZ dwords at the end of a group
+        # (like dword 8 on BDW+ 3DSTATE_HS). Otherwise, use the largest dword
+        # index we've seen plus one.
+        if self.size > 0:
+            length = self.size // 32
+        else:
+            length = max(dwords.keys()) + 1
+
+        for index in range(length):
+            # Handle MBZ dwords
+            if not index in dwords:
+                print("")
+                print("   dw[%d] = 0;" % index)
+                continue
+
             # For 64 bit dwords, we aliased the two dword entries in the dword
             # dict it occupies. Now that we're emitting the pack function,
             # skip the duplicate entries.
-            if index > 0 and index - 1 in dwords and dwords[index - 1] == dwords[index]:
+            dw = dwords[index]
+            if index > 0 and index - 1 in dwords and dw == dwords[index - 1]:
                 continue
 
             # Special case: only one field and it's a struct at the beginning
@@ -453,21 +469,26 @@ class Parser:
             self.gen = attrs["gen"].replace('.', '')
             print(pack_header % {'license': license, 'platform': self.platform})
         elif name == "instruction":
-            self.group = Group(self, None, 0, 1, 0)
             self.instruction = safe_name(attrs["name"])
             self.length_bias = int(attrs["bias"])
             if "length" in attrs:
                 self.length = int(attrs["length"])
+                size = self.length * 32
             else:
                 self.length = None
+                size = 0
+            self.group = Group(self, None, 0, 1, size)
         elif name == "struct":
-            self.group = Group(self, None, 0, 1, 0)
             self.struct = safe_name(attrs["name"])
             self.structs[attrs["name"]] = 1
             if "length" in attrs:
                 self.length = int(attrs["length"])
+                size = self.length * 32
             else:
                 self.length = None
+                size = 0
+            self.group = Group(self, None, 0, 1, size)
+
         elif name == "group":
             group = Group(self, self.group,
                           int(attrs["start"]), int(attrs["count"]), int(attrs["size"]))