Mesa (main): zink/codegen: remember the fields in feats/props structs of extensions

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 3 13:27:49 UTC 2022


Module: Mesa
Branch: main
Commit: 0d344e96c0ff0ba385411f1411ef6a51049fcc0c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d344e96c0ff0ba385411f1411ef6a51049fcc0c

Author: Hoe Hao Cheng <haochengho12907 at gmail.com>
Date:   Sun May  1 17:22:36 2022 +0800

zink/codegen: remember the fields in feats/props structs of extensions

this will be useful in the next commit, where we reapply fields from one struct
to another.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16265>

---

 src/gallium/drivers/zink/zink_extensions.py | 70 ++++++++++++++++++++++++++---
 1 file changed, 64 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_extensions.py b/src/gallium/drivers/zink/zink_extensions.py
index 2b8e7a4854c..0fd20a462b3 100644
--- a/src/gallium/drivers/zink/zink_extensions.py
+++ b/src/gallium/drivers/zink/zink_extensions.py
@@ -67,9 +67,12 @@ class Extension:
     core_since     = None
 
     # these are specific to zink_device_info.py:
-    has_properties = False
-    has_features   = False
-    guard          = False
+    has_properties      = False
+    has_features        = False
+    guard               = False
+    features_promoted   = False
+    properties_promoted = False
+    
 
     # these are specific to zink_instance.py:
     platform_guard = None
@@ -153,7 +156,11 @@ class ExtensionRegistryEntry:
     instance_commands = None
     constants         = None
     features_struct   = None
+    features_fields   = None
+    features_promoted = False
     properties_struct = None
+    properties_fields = None
+    properties_promoted = False
     # some instance extensions are locked behind certain platforms
     platform_guard    = ""
 
@@ -165,8 +172,9 @@ class ExtensionRegistry:
         vkxml = ElementTree.parse(vkxml_path)
 
         commands_type = dict()
-        aliases = dict()
+        command_aliases = dict()
         platform_guards = dict()
+        struct_aliases = dict()
 
         for cmd in vkxml.findall("commands/command"):
             name = cmd.find("./proto/name")
@@ -174,9 +182,19 @@ class ExtensionRegistry:
             if name is not None and name.text:
                 commands_type[name.text] = cmd.find("./param/type").text
             elif cmd.get("name") is not None:
-                aliases[cmd.get("name")] = cmd.get("alias")
+                command_aliases[cmd.get("name")] = cmd.get("alias")
+
+        for typ in vkxml.findall("types/type"):
+            if typ.get("category") != "struct":
+                continue
 
-        for (cmd, alias) in aliases.items():
+            name = typ.get("name")
+            alias = typ.get("alias")
+
+            if name and alias:
+                struct_aliases[name] = alias
+
+        for (cmd, alias) in command_aliases.items():
             commands_type[cmd] = commands_type[alias]
 
         for platform in vkxml.findall("platforms/platform"):
@@ -198,6 +216,8 @@ class ExtensionRegistry:
             entry.device_commands = []
             entry.pdevice_commands = []
             entry.instance_commands = []
+            entry.features_fields = []
+            entry.properties_fields = []
 
             for cmd in ext.findall("require/command"):
                 cmd_name = cmd.get("name")
@@ -223,10 +243,48 @@ class ExtensionRegistry:
                 if (self.is_features_struct(ty_name) and
                     entry.features_struct is None):
                     entry.features_struct = ty_name
+                    
                 elif (self.is_properties_struct(ty_name) and
                       entry.properties_struct is None):
                     entry.properties_struct = ty_name
 
+            if entry.features_struct:
+                struct_name = entry.features_struct
+                if entry.features_struct in struct_aliases:
+                    struct_name = struct_aliases[entry.features_struct]
+                    entry.features_promoted = True
+
+                elif entry.promoted_in is not None:
+                    # if the extension is promoted but a core-Vulkan alias is not
+                    # available for the features, then consider the features struct
+                    # non-core-promoted
+                    entry.features_promoted = False
+
+                for field in vkxml.findall("./types/type[@name='{}']/member".format(struct_name)):
+                    field_name = field.find("name").text
+                    
+                    # we ignore sType and pNext since they are irrelevant
+                    if field_name not in ["sType", "pNext"]:
+                        entry.features_fields.append(field_name)
+
+            if entry.properties_struct:
+                struct_name = entry.properties_struct
+                if entry.properties_struct in struct_aliases:
+                    struct_name = struct_aliases[entry.properties_struct]
+                    entry.properties_promoted = True
+
+                elif entry.promoted_in is not None:
+                    # if the extension is promoted but a core-Vulkan alias is not
+                    # available for the properties, then it is not promoted to core
+                    entry.properties_promoted = False
+                
+                for field in vkxml.findall("./types/type[@name='{}']/member".format(struct_name)):
+                    field_name = field.find("name").text
+
+                    # we ignore sType and pNext since they are irrelevant
+                    if field_name not in ["sType", "pNext"]:
+                        entry.properties_fields.append(field_name)
+
             if ext.get("platform") is not None:
                 entry.platform_guard = platform_guards[ext.get("platform")]
 



More information about the mesa-commit mailing list