Mesa (master): vulkan/util: Handle enums that are in platform-specific headers.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 18 15:39:59 UTC 2019


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

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Sun Mar 17 20:26:07 2019 +0100

vulkan/util: Handle enums  that are in platform-specific headers.

VkFullScreenExclusiveEXT comes from the win32 header. Mostly took
the logic from the entrypoint scripts:

1) If there is an ext that has it in the requires and has a platform,
   take the guard for that platform.
2) Otherwise assume it is from the core headers.

Acked-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>

---

 src/vulkan/util/gen_enum_to_str.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index 2756eb21cb8..4324ca5b7b7 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -65,6 +65,9 @@ C_TEMPLATE = Template(textwrap.dedent(u"""\
 
     % for enum in enums:
 
+      % if enum.guard:
+#ifdef ${enum.guard}
+      % endif
     const char *
     vk_${enum.name[2:]}_to_str(${enum.name} input)
     {
@@ -86,6 +89,10 @@ C_TEMPLATE = Template(textwrap.dedent(u"""\
             unreachable("Undefined enum value.");
         }
     }
+
+      % if enum.guard:
+#endif
+      % endif
     %endfor
 
     void vk_load_instance_commands(VkInstance instance,
@@ -150,7 +157,13 @@ H_TEMPLATE = Template(textwrap.dedent(u"""\
     % endfor
 
     % for enum in enums:
+      % if enum.guard:
+#ifdef ${enum.guard}
+      % endif
     const char * vk_${enum.name[2:]}_to_str(${enum.name} input);
+      % if enum.guard:
+#endif
+      % endif
     % endfor
 
     struct vk_instance_dispatch_table {
@@ -235,6 +248,7 @@ class VkEnum(object):
         # Maps numbers to names
         self.values = values or dict()
         self.name_to_value = dict()
+        self.guard = None
 
     def add_value(self, name, value=None,
                   extnum=None, offset=None,
@@ -269,6 +283,9 @@ class VkEnum(object):
                            offset=int(elem.attrib['offset']),
                            error=error)
 
+    def set_guard(self, g):
+        self.guard = g
+
 
 class VkCommand(object):
     """Simple struct-like class representing a single Vulkan command"""
@@ -325,6 +342,12 @@ def parse_xml(cmd_factory, enum_factory, ext_factory, filename):
             if enum is not None:
                 enum.add_value_from_xml(value, extension)
 
+        if define:
+            for value in ext_elem.findall('./require/type[@name]'):
+                enum = enum_factory.get(value.attrib['name'])
+                if enum is not None:
+                    enum.set_guard(define)
+
         for t in ext_elem.findall('./require/command'):
             command = cmd_factory.get(t.attrib['name'])
             if command is not None:




More information about the mesa-commit mailing list