From: Bas Nieuwenhuizen Date: Sun, 17 Mar 2019 19:26:07 +0000 (+0100) Subject: vulkan/util: Handle enums that are in platform-specific headers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eb5cda1c3eca15790c46fcb7fd62408a7e0ba5f8;p=mesa.git 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 Reviewed-by: Eric Engestrom --- 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: