panfrost: gen_pack: Allow empty structs

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>
This commit is contained in:
Boris Brezillon 2020-09-06 10:50:16 +02:00 committed by Alyssa Rosenzweig
parent c7a10193d4
commit 1b27817f17

View file

@ -345,7 +345,7 @@ class Group(object):
def get_length(self): def get_length(self):
# Determine number of bytes in this group. # 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: if self.length > 0:
assert(self.length >= calculated) assert(self.length >= calculated)
else: else:
@ -662,8 +662,10 @@ class Parser(object):
print('#define %-40s\\' % (name + '_header')) print('#define %-40s\\' % (name + '_header'))
if default_fields: if default_fields:
print(", \\\n".join(default_fields)) print(", \\\n".join(default_fields))
else: elif len(self.group.fields) > 0:
print(' 0') print(' 0')
else:
print(' ')
print('') print('')
def emit_template_struct(self, name, group, opaque_structs): def emit_template_struct(self, name, group, opaque_structs):