From: Jason Ekstrand Date: Tue, 16 Jan 2018 22:23:29 +0000 (-0800) Subject: anv/extensions: Generate a header file with extension tables X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dd088d4bec74f37ffe4cd02626a6a8af93fdebac;p=mesa.git anv/extensions: Generate a header file with extension tables This allows us better introspection into extensions. Reviewed-by: Samuel Iglesias Gonsálvez --- diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources index 7f8379c66a1..9595bf42582 100644 --- a/src/intel/Makefile.sources +++ b/src/intel/Makefile.sources @@ -249,7 +249,8 @@ VULKAN_GEM_STUB_FILES := \ VULKAN_GENERATED_FILES := \ vulkan/anv_entrypoints.c \ vulkan/anv_entrypoints.h \ - vulkan/anv_extensions.c + vulkan/anv_extensions.c \ + vulkan/anv_extensions.h VULKAN_GENX_FILES := \ vulkan/genX_blorp_exec.c \ diff --git a/src/intel/Makefile.vulkan.am b/src/intel/Makefile.vulkan.am index 3e385ffd033..7823b608804 100644 --- a/src/intel/Makefile.vulkan.am +++ b/src/intel/Makefile.vulkan.am @@ -44,7 +44,17 @@ vulkan/anv_extensions.c: vulkan/anv_extensions_gen.py \ $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_extensions_gen.py \ --xml $(vulkan_api_xml) \ --xml $(vk_android_native_buffer_xml) \ - --out $@ + --out-c $@ + +vulkan/anv_extensions.h: vulkan/anv_extensions_gen.py \ + vulkan/anv_extensions.py \ + $(vulkan_api_xml) \ + $(vk_android_native_buffer_xml) + $(MKDIR_GEN) + $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_extensions_gen.py \ + --xml $(vulkan_api_xml) \ + --xml $(vk_android_native_buffer_xml) \ + --out-h $@ BUILT_SOURCES += $(VULKAN_GENERATED_FILES) CLEANFILES += \ diff --git a/src/intel/vulkan/anv_extensions_gen.py b/src/intel/vulkan/anv_extensions_gen.py index a1e868855bd..dadf20a687e 100644 --- a/src/intel/vulkan/anv_extensions_gen.py +++ b/src/intel/vulkan/anv_extensions_gen.py @@ -58,7 +58,48 @@ def _init_exts_from_xml(xml): ext = ext_name_map[ext_name] ext.type = ext_elem.attrib['type'] -_TEMPLATE = Template(COPYRIGHT + """ +_TEMPLATE_H = Template(COPYRIGHT + """ + +#ifndef ANV_EXTENSIONS_H +#define ANV_EXTENSIONS_H + +#include "stdbool.h" + +#define ANV_INSTANCE_EXTENSION_COUNT ${len(instance_extensions)} + +extern const VkExtensionProperties anv_instance_extensions[]; + +struct anv_instance_extension_table { + union { + bool extensions[ANV_INSTANCE_EXTENSION_COUNT]; + struct { +%for ext in instance_extensions: + bool ${ext.name[3:]}; +%endfor + }; + }; +}; + + +#define ANV_DEVICE_EXTENSION_COUNT ${len(device_extensions)} + +extern const VkExtensionProperties anv_device_extensions[]; + +struct anv_device_extension_table { + union { + bool extensions[ANV_DEVICE_EXTENSION_COUNT]; + struct { +%for ext in device_extensions: + bool ${ext.name[3:]}; +%endfor + }; + }; +}; + +#endif /* ANV_EXTENSIONS_H */ +""") + +_TEMPLATE_C = Template(COPYRIGHT + """ #include "anv_private.h" #include "vk_util.h" @@ -85,6 +126,12 @@ _TEMPLATE = Template(COPYRIGHT + """ VK_USE_PLATFORM_XCB_KHR || \\ VK_USE_PLATFORM_XLIB_KHR) +const VkExtensionProperties anv_instance_extensions[ANV_INSTANCE_EXTENSION_COUNT] = { +%for ext in instance_extensions: + {"${ext.name}", ${ext.ext_version}}, +%endfor +}; + bool anv_instance_extension_supported(const char *name) { @@ -122,6 +169,12 @@ anv_physical_device_api_version(struct anv_physical_device *dev) return ${MAX_API_VERSION.c_vk_version()}; } +const VkExtensionProperties anv_device_extensions[ANV_DEVICE_EXTENSION_COUNT] = { +%for ext in device_extensions: + {"${ext.name}", ${ext.ext_version}}, +%endfor +}; + bool anv_physical_device_extension_supported(struct anv_physical_device *device, const char *name) @@ -160,7 +213,8 @@ VkResult anv_EnumerateDeviceExtensionProperties( if __name__ == '__main__': parser = argparse.ArgumentParser() - parser.add_argument('--out', help='Output C file.', required=True) + parser.add_argument('--out-c', help='Output C file.') + parser.add_argument('--out-h', help='Output H file.') parser.add_argument('--xml', help='Vulkan API XML file.', required=True, @@ -180,5 +234,10 @@ if __name__ == '__main__': 'device_extensions': [e for e in EXTENSIONS if e.type == 'device'], } - with open(args.out, 'w') as f: - f.write(_TEMPLATE.render(**template_env)) + if args.out_h: + with open(args.out_h, 'w') as f: + f.write(_TEMPLATE_H.render(**template_env)) + + if args.out_c: + with open(args.out_c, 'w') as f: + f.write(_TEMPLATE_C.render(**template_env)) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index ed711e9434b..d3953f10420 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -72,6 +72,7 @@ struct gen_l3_config; #include #include "anv_entrypoints.h" +#include "anv_extensions.h" #include "isl/isl.h" #include "common/gen_debug.h" diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index cbbd5677dcc..69ec26e19b6 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -37,7 +37,18 @@ anv_extensions_c = custom_target( output : 'anv_extensions.c', command : [ prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', - '--out', '@OUTPUT@', + '--out-c', '@OUTPUT@', + ], +) + +anv_extensions_h = custom_target( + 'anv_extensions.h', + input : ['anv_extensions_gen.py', vk_api_xml, vk_android_native_buffer_xml, + 'anv_extensions.py'], + output : 'anv_extensions.h', + command : [ + prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', + '--out-h', '@OUTPUT@', ], ) @@ -162,7 +173,7 @@ endif libanv_common = static_library( 'anv_common', - [libanv_files, anv_entrypoints, anv_extensions_c], + [libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h], include_directories : [ inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util, inc_vulkan_wsi, @@ -173,7 +184,7 @@ libanv_common = static_library( libvulkan_intel = shared_library( 'vulkan_intel', - [files('anv_gem.c'), block_entrypoints], + [files('anv_gem.c'), block_entrypoints, anv_extensions_h], include_directories : [ inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util, inc_vulkan_wsi, @@ -194,7 +205,7 @@ libvulkan_intel = shared_library( if with_tests libvulkan_intel_test = static_library( 'vulkan_intel_test', - [files('anv_gem_stubs.c'), block_entrypoints], + [files('anv_gem_stubs.c'), block_entrypoints, anv_extensions_h], include_directories : [ inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util, inc_vulkan_wsi,