X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Famd%2Fvulkan%2Fradv_entrypoints_gen.py;h=b64f2d93e8ac40f34ea162e84437b20c40b5a4af;hb=c179ded9cb1bc3e42b887c1d3362c86befc3bbcc;hp=a2011429869317ada25b94afec92535a17b495aa;hpb=4fdce205dd1f5ca42c6e45ff7b0b8c2f870638ba;p=mesa.git diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py index a2011429869..b64f2d93e8a 100644 --- a/src/amd/vulkan/radv_entrypoints_gen.py +++ b/src/amd/vulkan/radv_entrypoints_gen.py @@ -136,7 +136,7 @@ static const struct string_map_entry string_map_entries[] = { /* Hash table stats: * size ${len(strmap.sorted_strings)} entries * collisions entries: -% for i in xrange(10): +% for i in range(10): * ${i}${'+' if i == 9 else ' '} ${strmap.collisions[i]} % endfor */ @@ -227,6 +227,35 @@ radv_entrypoint_is_enabled(int index, uint32_t core_version, } } +static bool +radv_entrypoint_is_enabled_physical_device(int index, uint32_t core_version, + const struct radv_instance_extension_table *instance) +{ + switch (index) { +% for e in entrypoints: + %if e.physical_device_command: + case ${e.num}: + % if e.core_version: + return instance && ${e.core_version.c_vk_version()} <= core_version; + % elif e.extensions: + % for ext in e.extensions: + % if ext.type == 'instance': + if (instance && instance->${ext.name[3:]}) return true; + % else: + return true; + % endif + %endfor + return false; + % else: + return instance; + % endif + %endif +% endfor + default: + return false; + } +} + static int radv_lookup_entrypoint(const char *name) { @@ -274,7 +303,20 @@ radv_lookup_entrypoint_checked(const char *name, if (index < 0 || !radv_entrypoint_is_enabled(index, core_version, instance, device)) return NULL; return radv_resolve_entrypoint(index); -}""", output_encoding='utf-8') +} + +void * +radv_lookup_physical_device_entrypoint_checked(const char *name, + uint32_t core_version, + const struct radv_instance_extension_table *instance) +{ + int index = radv_lookup_entrypoint(name); + if (index < 0 || !radv_entrypoint_is_enabled_physical_device(index, core_version, instance)) + return NULL; + return radv_resolve_entrypoint(index); +} + +""", output_encoding='utf-8') U32_MASK = 2**32 - 1 @@ -353,6 +395,7 @@ class Entrypoint(EntrypointBase): self.params = params self.guard = guard self.device_command = len(params) > 0 and (params[0].type == 'VkDevice' or params[0].type == 'VkQueue' or params[0].type == 'VkCommandBuffer') + self.physical_device_command = len(params) > 0 and params[0].type == 'VkPhysicalDevice' def prefixed_name(self, prefix): assert self.name.startswith('vk') @@ -369,6 +412,7 @@ class EntrypointAlias(EntrypointBase): super(EntrypointAlias, self).__init__(name) self.alias = entrypoint self.device_command = entrypoint.device_command + self.physical_device_command = entrypoint.physical_device_command def prefixed_name(self, prefix): return self.alias.prefixed_name(prefix) @@ -413,9 +457,6 @@ def get_entrypoints(doc, entrypoints_to_defines, start_index): if ext_name not in supported_exts: continue - if extension.attrib['supported'] != 'vulkan': - continue - ext = supported_exts[ext_name] ext.type = extension.attrib['type'] @@ -433,7 +474,7 @@ def get_entrypoints(doc, entrypoints_to_defines, start_index): e_clone.name = e.name entrypoints[e.name] = e_clone - return [e for e in entrypoints.itervalues() if e.enabled] + return [e for e in entrypoints.values() if e.enabled] def get_entrypoints_defines(doc): @@ -447,9 +488,15 @@ def get_entrypoints_defines(doc): fullname = entrypoint.attrib['name'] entrypoints_to_defines[fullname] = define + 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'] - define = 'VK_USE_PLATFORM_' + platform.upper() + '_KHR' + define = platform_define[platform] for entrypoint in extension.findall('./require/command'): fullname = entrypoint.attrib['name']