panfrost: gen_pack: Allow empty structs
authorBoris Brezillon <boris.brezillon@collabora.com>
Sun, 6 Sep 2020 08:50:16 +0000 (10:50 +0200)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 21 Sep 2020 11:34:51 +0000 (07:34 -0400)
This is useful if we want to declare padding sections which can be
packed (filled with zeros) and unpacked (checked for non zero entries).

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6797>

src/panfrost/lib/gen_pack.py

index c17b42c..fed4dc1 100644 (file)
@@ -345,7 +345,7 @@ class Group(object):
 
     def get_length(self):
         # Determine number of bytes in this group.
-        calculated = max(field.end // 8 for field in self.fields) + 1
+        calculated = max(field.end // 8 for field in self.fields) + 1 if len(self.fields) > 0 else 0
         if self.length > 0:
             assert(self.length >= calculated)
         else:
@@ -662,8 +662,10 @@ class Parser(object):
         print('#define %-40s\\' % (name + '_header'))
         if default_fields:
             print(",  \\\n".join(default_fields))
-        else:
+        elif len(self.group.fields) > 0:
             print('   0')
+        else:
+            print('   ')
         print('')
 
     def emit_template_struct(self, name, group, opaque_structs):