vulkan: write beta extensions into generator scripts.
Updated by: Hyunjun Ko <zzoon@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21806>
This commit is contained in:
@@ -152,6 +152,7 @@ the following in the driver's ``meson.build``, modified as necessary:
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'drv',
|
||||
'--beta', with_vulkan_beta.to_string(),
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
@@ -21,6 +21,7 @@
|
||||
radv_entrypoints_gen_command = [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
]
|
||||
|
||||
radv_entrypoints_gen_command += [
|
||||
|
@@ -25,6 +25,7 @@ v3dv_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'v3dv',
|
||||
'--beta', with_vulkan_beta.to_string(),
|
||||
'--device-prefix', 'ver42',
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
|
@@ -11,6 +11,7 @@ tu_entrypoints = custom_target(
|
||||
'--include', 'adreno_common.xml.h',
|
||||
'--tmpl-prefix', 'tu', '--tmpl-param', 'chip CHIP',
|
||||
'--tmpl-variants', '<A6XX>', '<A7XX>',
|
||||
'--beta', with_vulkan_beta.to_string(),
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
@@ -6,6 +6,7 @@ lvp_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'lvp',
|
||||
'--beta', with_vulkan_beta.to_string(),
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
@@ -28,6 +28,7 @@ pvr_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'pvr',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
@@ -36,6 +36,7 @@ anv_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'anv',
|
||||
'--beta', with_vulkan_beta.to_string(),
|
||||
'--device-prefix', 'gfx9',
|
||||
'--device-prefix', 'gfx11',
|
||||
'--device-prefix', 'gfx12',
|
||||
|
@@ -25,6 +25,7 @@ anv_hasvk_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'anv',
|
||||
'--beta', with_vulkan_beta.to_string(),
|
||||
'--device-prefix', 'gfx7', '--device-prefix', 'gfx75',
|
||||
'--device-prefix', 'gfx8',
|
||||
'--device-prefix', 'doom64',
|
||||
|
@@ -25,7 +25,8 @@ dzn_entrypoints = custom_target(
|
||||
output : ['dzn_entrypoints.h', 'dzn_entrypoints.c'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'dzn'
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'dzn',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
@@ -29,6 +29,7 @@ panvk_entrypoints = custom_target(
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'panvk',
|
||||
'--device-prefix', 'panvk_v6', '--device-prefix', 'panvk_v7',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
@@ -11,6 +11,7 @@ vn_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'vn',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
)
|
||||
|
||||
|
@@ -126,6 +126,7 @@ vk_common_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'vk_common',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
@@ -136,7 +137,8 @@ vk_cmd_queue = custom_target(
|
||||
output : ['vk_cmd_queue.c', 'vk_cmd_queue.h'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_cmd_queue_gen_depend_files,
|
||||
)
|
||||
@@ -149,6 +151,7 @@ vk_cmd_enqueue_entrypoints = custom_target(
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@',
|
||||
'--prefix', 'vk_cmd_enqueue', '--prefix', 'vk_cmd_enqueue_unless_primary',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
@@ -159,7 +162,8 @@ vk_dispatch_trampolines = custom_target(
|
||||
output : ['vk_dispatch_trampolines.c', 'vk_dispatch_trampolines.h'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_dispatch_trampolines_gen_depend_files,
|
||||
)
|
||||
@@ -171,6 +175,7 @@ vk_physical_device_features = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_physical_device_features_gen_depend_files,
|
||||
)
|
||||
|
@@ -404,7 +404,7 @@ class VkObjectType(object):
|
||||
|
||||
|
||||
def parse_xml(enum_factory, ext_factory, struct_factory, bitmask_factory,
|
||||
obj_type_factory, filename):
|
||||
obj_type_factory, filename, beta):
|
||||
"""Parse the XML file. Accumulate results into the factories.
|
||||
|
||||
This parser is a memory efficient iterative XML parser that returns a list
|
||||
@@ -414,7 +414,7 @@ def parse_xml(enum_factory, ext_factory, struct_factory, bitmask_factory,
|
||||
xml = et.parse(filename)
|
||||
api = 'vulkan'
|
||||
|
||||
required_types = get_all_required(xml, 'type', api)
|
||||
required_types = get_all_required(xml, 'type', api, beta)
|
||||
|
||||
for enum_type in xml.findall('./enums[@type="enum"]'):
|
||||
if not filter_api(enum_type, api):
|
||||
@@ -529,6 +529,7 @@ def parse_xml(enum_factory, ext_factory, struct_factory, bitmask_factory,
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
parser.add_argument('--xml', required=True,
|
||||
help='Vulkan API XML files',
|
||||
action='append',
|
||||
@@ -547,7 +548,7 @@ def main():
|
||||
|
||||
for filename in args.xml_files:
|
||||
parse_xml(enum_factory, ext_factory, struct_factory, bitmask_factory,
|
||||
obj_type_factory, filename)
|
||||
obj_type_factory, filename, args.beta)
|
||||
enums = sorted(enum_factory.registry.values(), key=lambda e: e.name)
|
||||
extensions = sorted(ext_factory.registry.values(), key=lambda e: e.name)
|
||||
structs = sorted(struct_factory.registry.values(), key=lambda e: e.name)
|
||||
|
@@ -71,7 +71,8 @@ vk_dispatch_table = custom_target(
|
||||
output : ['vk_dispatch_table.c', 'vk_dispatch_table.h'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
|
||||
'--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_dispatch_table_gen_depend_files,
|
||||
)
|
||||
@@ -82,7 +83,8 @@ vk_enum_to_str = custom_target(
|
||||
output : ['vk_enum_to_str.c', 'vk_enum_to_str.h', 'vk_enum_defines.h'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||
'--outdir', meson.current_build_dir()
|
||||
'--outdir', meson.current_build_dir(),
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
)
|
||||
|
||||
@@ -92,7 +94,8 @@ vk_struct_type_cast = custom_target(
|
||||
output : ['vk_struct_type_cast.h'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||
'--outdir', meson.current_build_dir()
|
||||
'--outdir', meson.current_build_dir(),
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
)
|
||||
|
||||
|
@@ -194,6 +194,9 @@ TEMPLATE_C = Template(COPYRIGHT + """
|
||||
|
||||
#define VK_PROTOTYPES
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
#include <vulkan/vulkan_beta.h>
|
||||
#endif
|
||||
|
||||
#include "vk_alloc.h"
|
||||
#include "vk_cmd_enqueue_entrypoints.h"
|
||||
@@ -531,11 +534,11 @@ def get_types_defines(doc):
|
||||
|
||||
return types_to_defines
|
||||
|
||||
def get_types(doc, api, types_to_defines):
|
||||
def get_types(doc, beta, api, types_to_defines):
|
||||
"""Extract the types from the registry."""
|
||||
types = {}
|
||||
|
||||
required = get_all_required(doc, 'type', api)
|
||||
required = get_all_required(doc, 'type', api, beta)
|
||||
|
||||
for _type in doc.findall('./types/type'):
|
||||
if _type.attrib.get('category') != 'struct':
|
||||
@@ -582,12 +585,12 @@ def get_types(doc, api, types_to_defines):
|
||||
|
||||
return types
|
||||
|
||||
def get_types_from_xml(xml_files, api='vulkan'):
|
||||
def get_types_from_xml(xml_files, beta, api='vulkan'):
|
||||
types = {}
|
||||
|
||||
for filename in xml_files:
|
||||
doc = et.parse(filename)
|
||||
types.update(get_types(doc, api, get_types_defines(doc)))
|
||||
types.update(get_types(doc, beta, api, get_types_defines(doc)))
|
||||
|
||||
return types
|
||||
|
||||
@@ -595,18 +598,19 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out-c', required=True, help='Output C file.')
|
||||
parser.add_argument('--out-h', required=True, help='Output H file.')
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
parser.add_argument('--xml',
|
||||
help='Vulkan API XML file.',
|
||||
required=True, action='append', dest='xml_files')
|
||||
args = parser.parse_args()
|
||||
|
||||
commands = []
|
||||
for e in get_entrypoints_from_xml(args.xml_files):
|
||||
for e in get_entrypoints_from_xml(args.xml_files, args.beta):
|
||||
if e.name.startswith('Cmd') and \
|
||||
not e.alias:
|
||||
commands.append(e)
|
||||
|
||||
types = get_types_from_xml(args.xml_files)
|
||||
types = get_types_from_xml(args.xml_files, args.beta)
|
||||
|
||||
assert os.path.dirname(args.out_c) == os.path.dirname(args.out_h)
|
||||
|
||||
|
@@ -673,6 +673,7 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out-c', help='Output C file.')
|
||||
parser.add_argument('--out-h', help='Output H file.')
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
parser.add_argument('--xml',
|
||||
help='Vulkan API XML file.',
|
||||
required=True,
|
||||
@@ -680,7 +681,7 @@ def main():
|
||||
dest='xml_files')
|
||||
args = parser.parse_args()
|
||||
|
||||
entrypoints = get_entrypoints_from_xml(args.xml_files)
|
||||
entrypoints = get_entrypoints_from_xml(args.xml_files, args.beta)
|
||||
|
||||
device_entrypoints = []
|
||||
physical_device_entrypoints = []
|
||||
|
@@ -155,6 +155,7 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out-c', help='Output C file.')
|
||||
parser.add_argument('--out-h', help='Output H file.')
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
parser.add_argument('--xml',
|
||||
help='Vulkan API XML file.',
|
||||
required=True,
|
||||
@@ -162,7 +163,7 @@ def main():
|
||||
dest='xml_files')
|
||||
args = parser.parse_args()
|
||||
|
||||
entrypoints = get_entrypoints_from_xml(args.xml_files)
|
||||
entrypoints = get_entrypoints_from_xml(args.xml_files, args.beta)
|
||||
|
||||
# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
|
||||
# per entry point.
|
||||
|
@@ -98,11 +98,11 @@ class EntrypointAlias(EntrypointBase):
|
||||
def call_params(self):
|
||||
return self.alias.call_params()
|
||||
|
||||
def get_entrypoints(doc, api):
|
||||
def get_entrypoints(doc, api, beta):
|
||||
"""Extract the entry points from the registry."""
|
||||
entrypoints = OrderedDict()
|
||||
|
||||
required = get_all_required(doc, 'command', api)
|
||||
required = get_all_required(doc, 'command', api, beta)
|
||||
|
||||
for command in doc.findall('./commands/command'):
|
||||
if not filter_api(command, api):
|
||||
@@ -137,11 +137,11 @@ def get_entrypoints(doc, api):
|
||||
|
||||
return entrypoints.values()
|
||||
|
||||
def get_entrypoints_from_xml(xml_files, api='vulkan'):
|
||||
def get_entrypoints_from_xml(xml_files, beta, api='vulkan'):
|
||||
entrypoints = []
|
||||
|
||||
for filename in xml_files:
|
||||
doc = et.parse(filename)
|
||||
entrypoints += get_entrypoints(doc, api)
|
||||
entrypoints += get_entrypoints(doc, api, beta)
|
||||
|
||||
return entrypoints
|
||||
|
@@ -223,6 +223,7 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out-c', required=True, help='Output C file.')
|
||||
parser.add_argument('--out-h', required=True, help='Output H file.')
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
parser.add_argument('--xml',
|
||||
help='Vulkan API XML file.',
|
||||
required=True, action='append', dest='xml_files')
|
||||
@@ -257,7 +258,7 @@ def main():
|
||||
tmpl_variants_sanitized = [
|
||||
''.join(filter(str.isalnum, v)).lower() for v in args.tmpl_variants]
|
||||
|
||||
entrypoints = get_entrypoints_from_xml(args.xml_files)
|
||||
entrypoints = get_entrypoints_from_xml(args.xml_files, args.beta)
|
||||
|
||||
device_entrypoints = []
|
||||
physical_device_entrypoints = []
|
||||
|
@@ -175,7 +175,7 @@ def filter_api(elem, api):
|
||||
|
||||
return api in elem.attrib['api'].split(',')
|
||||
|
||||
def get_all_required(xml, thing, api):
|
||||
def get_all_required(xml, thing, api, beta):
|
||||
things = {}
|
||||
for feature in xml.findall('./feature'):
|
||||
if not filter_api(feature, api):
|
||||
@@ -192,7 +192,7 @@ def get_all_required(xml, thing, api):
|
||||
if api not in ext.supported:
|
||||
continue
|
||||
|
||||
if ext.provisional:
|
||||
if beta != 'true' and ext.provisional:
|
||||
continue
|
||||
|
||||
for require in extension.findall('./require'):
|
||||
|
@@ -350,10 +350,10 @@ def filter_api(elem, api):
|
||||
|
||||
return api in elem.attrib['api'].split(',')
|
||||
|
||||
def get_feature_structs(doc, api):
|
||||
def get_feature_structs(doc, api, beta):
|
||||
feature_structs = OrderedDict()
|
||||
|
||||
required = get_all_required(doc, 'type', api)
|
||||
required = get_all_required(doc, 'type', api, beta)
|
||||
|
||||
# parse all struct types where structextends VkPhysicalDeviceFeatures2
|
||||
for _type in doc.findall('./types/type[@category="struct"]'):
|
||||
@@ -388,7 +388,7 @@ def get_feature_structs(doc, api):
|
||||
|
||||
return feature_structs.values()
|
||||
|
||||
def get_feature_structs_from_xml(xml_files, api='vulkan'):
|
||||
def get_feature_structs_from_xml(xml_files, beta, api='vulkan'):
|
||||
diagnostics = []
|
||||
|
||||
pdev_features = None
|
||||
@@ -396,7 +396,7 @@ def get_feature_structs_from_xml(xml_files, api='vulkan'):
|
||||
|
||||
for filename in xml_files:
|
||||
doc = et.parse(filename)
|
||||
feature_structs += get_feature_structs(doc, api)
|
||||
feature_structs += get_feature_structs(doc, api, beta)
|
||||
if not pdev_features:
|
||||
pdev_features = get_pdev_features(doc)
|
||||
|
||||
@@ -432,12 +432,13 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out-c', required=True, help='Output C file.')
|
||||
parser.add_argument('--out-h', required=True, help='Output H file.')
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
parser.add_argument('--xml',
|
||||
help='Vulkan API XML file.',
|
||||
required=True, action='append', dest='xml_files')
|
||||
args = parser.parse_args()
|
||||
|
||||
pdev_features, feature_structs, all_flags = get_feature_structs_from_xml(args.xml_files)
|
||||
pdev_features, feature_structs, all_flags = get_feature_structs_from_xml(args.xml_files, args.beta)
|
||||
|
||||
environment = {
|
||||
'filename': os.path.basename(__file__),
|
||||
|
@@ -60,11 +60,11 @@ def struct_get_stype(xml_node):
|
||||
return None
|
||||
|
||||
|
||||
def parse_xml(filename, structs):
|
||||
def parse_xml(filename, structs, beta):
|
||||
xml = et.parse(filename)
|
||||
api = 'vulkan'
|
||||
|
||||
required_types = get_all_required(xml, 'type', api)
|
||||
required_types = get_all_required(xml, 'type', api, beta)
|
||||
|
||||
for struct_type in xml.findall('./types/type[@category="struct"]'):
|
||||
if not filter_api(struct_type, api):
|
||||
@@ -93,13 +93,14 @@ def main():
|
||||
parser.add_argument('--outdir',
|
||||
help='Directory to put the generated files in',
|
||||
required=True)
|
||||
parser.add_argument('--beta', required=True, help='Enable beta extensions.')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
structs = []
|
||||
|
||||
for filename in args.xml_files:
|
||||
parse_xml(filename, structs)
|
||||
parse_xml(filename, structs, args.beta)
|
||||
|
||||
structs = sorted(structs, key=lambda s: s.name)
|
||||
|
||||
|
@@ -53,6 +53,7 @@ wsi_entrypoints = custom_target(
|
||||
command : [
|
||||
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
|
||||
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'wsi',
|
||||
'--beta', with_vulkan_beta.to_string()
|
||||
],
|
||||
depend_files : vk_entrypoints_gen_depend_files,
|
||||
)
|
||||
|
Reference in New Issue
Block a user