mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 13:40:16 +01:00
anv/extensions: Generate a header file with extension tables
This allows us better introspection into extensions. Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
This commit is contained in:
parent
ffb10bfd8e
commit
dd088d4bec
5 changed files with 92 additions and 10 deletions
|
|
@ -249,7 +249,8 @@ VULKAN_GEM_STUB_FILES := \
|
||||||
VULKAN_GENERATED_FILES := \
|
VULKAN_GENERATED_FILES := \
|
||||||
vulkan/anv_entrypoints.c \
|
vulkan/anv_entrypoints.c \
|
||||||
vulkan/anv_entrypoints.h \
|
vulkan/anv_entrypoints.h \
|
||||||
vulkan/anv_extensions.c
|
vulkan/anv_extensions.c \
|
||||||
|
vulkan/anv_extensions.h
|
||||||
|
|
||||||
VULKAN_GENX_FILES := \
|
VULKAN_GENX_FILES := \
|
||||||
vulkan/genX_blorp_exec.c \
|
vulkan/genX_blorp_exec.c \
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,17 @@ vulkan/anv_extensions.c: vulkan/anv_extensions_gen.py \
|
||||||
$(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_extensions_gen.py \
|
$(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_extensions_gen.py \
|
||||||
--xml $(vulkan_api_xml) \
|
--xml $(vulkan_api_xml) \
|
||||||
--xml $(vk_android_native_buffer_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)
|
BUILT_SOURCES += $(VULKAN_GENERATED_FILES)
|
||||||
CLEANFILES += \
|
CLEANFILES += \
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,48 @@ def _init_exts_from_xml(xml):
|
||||||
ext = ext_name_map[ext_name]
|
ext = ext_name_map[ext_name]
|
||||||
ext.type = ext_elem.attrib['type']
|
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 "anv_private.h"
|
||||||
|
|
||||||
#include "vk_util.h"
|
#include "vk_util.h"
|
||||||
|
|
@ -85,6 +126,12 @@ _TEMPLATE = Template(COPYRIGHT + """
|
||||||
VK_USE_PLATFORM_XCB_KHR || \\
|
VK_USE_PLATFORM_XCB_KHR || \\
|
||||||
VK_USE_PLATFORM_XLIB_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
|
bool
|
||||||
anv_instance_extension_supported(const char *name)
|
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()};
|
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
|
bool
|
||||||
anv_physical_device_extension_supported(struct anv_physical_device *device,
|
anv_physical_device_extension_supported(struct anv_physical_device *device,
|
||||||
const char *name)
|
const char *name)
|
||||||
|
|
@ -160,7 +213,8 @@ VkResult anv_EnumerateDeviceExtensionProperties(
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
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',
|
parser.add_argument('--xml',
|
||||||
help='Vulkan API XML file.',
|
help='Vulkan API XML file.',
|
||||||
required=True,
|
required=True,
|
||||||
|
|
@ -180,5 +234,10 @@ if __name__ == '__main__':
|
||||||
'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
|
'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(args.out, 'w') as f:
|
if args.out_h:
|
||||||
f.write(_TEMPLATE.render(**template_env))
|
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))
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ struct gen_l3_config;
|
||||||
#include <vulkan/vk_android_native_buffer.h>
|
#include <vulkan/vk_android_native_buffer.h>
|
||||||
|
|
||||||
#include "anv_entrypoints.h"
|
#include "anv_entrypoints.h"
|
||||||
|
#include "anv_extensions.h"
|
||||||
#include "isl/isl.h"
|
#include "isl/isl.h"
|
||||||
|
|
||||||
#include "common/gen_debug.h"
|
#include "common/gen_debug.h"
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,18 @@ anv_extensions_c = custom_target(
|
||||||
output : 'anv_extensions.c',
|
output : 'anv_extensions.c',
|
||||||
command : [
|
command : [
|
||||||
prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@',
|
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(
|
libanv_common = static_library(
|
||||||
'anv_common',
|
'anv_common',
|
||||||
[libanv_files, anv_entrypoints, anv_extensions_c],
|
[libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h],
|
||||||
include_directories : [
|
include_directories : [
|
||||||
inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
|
inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
|
||||||
inc_vulkan_wsi,
|
inc_vulkan_wsi,
|
||||||
|
|
@ -173,7 +184,7 @@ libanv_common = static_library(
|
||||||
|
|
||||||
libvulkan_intel = shared_library(
|
libvulkan_intel = shared_library(
|
||||||
'vulkan_intel',
|
'vulkan_intel',
|
||||||
[files('anv_gem.c'), block_entrypoints],
|
[files('anv_gem.c'), block_entrypoints, anv_extensions_h],
|
||||||
include_directories : [
|
include_directories : [
|
||||||
inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
|
inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
|
||||||
inc_vulkan_wsi,
|
inc_vulkan_wsi,
|
||||||
|
|
@ -194,7 +205,7 @@ libvulkan_intel = shared_library(
|
||||||
if with_tests
|
if with_tests
|
||||||
libvulkan_intel_test = static_library(
|
libvulkan_intel_test = static_library(
|
||||||
'vulkan_intel_test',
|
'vulkan_intel_test',
|
||||||
[files('anv_gem_stubs.c'), block_entrypoints],
|
[files('anv_gem_stubs.c'), block_entrypoints, anv_extensions_h],
|
||||||
include_directories : [
|
include_directories : [
|
||||||
inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
|
inc_common, inc_intel, inc_compiler, inc_drm_uapi, inc_vulkan_util,
|
||||||
inc_vulkan_wsi,
|
inc_vulkan_wsi,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue