This allows us better introspection into extensions.
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
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 \
$(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 += \
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"
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)
{
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)
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,
'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))
#include <vulkan/vk_android_native_buffer.h>
#include "anv_entrypoints.h"
+#include "anv_extensions.h"
#include "isl/isl.h"
#include "common/gen_debug.h"
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@',
],
)
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,
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,
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,