This is identical, except for 240 new entries that weren't generated. I believe this is a bug in the current implementation because the mesa XML is wrong (surprise!), namely that it lacks metadata for a number of functions that take arrays about the length of those arrays. --- src/mapi/glapi/gen/Makefile.am | 11 ++- src/mapi/glapi/gen/gl_marshal_h.py | 104 +++++++++++++++++++---------- src/mapi/glapi/gen/meson.build | 10 ++- src/mapi/glapi/meson.build | 2 + src/mesa/main/meson.build | 11 +-- 5 files changed, 97 insertions(+), 41 deletions(-)
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 2e37060da95..d2c5eb71e8d 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -239,6 +239,13 @@ COMMON = $(API_XML) \ COMMON_GLX = $(COMMON) glX_API.xml glX_XML.py glX_proto_common.py PYTHON_GEN = $(AM_V_GEN)$(PYTHON) $(PYTHON_FLAGS) +COMMON_NEW = \ + ../registry/gl.xml \ + helpers.py \ + khr_xml.py \ + mesa_data.py \ + templates/copyright.mako \ + templates/helpers.mako ###################################################################### @@ -307,8 +314,8 @@ $(MESA_DIR)/main/api_exec.c: gl_genexec.py apiexec.py $(COMMON) $(MESA_DIR)/main/marshal_generated.c: gl_marshal.py marshal_XML.py $(COMMON) $(PYTHON_GEN) $(srcdir)/gl_marshal.py -f $(srcdir)/gl_and_es_API.xml > $@ -$(MESA_DIR)/main/marshal_generated.h: gl_marshal_h.py marshal_XML.py $(COMMON) - $(PYTHON_GEN) $(srcdir)/gl_marshal_h.py -f $(srcdir)/gl_and_es_API.xml > $@ +$(MESA_DIR)/main/marshal_generated.h: gl_marshal_h.py $(COMMON_NEW) + $(PYTHON_GEN) $(srcdir)/gl_marshal_h.py $(srcdir)/../registry/gl.xml $(srcdir)/templates $@ $(MESA_DIR)/main/dispatch.h: gl_table.py $(COMMON) $(PYTHON_GEN) $(srcdir)/gl_table.py -f $(srcdir)/gl_and_es_API.xml -m remap_table > $@ diff --git a/src/mapi/glapi/gen/gl_marshal_h.py b/src/mapi/glapi/gen/gl_marshal_h.py index 619754e05c6..abc6afc4cdf 100644 --- a/src/mapi/glapi/gen/gl_marshal_h.py +++ b/src/mapi/glapi/gen/gl_marshal_h.py @@ -21,60 +21,96 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -from __future__ import print_function +from __future__ import absolute_import, division, print_function, unicode_literals import argparse +import io +import os +import xml.etree.cElementTree as et -import gl_XML -import license -import marshal_XML -import sys +from mako.lookup import TemplateLookup +from mesa_data import ExecType, MarshalType +import khr_xml -header = """ -#ifndef MARSHAL_GENERATABLE_H -#define MARSHAL_GENERATABLE_H -""" -footer = """ -#endif /* MARSHAL_GENERATABLE_H */ +TEMPLATE = """\ +<%namespace name="helpers" file="helpers.mako"/> +<%include file="copyright.mako"/> + +${helpers.start_guard(guard)} + +enum marshal_dispatch_cmd_id +{ +% for func in functions: + DISPATCH_CMD_${func}, +% endfor +}; + +${helpers.end_guard(guard)} """ -class PrintCode(gl_XML.gl_print_base): - def __init__(self): - super(PrintCode, self).__init__() +def gen_functions(xml): + """Generator that gets the name of each command in OpenGL and yeilds it. - self.name = 'gl_marshal_h.py' - self.license = license.bsd_license_template % ( - 'Copyright (C) 2012 Intel Corporation', 'INTEL CORPORATION') + Ignores commands with special marshaling requirements. + """ + for func in khr_xml.make_functions(xml): + # If the function is not in our records we don't implement it, at all, + # skip it + if not func.is_implemented(): + continue - def printRealHeader(self): - print(header) + # Don't marshal aliases + if func.mesa.alias: + continue - def printRealFooter(self): - print(footer) + if func.mesa.marshal is MarshalType.SYNC: + continue - def printBody(self, api): - print('enum marshal_dispatch_cmd_id') - print('{') - for func in api.functionIterateAll(): - flavor = func.marshal_flavor() - if flavor in ('skip', 'sync'): - continue - print(' DISPATCH_CMD_{0},'.format(func.name)) - print('};') + if func.mesa.marshal not in [MarshalType.DEFAULT, MarshalType.DRAW]: + yield func.name + continue + if func.mesa.exectype is ExecType.SKIP: + continue + + if func.return_type != 'void': + continue + + if func.mesa.output: + continue + + for param in func.params: + if (param.is_pointer() and param.len is None and not + (func.mesa.marshal is MarshalType.DRAW and + param.name == 'indices')): + break + else: + yield func.name def main(): parser = argparse.ArgumentParser() - parser.add_argument('-f', '--filename', metavar='input_file_name', default='gl_API.xml') + parser.add_argument('registry') + parser.add_argument('templatedir') + parser.add_argument('outfile') args = parser.parse_args() - printer = PrintCode() + lookup = TemplateLookup(directories=[args.templatedir], + input_encoding='utf-8', + output_encoding='utf-8') + lookup.put_string('main', TEMPLATE) + + tree = et.parse(args.registry) + root = tree.getroot() - api = gl_XML.parse_GL_API(args.filename, marshal_XML.marshal_item_factory()) - printer.Print(api) + with io.open(args.outfile, 'wb') as f: + f.write(lookup.get_template('main').render( + functions=gen_functions(root), + guard='MARSHAL_GENERATABLE', + copyrights=['Copyright (C) 2012 Intel Corporation'], + script=os.path.basename(__file__))) if __name__ == '__main__': diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build index f494e9707b6..97312596c9c 100644 --- a/src/mapi/glapi/gen/meson.build +++ b/src/mapi/glapi/gen/meson.build @@ -134,6 +134,14 @@ api_xml_files = files( 'GL4x.xml', ) +glapi_new_gen_depends = files( + 'helpers.py', + 'khr_xml.py', + 'mesa_data.py', + 'templates/copyright.mako', + 'templates/helpers.mako', +) + glapi_gen_depends = files( 'gl_XML.py', 'glX_XML.py', @@ -195,7 +203,7 @@ glapi_gentable_c = custom_target( main_enums_c = custom_target( 'enums.c', - input : ['gl_enums.py', files('../registry/gl.xml')], + input : ['gl_enums.py', files_gl_xml], output : 'enums.c', command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], capture : true, diff --git a/src/mapi/glapi/meson.build b/src/mapi/glapi/meson.build index 7e8bc38a817..2c9efeab917 100644 --- a/src/mapi/glapi/meson.build +++ b/src/mapi/glapi/meson.build @@ -18,6 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +files_gl_xml = files('registry/gl.xml') + subdir('gen') inc_glapi = include_directories('.') diff --git a/src/mesa/main/meson.build b/src/mesa/main/meson.build index a5f0e02c6cd..56d070f224b 100644 --- a/src/mesa/main/meson.build +++ b/src/mesa/main/meson.build @@ -29,11 +29,14 @@ main_dispatch_h = custom_target( main_marshal_generated_h = custom_target( 'marshal_generated.h', - input : [files('../../mapi/glapi/gen/gl_marshal_h.py'), gl_and_es_api_files], + input : ['../../mapi/glapi/gen/gl_marshal_h.py', files_gl_xml], output : 'marshal_generated.h', - command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], - depend_files : files('../../mapi/glapi/gen/marshal_XML.py') + glapi_gen_depends, - capture : true, + command : [ + prog_python, '@INPUT0@', '@INPUT1@', + join_paths(meson.current_source_dir(), '../../mapi/glapi/gen/templates'), + '@OUTPUT@', + ], + depend_files : glapi_new_gen_depends, ) main_remap_helper_h = custom_target( -- 2.19.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev