X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fintel%2Fvulkan%2Fanv_entrypoints_gen.py;h=23ade58ae19abda0b5bef2c2e5071465691a0bfb;hb=c9bebae2877e55cdcd94f9f9f3f6805238caeb28;hp=25a532fd706766fac9a4ec1ba448a6a2192b76d2;hpb=00bb42105d6edf6e432c0e3712ffb9d3eb0aece4;p=mesa.git diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py index 25a532fd706..23ade58ae19 100644 --- a/src/intel/vulkan/anv_entrypoints_gen.py +++ b/src/intel/vulkan/anv_entrypoints_gen.py @@ -45,6 +45,7 @@ LAYERS = [ 'gen9', 'gen10', 'gen11', + 'gen12', ] TEMPLATE_H = Template("""\ @@ -92,7 +93,6 @@ extern const struct anv_instance_dispatch_table anv_instance_dispatch_table; %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: @@ -227,6 +227,19 @@ ${strmap(device_strmap, 'device')} * 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: @@ -247,7 +260,26 @@ const struct anv_instance_dispatch_table anv_instance_dispatch_table = { % 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 @@ -267,49 +299,6 @@ const struct anv_instance_dispatch_table anv_instance_dispatch_table = { % 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. * @@ -395,6 +384,9 @@ anv_resolve_device_entrypoint(const struct gen_device_info *devinfo, uint32_t in { 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; @@ -466,7 +458,7 @@ class StringIntMap(object): 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): @@ -508,7 +500,7 @@ class EntrypointBase(object): 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 @@ -538,7 +530,7 @@ class EntrypointAlias(EntrypointBase): 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() @@ -551,9 +543,9 @@ def get_entrypoints(doc, entrypoints_to_defines, start_index): 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 @@ -594,12 +586,15 @@ def get_entrypoints_defines(doc): """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'] @@ -623,8 +618,7 @@ def main(): 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. @@ -674,7 +668,7 @@ def main(): 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