[Mesa-dev] [PATCH 06/13] anv: convert header generation in anv_entrypoints_gen.py to mako
Dylan Baker
dylan at pnwbakers.com
Wed Feb 22 23:15:38 UTC 2017
This produces an identical file except for whitespace.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
src/intel/vulkan/anv_entrypoints_gen.py | 75 ++++++++++++++++++---------------
1 file changed, 41 insertions(+), 34 deletions(-)
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7b5589e5..1b15b13b2f 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -27,6 +27,8 @@ import sys
import textwrap
import xml.etree.ElementTree as et
+from mako.template import Template
+
VK_XML = os.path.join(
os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
@@ -49,6 +51,44 @@ SUPPORTED_EXTENSIONS = [
# function and a power-of-two size table. The prime numbers are determined
# experimentally.
+TEMPLATE_H = Template(textwrap.dedent("""\
+ /* This file generated from vk_gen.py, don't edit directly. */
+
+ struct anv_dispatch_table {
+ union {
+ void *entrypoints[${len(entrypoints)}];
+ struct {
+ % for _, name, _, _, _, guard in entrypoints:
+ % if guard is not None:
+ #ifdef ${guard}
+ PFN_vk${name} ${name};
+ #else
+ void *${name};
+ # endif
+ % else:
+ PFN_vk${name} ${name};
+ % endif
+ % endfor
+ };
+ };
+ };
+
+ void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+ % for type_, name, args, num, h, guard in entrypoints:
+ % if guard is not None:
+ #ifdef ${guard}
+ % endif
+ ${type_} anv_${name}(${args});
+ ${type_} gen7_${name}(${args});
+ ${type_} gen75_${name}(${args});
+ ${type_} gen8_${name}(${args});
+ ${type_} gen9_${name}(${args});
+ % if guard is not None:
+ #endif // ${guard}
+ % endif
+ % endfor
+ """))
+
NONE = 0xffff
HASH_SIZE = 256
U32_MASK = 2**32 - 1
@@ -141,39 +181,6 @@ def get_entrypoints_defines(doc):
return entrypoints_to_defines
-def gen_header(entrypoints):
- print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
- print "struct anv_dispatch_table {"
- print " union {"
- print " void *entrypoints[%d];" % len(entrypoints)
- print " struct {"
-
- for type, name, args, num, h, guard in entrypoints:
- if guard is not None:
- print "#ifdef {0}".format(guard)
- print " PFN_vk{0} {0};".format(name)
- print "#else"
- print " void *{0};".format(name)
- print "#endif"
- else:
- print " PFN_vk{0} {0};".format(name)
- print " };\n"
- print " };\n"
- print "};\n"
-
- print "void anv_set_dispatch_devinfo(const struct gen_device_info *info);\n"
-
- for type, name, args, num, h, guard in entrypoints:
- print_guard_start(guard)
- print "%s anv_%s(%s);" % (type, name, args)
- print "%s gen7_%s(%s);" % (type, name, args)
- print "%s gen75_%s(%s);" % (type, name, args)
- print "%s gen8_%s(%s);" % (type, name, args)
- print "%s gen9_%s(%s);" % (type, name, args)
- print_guard_end(guard)
-
-
def gen_code(entrypoints):
print textwrap.dedent("""\
/*
@@ -376,7 +383,7 @@ def main():
# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
# per entry point.
if opt_header:
- gen_header(entrypoints)
+ print TEMPLATE_H.render(entrypoints=entrypoints)
else:
gen_code(entrypoints)
--
2.11.1
More information about the mesa-dev
mailing list