Mesa (master): vulkan/util: use the platform defines in vk.xml instead of hard-coding them

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 7 11:50:28 UTC 2019


Module: Mesa
Branch: master
Commit: d141472d0ec1db2391a54919bc480eaa1eac36b6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d141472d0ec1db2391a54919bc480eaa1eac36b6

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Tue Mar  5 15:57:34 2019 +0000

vulkan/util: use the platform defines in vk.xml instead of hard-coding them

See also: 3d4238d26c5de4a0f7a5 "anv: use the platform defines in vk.xml
                                instead of hard-coding them"
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/vulkan/util/gen_enum_to_str.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index cf031670ff7..e6d5f86fa81 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -221,15 +221,10 @@ class NamedFactory(object):
 class VkExtension(object):
     """Simple struct-like class representing extensions"""
 
-    def __init__(self, name, number=None, platform=None):
+    def __init__(self, name, number=None, define=None):
         self.name = name
         self.number = number
-        self.define = None
-        if platform is not None:
-            ext = '_KHR'
-            if platform.upper() == 'XLIB_XRANDR':
-                ext = '_EXT'
-            self.define = 'VK_USE_PLATFORM_' + platform.upper() + ext
+        self.define = define
 
 
 class VkEnum(object):
@@ -311,13 +306,19 @@ def parse_xml(cmd_factory, enum_factory, ext_factory, filename):
             cmd_factory(name.text,
                         device_entrypoint=(first_arg.text in ('VkDevice', 'VkCommandBuffer', 'VkQueue')))
 
+    platform_define = {}
+    for platform in xml.findall('./platforms/platform'):
+        name = platform.attrib['name']
+        define = platform.attrib['protect']
+        platform_define[name] = define
+
     for ext_elem in xml.findall('./extensions/extension[@supported="vulkan"]'):
         platform = None
         if "platform" in ext_elem.attrib:
-            platform = ext_elem.attrib['platform']
+            define = platform_define[ext_elem.attrib['platform']]
         extension = ext_factory(ext_elem.attrib['name'],
                                 number=int(ext_elem.attrib['number']),
-                                platform=platform)
+                                define=define)
 
         for value in ext_elem.findall('./require/enum[@extends]'):
             enum = enum_factory.get(value.attrib['extends'])




More information about the mesa-commit mailing list