diff options
author | Bas Nieuwenhuizen <[email protected]> | 2019-03-17 20:26:07 +0100 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2019-03-18 14:48:41 +0000 |
commit | eb5cda1c3eca15790c46fcb7fd62408a7e0ba5f8 (patch) | |
tree | 214851e4bc07eeb6bf474f79643e1a8a65d0620b /src/vulkan/util | |
parent | 5abe488d185461261275cb2f957871a04e03dab8 (diff) |
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 <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/vulkan/util')
-rw-r--r-- | src/vulkan/util/gen_enum_to_str.py | 23 |
1 files changed, 23 insertions, 0 deletions
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: |