Mesa (main): vulkan: put generated defines into their own header
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 6 20:51:01 UTC 2021
Module: Mesa
Branch: main
Commit: 2ff3fd4773d0ed6708a205add14a5cc5ecf45d34
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ff3fd4773d0ed6708a205add14a5cc5ecf45d34
Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date: Wed Sep 22 10:52:43 2021 +0300
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 at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
---
src/intel/vulkan/anv_formats.c | 1 +
src/vulkan/util/gen_enum_to_str.py | 35 ++++++++++++++++++++++++++++++-----
src/vulkan/util/meson.build | 2 +-
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 91c379c931b..77530c60a1b 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -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"
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index 6dfcfda81ca..a7108fe8690 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -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__),
diff --git a/src/vulkan/util/meson.build b/src/vulkan/util/meson.build
index 34e53d6a04c..4f67b38b181 100644
--- a/src/vulkan/util/meson.build
+++ b/src/vulkan/util/meson.build
@@ -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()
More information about the mesa-commit
mailing list