'gen9',
'gen10',
'gen11',
+ 'gen12',
]
TEMPLATE_H = Template("""\
%for layer in LAYERS:
extern const struct anv_device_dispatch_table ${layer}_device_dispatch_table;
%endfor
-extern const struct anv_device_dispatch_table anv_tramp_device_dispatch_table;
% for e in instance_entrypoints:
% if e.alias:
* either pick the correct entry point.
*/
+% for e in instance_entrypoints:
+ % if e.alias:
+ <% continue %>
+ % endif
+ % if e.guard is not None:
+#ifdef ${e.guard}
+ % endif
+ ${e.return_type} ${e.prefixed_name('anv')}(${e.decl_params()}) __attribute__ ((weak));
+ % if e.guard is not None:
+#endif // ${e.guard}
+ % endif
+% endfor
+
const struct anv_instance_dispatch_table anv_instance_dispatch_table = {
% for e in instance_entrypoints:
% if e.guard is not None:
% if e.guard is not None:
#ifdef ${e.guard}
% endif
- ${e.return_type} ${e.prefixed_name(layer)}(${e.decl_params()}) __attribute__ ((weak));
+ % if layer == 'anv':
+ ${e.return_type} __attribute__ ((weak))
+ ${e.prefixed_name('anv')}(${e.decl_params()})
+ {
+ % if e.params[0].type == 'VkDevice':
+ ANV_FROM_HANDLE(anv_device, anv_device, ${e.params[0].name});
+ return anv_device->dispatch.${e.name}(${e.call_params()});
+ % elif e.params[0].type == 'VkCommandBuffer':
+ ANV_FROM_HANDLE(anv_cmd_buffer, anv_cmd_buffer, ${e.params[0].name});
+ return anv_cmd_buffer->device->dispatch.${e.name}(${e.call_params()});
+ % elif e.params[0].type == 'VkQueue':
+ ANV_FROM_HANDLE(anv_queue, anv_queue, ${e.params[0].name});
+ return anv_queue->device->dispatch.${e.name}(${e.call_params()});
+ % else:
+ assert(!"Unhandled device child trampoline case: ${e.params[0].type}");
+ % endif
+ }
+ % else:
+ ${e.return_type} ${e.prefixed_name(layer)}(${e.decl_params()}) __attribute__ ((weak));
+ % endif
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
-/** Trampoline entrypoints for all device functions */
-
-% for e in device_entrypoints:
- % if e.alias:
- <% continue %>
- % endif
- % if e.guard is not None:
-#ifdef ${e.guard}
- % endif
- static ${e.return_type}
- ${e.prefixed_name('anv_tramp')}(${e.decl_params()})
- {
- % if e.params[0].type == 'VkDevice':
- ANV_FROM_HANDLE(anv_device, anv_device, ${e.params[0].name});
- return anv_device->dispatch.${e.name}(${e.call_params()});
- % elif e.params[0].type == 'VkCommandBuffer':
- ANV_FROM_HANDLE(anv_cmd_buffer, anv_cmd_buffer, ${e.params[0].name});
- return anv_cmd_buffer->device->dispatch.${e.name}(${e.call_params()});
- % elif e.params[0].type == 'VkQueue':
- ANV_FROM_HANDLE(anv_queue, anv_queue, ${e.params[0].name});
- return anv_queue->device->dispatch.${e.name}(${e.call_params()});
- % else:
- assert(!"Unhandled device child trampoline case: ${e.params[0].type}");
- % endif
- }
- % if e.guard is not None:
-#endif // ${e.guard}
- % endif
-% endfor
-
-const struct anv_device_dispatch_table anv_tramp_device_dispatch_table = {
-% for e in device_entrypoints:
- % if e.guard is not None:
-#ifdef ${e.guard}
- % endif
- .${e.name} = ${e.prefixed_name('anv_tramp')},
- % if e.guard is not None:
-#endif // ${e.guard}
- % endif
-% endfor
-};
-
-
/** Return true if the core version or extension in which the given entrypoint
* is defined is enabled.
*
{
const struct anv_device_dispatch_table *genX_table;
switch (devinfo->gen) {
+ case 12:
+ genX_table = &gen12_device_dispatch_table;
+ break;
case 11:
genX_table = &gen11_device_dispatch_table;
break;
def add_string(self, string, num):
assert not self.baked
assert string not in self.strings
- assert num >= 0 and num < 2**31
+ assert 0 <= num < 2**31
self.strings[string] = StringIntMapEntry(string, num)
def bake(self):
self.extensions = []
class Entrypoint(EntrypointBase):
- def __init__(self, name, return_type, params, guard = None):
+ def __init__(self, name, return_type, params, guard=None):
super(Entrypoint, self).__init__(name)
self.return_type = return_type
self.params = params
def prefixed_name(self, prefix):
return self.alias.prefixed_name(prefix)
-def get_entrypoints(doc, entrypoints_to_defines, start_index):
+def get_entrypoints(doc, entrypoints_to_defines):
"""Extract the entry points from the registry."""
entrypoints = OrderedDict()
name = command.find('./proto/name').text
ret_type = command.find('./proto/type').text
params = [EntrypointParam(
- type = p.find('./type').text,
- name = p.find('./name').text,
- decl = ''.join(p.itertext())
+ type=p.find('./type').text,
+ name=p.find('./name').text,
+ decl=''.join(p.itertext())
) for p in command.findall('./param')]
guard = entrypoints_to_defines.get(name)
# They really need to be unique
"""Maps entry points to extension defines."""
entrypoints_to_defines = {}
+ platform_define = {}
+ for platform in doc.findall('./platforms/platform'):
+ name = platform.attrib['name']
+ define = platform.attrib['protect']
+ platform_define[name] = define
+
for extension in doc.findall('./extensions/extension[@platform]'):
platform = extension.attrib['platform']
- ext = '_KHR'
- if platform.upper() == 'XLIB_XRANDR':
- ext = '_EXT'
- define = 'VK_USE_PLATFORM_' + platform.upper() + ext
+ define = platform_define[platform]
for entrypoint in extension.findall('./require/command'):
fullname = entrypoint.attrib['name']
for filename in args.xml_files:
doc = et.parse(filename)
- entrypoints += get_entrypoints(doc, get_entrypoints_defines(doc),
- start_index=len(entrypoints))
+ entrypoints += get_entrypoints(doc, get_entrypoints_defines(doc))
# Manually add CreateDmaBufImageINTEL for which we don't have an extension
# defined.
device_strmap=device_strmap,
filename=os.path.basename(__file__)))
except Exception:
- # In the even there's an error this imports some helpers from mako
+ # In the event there's an error, this imports some helpers from mako
# to print a useful stack trace and prints it, then exits with
# status 1, if python is run with debug; otherwise it just raises
# the exception