panfrost: Inherit default values from structs
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 21 Aug 2020 20:21:40 +0000 (16:21 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 25 Aug 2020 15:05:38 +0000 (17:05 +0200)
Nesting can be useful sometimes.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6440>

src/panfrost/lib/gen_pack.py

index 59890f7cd8a9d0e3b487a48fa850bd962f89f6ea..8c1f2e755cdda1d232dfe76ea0ebce000ddc083b 100644 (file)
@@ -539,9 +539,10 @@ class Parser(object):
         for field in self.group.fields:
             if not type(field) is Field:
                 continue
-            if field.default == None:
-                continue
-            default_fields.append("   .{} = {}".format(field.name, field.default))
+            if field.default is not None:
+                default_fields.append("   .{} = {}".format(field.name, field.default))
+            elif field.type in self.structs:
+                default_fields.append("   .{} = {{ {}_header }}".format(field.name, self.gen_prefix(safe_name(field.type.upper()))))
 
         print('#define %-40s\\' % (name + '_header'))
         print(",  \\\n".join(default_fields))