Skip to content

Commit 8d4637a

Browse files
committed
vulkan: Add support for including aliased entrypoints
1 parent eb7fe42 commit 8d4637a

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

bin/gen_enum_to_str.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
#endif
121121
% else:
122122
table->${cmd.name[2:]} = (PFN_${cmd.name}) gpa(instance, "${cmd.name}");
123+
% for alias in cmd.aliases:
124+
if (table->${cmd.name[2:]} == NULL)
125+
table->${cmd.name[2:]} = (PFN_${cmd.name}) gpa(instance, "${alias}");
126+
% endfor
123127
% endif
124128
% endif
125129
%endfor
@@ -139,6 +143,10 @@
139143
#endif
140144
% else:
141145
table->${cmd.name[2:]} = (PFN_${cmd.name}) gpa(device, "${cmd.name}");
146+
% for alias in cmd.aliases:
147+
if (table->${cmd.name[2:]} == NULL)
148+
table->${cmd.name[2:]} = (PFN_${cmd.name}) gpa(instance, "${alias}");
149+
% endfor
142150
% endif
143151
% endif
144152
%endfor
@@ -320,6 +328,7 @@ def __init__(self, name, device_entrypoint=False):
320328
self.name = name
321329
self.device_entrypoint = device_entrypoint
322330
self.extension = None
331+
self.aliases = []
323332

324333

325334
class VkChainStruct(object):
@@ -362,11 +371,22 @@ def parse_xml(cmd_factory, enum_factory, ext_factory, struct_factory, filename):
362371
if name is not None and "ANDROID" in name.text:
363372
continue
364373
first_arg = command.find('./param/type')
365-
# Some commands are alias KHR -> nonKHR, ignore those
374+
# Some commands are alias KHR -> nonKHR, process those later.
366375
if name is not None:
367376
cmd_factory(name.text,
368377
device_entrypoint=(first_arg.text in ('VkDevice', 'VkCommandBuffer', 'VkQueue')))
369378

379+
ALLOWED_COMMAND_ALIASES = [
380+
]
381+
for command in xml.findall('./commands/command'):
382+
if 'alias' not in command.attrib:
383+
continue
384+
alias = command.attrib['alias']
385+
name = command.attrib['name']
386+
if name not in ALLOWED_COMMAND_ALIASES:
387+
continue
388+
cmd_factory.get(alias).aliases.append(name)
389+
370390
for struct_type in xml.findall('./types/type[@category="struct"]'):
371391
name = struct_type.attrib['name']
372392
if name is not None and "ANDROID" in name:

0 commit comments

Comments
 (0)