vulkan: put generated defines into their own header

v2: Put vk_enum_defines.h in the list of generated files

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
This commit is contained in:
Lionel Landwerlin 2021-09-22 10:52:43 +03:00 committed by Marge Bot
parent 7d388c8d09
commit 2ff3fd4773
3 changed files with 32 additions and 6 deletions

View file

@ -23,6 +23,7 @@
#include "anv_private.h"
#include "drm-uapi/drm_fourcc.h"
#include "vk_enum_defines.h"
#include "vk_enum_to_str.h"
#include "vk_format.h"
#include "vk_util.h"

View file

@ -136,10 +136,6 @@ H_TEMPLATE = Template(textwrap.dedent(u"""\
extern "C" {
#endif
% for ext in extensions:
#define _${ext.name}_number (${ext.number})
% endfor
% for enum in enums:
% if enum.guard:
#ifdef ${enum.guard}
@ -161,6 +157,34 @@ H_TEMPLATE = Template(textwrap.dedent(u"""\
#endif"""))
H_DEFINE_TEMPLATE = Template(textwrap.dedent(u"""\
/* Autogenerated file -- do not edit
* generated by ${file}
*
${copyright}
*/
#ifndef MESA_VK_ENUM_DEFINES_H
#define MESA_VK_ENUM_DEFINES_H
#include <vulkan/vulkan.h>
#include <vulkan/vk_android_native_buffer.h>
#ifdef __cplusplus
extern "C" {
#endif
% for ext in extensions:
#define _${ext.name}_number (${ext.number})
% endfor
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif"""))
class NamedFactory(object):
"""Factory for creating enums."""
@ -375,7 +399,8 @@ def main():
object_types = sorted(obj_type_factory.registry.values(), key=lambda e: e.name)
for template, file_ in [(C_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.c')),
(H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h'))]:
(H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h')),
(H_DEFINE_TEMPLATE, os.path.join(args.outdir, 'vk_enum_defines.h'))]:
with open(file_, 'w') as f:
f.write(template.render(
file=os.path.basename(__file__),

View file

@ -111,7 +111,7 @@ vk_dispatch_table = custom_target(
vk_enum_to_str = custom_target(
'vk_enum_to_str',
input : ['gen_enum_to_str.py', vk_api_xml],
output : ['vk_enum_to_str.c', 'vk_enum_to_str.h'],
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()