def gen_util_wgl_loader(): supported_wgl_extensions = [ "WGL_ARB_create_context", "WGL_ARB_extensions_string", "WGL_EXT_swap_control", ] source = "wgl.xml" xml = registry_xml.RegistryXML(source) for major_version, minor_version in [[1, 0]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "WGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation) xml.AddExtensionCommands(supported_wgl_extensions, ['wgl']) all_cmds = xml.all_cmd_names.get_all_commands() path = os.path.join("..", "util", "windows") write_header(source, all_cmds, "wgl", util_wgl_preamble, path, "UTIL_WINDOWS", "_") write_source(source, all_cmds, "wgl", path, "_")
def gen_libegl_loader(): data_source_name = "egl.xml and egl_angle_ext.xml" xml = registry_xml.RegistryXML("egl.xml", "egl_angle_ext.xml") for major_version, minor_version in [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "EGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation) xml.AddExtensionCommands(registry_xml.supported_egl_extensions, ['egl']) all_cmds = xml.all_cmd_names.get_all_commands() path = os.path.join("..", "src", "libEGL") write_header(data_source_name, all_cmds, "egl", libegl_preamble, path, "LIBEGL", prefix="EGL_", export="ANGLE_NO_EXPORT ") write_source(data_source_name, all_cmds, "egl", path, prefix="EGL_")
def gen_egl_loader(egl_preamble, path, header_lib, export, internal_prefix, file_prefix): data_source_name = "egl.xml and egl_angle_ext.xml" xml = registry_xml.RegistryXML("egl.xml", "egl_angle_ext.xml") for major_version, minor_version in [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "EGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation) xml.AddExtensionCommands(registry_xml.supported_egl_extensions, ['egl']) all_cmds = xml.all_cmd_names.get_all_commands() write_header(data_source_name, all_cmds, "egl", egl_preamble, path, header_lib, export=export, internal_prefix=internal_prefix, file_prefix=file_prefix) write_source(data_source_name, all_cmds, "egl", path, export=export, internal_prefix=internal_prefix, file_prefix=file_prefix)
def get_egl_exports(): egl = registry_xml.RegistryXML('egl.xml', 'egl_angle_ext.xml') exports = [] capser = lambda fn: "EGL_" + fn[3:] for major, minor in [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]: annotation = "{}_{}".format(major, minor) name_prefix = "EGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) egl.AddCommands(feature_name, annotation) commands = egl.commands[annotation] if len(commands) == 0: continue exports.append("\n ; EGL %d.%d" % (major, minor)) exports += get_exports(commands, capser) egl.AddExtensionCommands(registry_xml.supported_egl_extensions, ['egl']) for extension_name, ext_cmd_names in sorted(egl.ext_data.iteritems()): if len(ext_cmd_names) == 0: continue exports.append("\n ; %s" % extension_name) exports += get_exports(ext_cmd_names, capser) return exports
def gen_libcl_loader(): xml = registry_xml.RegistryXML("cl.xml") for major_version, minor_version in registry_xml.CL_VERSIONS: name_prefix = "CL_VERSION_" annotation = "%d_%d" % (major_version, minor_version) feature_name = "%s%s" % (name_prefix, annotation) xml.AddCommands(feature_name, annotation) all_cmds = xml.all_cmd_names.get_all_commands() path = os.path.join("..", "src", "libOpenCL") source_path = registry_xml.path_to(path, "cl_loader_autogen.cpp") with open(source_path, "w") as out: # TODO(jplate): use first setters after migration in http://anglebug.com/5759 # setter = " cl_loader.%s = reinterpret_cast<cl_api_%s>(loadProc(\"CL_%s\"));" # setters = [setter % (cmd, cmd, cmd[2:]) for cmd in all_cmds] setter = " cl_loader.%s = CL_%s;" setters = [setter % (cmd, cmd[2:]) for cmd in all_cmds] loader_source = template_cl_loader_cpp.format( script_name=os.path.basename(sys.argv[0]), data_source_name="cl.xml", set_pointers="\n".join(setters)) out.write(loader_source) out.close()
def gen_gl_loader(): data_source_name = "gl.xml and gl_angle_ext.xml" xml = registry_xml.RegistryXML("gl.xml", "gl_angle_ext.xml") # First run through the main GLES entry points. Since ES2+ is the primary use # case, we go through those first and then add ES1-only APIs at the end. for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "GL_ES_VERSION_" is_gles1 = major_version == 1 if is_gles1: name_prefix = "GL_VERSION_ES_CM_" feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation) xml.AddExtensionCommands(registry_xml.supported_extensions, ['gles2', 'gles1']) all_cmds = xml.all_cmd_names.get_all_commands() if registry_xml.support_EGL_ANGLE_explicit_context: all_cmds += [cmd + "ContextANGLE" for cmd in xml.all_cmd_names.get_all_commands()] path = os.path.join("..", "util") ex = "ANGLE_UTIL_EXPORT " write_header(data_source_name, all_cmds, "gles", util_gles_preamble, path, "UTIL", export=ex) write_source(data_source_name, all_cmds, "gles", path, export=ex)
def gen_gles_loader(gles_preamble, path, header_lib, export, internal_prefix, file_prefix): data_source_name = "gl.xml and gl_angle_ext.xml" xml = registry_xml.RegistryXML("gl.xml", "gl_angle_ext.xml") # First run through the main GLES entry points. Since ES2+ is the primary use # case, we go through those first and then add ES1-only APIs at the end. for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [3, 2], [1, 0]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "GL_ES_VERSION_" is_gles1 = major_version == 1 if is_gles1: name_prefix = "GL_VERSION_ES_CM_" feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation) xml.AddExtensionCommands(registry_xml.supported_extensions, ['gles2', 'gles1']) all_cmds = xml.all_cmd_names.get_all_commands() if registry_xml.support_EGL_ANGLE_explicit_context: all_cmds += [ cmd + "ContextANGLE" for cmd in xml.all_cmd_names.get_all_commands() ] # Ensure there are no duplicates assert (len(all_cmds) == len( set(all_cmds))), "Duplicate command names found" write_header(data_source_name, all_cmds, "gles", gles_preamble, path, header_lib, export=export, internal_prefix=internal_prefix, file_prefix=file_prefix) write_source(data_source_name, all_cmds, "gles", path, export=export, internal_prefix=internal_prefix, file_prefix=file_prefix)
def main(): # auto_script parameters. if len(sys.argv) > 1: inputs = [source for source in registry_xml.xml_inputs] outputs = [out_file_name_gles, out_file_name_gl] if sys.argv[1] == 'inputs': print ','.join(inputs) elif sys.argv[1] == 'outputs': print ','.join(outputs) else: print('Invalid script parameters') return 1 return 0 glesxml = registry_xml.RegistryXML('gl.xml', 'gl_angle_ext.xml') for annotation in _get_annotations(registry_xml.GLES_VERSIONS): name_prefix = "GL_ES_VERSION_" if annotation[0] == '1': name_prefix = "GL_VERSION_ES_CM_" feature_name = "{}{}".format(name_prefix, annotation) glesxml.AddCommands(feature_name, annotation) glesxml.AddExtensionCommands(registry_xml.supported_extensions, ['gles2', 'gles1']) # Also don't add GLES extension commands to libGL proc table extension_commands = [] for extension_name, ext_cmd_names in sorted(glesxml.ext_data.iteritems()): extension_commands.extend(glesxml.ext_data[extension_name]) for name in extension_commands: name_no_suffix = name for suffix in strip_suffixes: if name_no_suffix.endswith(suffix): name_no_suffix = name_no_suffix[0:-len(suffix)] gles_data = glesxml.all_cmd_names.get_all_commands() eglxml = registry_xml.RegistryXML('egl.xml', 'egl_angle_ext.xml') for annotation in _get_annotations(registry_xml.EGL_VERSIONS): name_prefix = "EGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) eglxml.AddCommands(feature_name, annotation) eglxml.AddExtensionCommands(registry_xml.supported_egl_extensions, ['gles2', 'gles1']) gles_data.extend(eglxml.all_cmd_names.get_all_commands()) gles_data.append("ANGLEGetDisplayPlatform") gles_data.append("ANGLEResetDisplayPlatform") all_functions = {} for function in gles_data: if function.startswith("gl"): all_functions[function] = "gl::" + function[2:] # Special handling for EGL_ANGLE_explicit_context extension if support_egl_ANGLE_explicit_context: all_functions[ function + "ContextANGLE"] = "gl::" + function[2:] + "ContextANGLE" elif function.startswith("egl"): all_functions[function] = "EGL_" + function[3:] else: all_functions[function] = function proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())] with open(out_file_name_gles, 'w') as out_file: output_cpp = template_cpp.format( script_name=sys.argv[0], data_source_name= "gl.xml, gl_angle_ext.xml, egl.xml, egl_angle_ext.xml", copyright_year=date.today().year, includes=includes_gles, cast="__eglMustCastToProperFunctionPointerType", namespace="egl", proc_data=",\n".join(proc_data), num_procs=len(proc_data)) out_file.write(output_cpp) out_file.close() # libGL proc table glxml = registry_xml.RegistryXML('gl.xml') for annotation in _get_annotations(registry_xml.DESKTOP_GL_VERSIONS): name_prefix = "GL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) glxml.AddCommands(feature_name, annotation) gl_data = [cmd for cmd in glxml.all_cmd_names.get_all_commands()] wglxml = registry_xml.RegistryXML('wgl.xml') for annotation in _get_annotations(registry_xml.WGL_VERSIONS): name_prefix = "WGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) wglxml.AddCommands(feature_name, annotation) gl_commands = wglxml.all_cmd_names.get_all_commands() gl_data.extend( [cmd if cmd[:3] == 'wgl' else 'wgl' + cmd for cmd in gl_commands]) all_functions = {} for function in gl_data: if function.startswith("gl"): all_functions[function] = "gl::" + function[2:] else: all_functions[function] = function proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())] with open(out_file_name_gl, 'w') as out_file: output_cpp = template_cpp.format(script_name=sys.argv[0], data_source_name="gl.xml, wgl.xml", copyright_year=date.today().year, includes=includes_gl, cast="PROC", namespace="wgl", proc_data=",\n".join(proc_data), num_procs=len(proc_data)) out_file.write(output_cpp) out_file.close() return 0
def get_exports(commands, fmt = None): if fmt: return [" %s" % fmt(cmd) for cmd in sorted(commands)] else: return [" %s" % cmd for cmd in sorted(commands)] gles1decls = {} gles1decls['core'] = [] gles1decls['exts'] = {} libgles_ep_defs = [] libgles_ep_exports = [] xml = registry_xml.RegistryXML('gl.xml', 'gl_angle_ext.xml') # First run through the main GLES entry points. Since ES2+ is the primary use # case, we go through those first and then add ES1-only APIs at the end. for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "GL_ES_VERSION_" is_gles1 = major_version == 1 if is_gles1: name_prefix = "GL_VERSION_ES_CM_" comment = annotation.replace("_", ".") feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation)
def main(header_output_path, source_output_path): xml = registry_xml.RegistryXML('gl.xml', 'gl_angle_ext.xml') # build a map from GLenum name to its value all_gl_enums = dict() for enums_node in xml.root.findall('enums'): for enum in enums_node.findall('enum'): name = enum.attrib['name'] value = int(enum.attrib['value'], base=16) all_gl_enums[name] = value # Parse groups of GLenums to build a {group, name} -> value mapping. gl_enum_in_groups = dict() enums_has_group = set() for enums_group_node in xml.root.findall('groups/group'): group_name = enums_group_node.attrib['name'] if group_name in exclude_gl_enum_groups: continue if group_name not in gl_enum_in_groups: gl_enum_in_groups[group_name] = dict() for enum_node in enums_group_node.findall('enum'): enum_name = enum_node.attrib['name'] enums_has_group.add(enum_name) gl_enum_in_groups[group_name][enum_name] = all_gl_enums[enum_name] # Find relevant GLenums according to enabled APIs and extensions. exporting_enums = set() # export all the apis xpath = "./feature/require/enum" for enum_tag in xml.root.findall(xpath): enum_name = enum_tag.attrib['name'] if enum_name not in exclude_gl_enums: exporting_enums.add(enum_name) for extension in registry_xml.supported_extensions: xpath = "./extensions/extension[@name='%s']/require/enum" % extension for enum_tag in xml.root.findall(xpath): enum_name = enum_tag.attrib['name'] if enum_name not in exclude_gl_enums: exporting_enums.add(enum_name) # For enums that do not have a group, add them to a default group default_group_name = registry_xml.default_enum_group_name gl_enum_in_groups[default_group_name] = dict() default_group = gl_enum_in_groups[default_group_name] for enum_name in exporting_enums: if enum_name not in enums_has_group: default_group[enum_name] = all_gl_enums[enum_name] # Write GLenum groups into the header file. header_content = template_gl_enums_header.format( script_name=os.path.basename(sys.argv[0]), data_source_name="gl.xml and gl_angle_ext.xml", year=date.today().year, gl_enum_groups=',\n'.join(sorted(gl_enum_in_groups.iterkeys()))) header_output_path = registry_xml.script_relative(header_output_path) with open(header_output_path, 'w') as f: f.write(header_content) # Write mapping to source file gl_enums_value_to_string_table = dump_value_to_string_mapping(gl_enum_in_groups, exporting_enums) source_content = template_gl_enums_source.format( script_name=os.path.basename(sys.argv[0]), data_source_name="gl.xml and gl_angle_ext.xml", year=date.today().year, gl_enums_value_to_string_table=gl_enums_value_to_string_table, ) source_output_path = registry_xml.script_relative(source_output_path) with open(source_output_path, 'w') as f: f.write(source_content) return 0
def main(): # auto_script parameters. if len(sys.argv) > 1: inputs = [ 'egl.xml', 'egl_angle_ext.xml', 'entry_point_packed_gl_enums.json', 'gl.xml', 'gl_angle_ext.xml', 'registry_xml.py', ] outputs = [ '../src/libANGLE/Context_gles_1_0_autogen.h', '../src/libANGLE/validationES1_autogen.h', '../src/libANGLE/validationES2_autogen.h', '../src/libANGLE/validationES31_autogen.h', '../src/libANGLE/validationES3_autogen.h', '../src/libANGLE/validationESEXT_autogen.h', '../src/libGLESv2/entry_points_enum_autogen.h', '../src/libGLESv2/entry_points_gles_1_0_autogen.cpp', '../src/libGLESv2/entry_points_gles_1_0_autogen.h', '../src/libGLESv2/entry_points_gles_2_0_autogen.cpp', '../src/libGLESv2/entry_points_gles_2_0_autogen.h', '../src/libGLESv2/entry_points_gles_3_0_autogen.cpp', '../src/libGLESv2/entry_points_gles_3_0_autogen.h', '../src/libGLESv2/entry_points_gles_3_1_autogen.cpp', '../src/libGLESv2/entry_points_gles_3_1_autogen.h', '../src/libGLESv2/entry_points_gles_ext_autogen.cpp', '../src/libGLESv2/entry_points_gles_ext_autogen.h', '../src/libGLESv2/libGLESv2_autogen.cpp', '../src/libGLESv2/libGLESv2_autogen.def', ] if sys.argv[1] == 'inputs': print ','.join(inputs) elif sys.argv[1] == 'outputs': print ','.join(outputs) else: print('Invalid script parameters') return 1 return 0 gles1decls = {} gles1decls['core'] = [] gles1decls['exts'] = {} libgles_ep_defs = [] libgles_ep_exports = [] xml = registry_xml.RegistryXML('gl.xml', 'gl_angle_ext.xml') # First run through the main GLES entry points. Since ES2+ is the primary use # case, we go through those first and then add ES1-only APIs at the end. for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]: annotation = "{}_{}".format(major_version, minor_version) name_prefix = "GL_ES_VERSION_" is_gles1 = major_version == 1 if is_gles1: name_prefix = "GL_VERSION_ES_CM_" comment = annotation.replace("_", ".") feature_name = "{}{}".format(name_prefix, annotation) xml.AddCommands(feature_name, annotation) gles_commands = xml.commands[annotation] all_commands = xml.all_commands decls, defs, libgles_defs, validation_protos = get_entry_points( all_commands, gles_commands, False) # Write the version as a comment before the first EP. libgles_defs.insert(0, "\n// OpenGL ES %s" % comment) libgles_ep_exports.append("\n ; OpenGL ES %s" % comment) libgles_ep_defs += libgles_defs libgles_ep_exports += get_exports(gles_commands) major_if_not_one = major_version if major_version != 1 else "" minor_if_not_zero = minor_version if minor_version != 0 else "" header_includes = template_header_includes.format( major=major_if_not_one, minor=minor_if_not_zero) # We include the platform.h header since it undefines the conflicting MemoryBarrier macro. if major_version == 3 and minor_version == 1: header_includes += "\n#include \"common/platform.h\"\n" source_includes = template_sources_includes.format( annotation.lower(), major_version, minor_if_not_zero) write_file(annotation, comment, template_entry_point_header, "\n".join(decls), "h", header_includes, "gl.xml") write_file(annotation, comment, template_entry_point_source, "\n".join(defs), "cpp", source_includes, "gl.xml") if is_gles1: gles1decls['core'] = get_gles1_decls(all_commands, gles_commands) validation_annotation = "%s%s" % (major_version, minor_if_not_zero) write_validation_header(validation_annotation, comment, validation_protos) # After we finish with the main entry points, we process the extensions. extension_defs = [] extension_decls = [] # Accumulated validation prototypes. ext_validation_protos = [] for gles1ext in registry_xml.gles1_extensions: gles1decls['exts'][gles1ext] = [] xml.AddExtensionCommands(registry_xml.supported_extensions, ['gles2', 'gles1']) for extension_name, ext_cmd_names in sorted(xml.ext_data.iteritems()): # Detect and filter duplicate extensions. decls, defs, libgles_defs, validation_protos = get_entry_points( xml.all_commands, ext_cmd_names, False) # Avoid writing out entry points defined by a prior extension. for dupe in xml.ext_dupes[extension_name]: msg = "// {} is already defined.\n".format(dupe[2:]) defs.append(msg) # Write the extension name as a comment before the first EP. comment = "\n// {}".format(extension_name) defs.insert(0, comment) decls.insert(0, comment) libgles_defs.insert(0, comment) libgles_ep_exports.append("\n ; %s" % extension_name) extension_defs += defs extension_decls += decls ext_validation_protos += [comment] + validation_protos libgles_ep_defs += libgles_defs libgles_ep_exports += get_exports(ext_cmd_names) if extension_name in registry_xml.gles1_extensions: if extension_name not in gles1_no_context_decl_extensions: gles1decls['exts'][extension_name] = get_gles1_decls(all_commands, ext_cmd_names) # Special handling for EGL_ANGLE_explicit_context extension if registry_xml.support_EGL_ANGLE_explicit_context: comment = "\n// EGL_ANGLE_explicit_context" extension_defs.append(comment) extension_decls.append(comment) libgles_ep_defs.append(comment) cmds = xml.all_cmd_names.get_all_commands() # Get the explicit context entry points decls, defs, libgles_defs, validation_protos = get_entry_points( xml.all_commands, cmds, True) # Append the explicit context entry points extension_decls += decls extension_defs += defs libgles_ep_defs += libgles_defs libgles_ep_exports.append("\n ; EGL_ANGLE_explicit_context") libgles_ep_exports += get_exports(cmds, lambda x: "%sContextANGLE" % x) # Generate .inc files for extension function pointers and declarations for major, minor in [[2, 0], [3, 0], [3, 1], [1, 0]]: annotation = "{}_{}".format(major, minor) major_if_not_one = major if major != 1 else "" minor_if_not_zero = minor if minor != 0 else "" version = "{}{}".format(major_if_not_one, minor_if_not_zero) glext_ptrs, glext_protos = get_glext_decls(all_commands, xml.all_cmd_names.get_commands(annotation), version, True) glext_ext_ptrs = [] glext_ext_protos = [] # Append extensions for 1.0 and 2.0 if(annotation == "1_0"): glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands, xml.all_cmd_names.get_commands("glext"), version, True) elif(annotation == "2_0"): glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands, xml.all_cmd_names.get_commands("gl2ext"), version, True) glext_ptrs += glext_ext_ptrs glext_protos += glext_ext_protos write_glext_explicit_context_inc(version, "\n".join(glext_ptrs), "\n".join(glext_protos)) header_includes = template_header_includes.format( major="", minor="") header_includes += """ #include <GLES/glext.h> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> """ source_includes = template_sources_includes.format("ext", "EXT", "") source_includes += """ #include "libANGLE/validationES1.h" #include "libANGLE/validationES2.h" #include "libANGLE/validationES3.h" #include "libANGLE/validationES31.h" """ write_file("ext", "extension", template_entry_point_header, "\n".join([item for item in extension_decls]), "h", header_includes, "gl.xml and gl_angle_ext.xml") write_file("ext", "extension", template_entry_point_source, "\n".join([item for item in extension_defs]), "cpp", source_includes, "gl.xml and gl_angle_ext.xml") write_validation_header("EXT", "extension", ext_validation_protos) write_context_api_decls("1_0", context_gles_header, gles1decls) sorted_cmd_names = ["Invalid"] + [cmd[2:] for cmd in sorted(xml.all_cmd_names.get_all_commands())] entry_points_enum = template_entry_points_enum_header.format( script_name = os.path.basename(sys.argv[0]), data_source_name = "gl.xml and gl_angle_ext.xml", year = date.today().year, entry_points_list = ",\n".join([" " + cmd for cmd in sorted_cmd_names])) entry_points_enum_header_path = path_to("libGLESv2", "entry_points_enum_autogen.h") with open(entry_points_enum_header_path, "w") as out: out.write(entry_points_enum) out.close() source_includes = """ #include "angle_gl.h" #include "libGLESv2/entry_points_gles_1_0_autogen.h" #include "libGLESv2/entry_points_gles_2_0_autogen.h" #include "libGLESv2/entry_points_gles_3_0_autogen.h" #include "libGLESv2/entry_points_gles_3_1_autogen.h" #include "libGLESv2/entry_points_gles_ext_autogen.h" #include "common/event_tracer.h" """ write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes) libgles_ep_exports += get_egl_exports() everything = "Khronos and ANGLE XML files" write_windows_def_file(everything, "libGLESv2", libgles_ep_exports)
def main(): # auto_script parameters. if len(sys.argv) > 1: inputs = [source for source in registry_xml.xml_inputs] outputs = [ out_file_name_gles, out_file_name_gl, out_file_name_cl, out_file_name_cl_map ] if sys.argv[1] == 'inputs': print(','.join(inputs)) elif sys.argv[1] == 'outputs': print(','.join(outputs)) else: print('Invalid script parameters') return 1 return 0 glesxml = registry_xml.RegistryXML('gl.xml', 'gl_angle_ext.xml') for annotation in _get_annotations(registry_xml.GLES_VERSIONS): name_prefix = "GL_ES_VERSION_" if annotation[0] == '1': name_prefix = "GL_VERSION_ES_CM_" feature_name = "{}{}".format(name_prefix, annotation) glesxml.AddCommands(feature_name, annotation) glesxml.AddExtensionCommands(registry_xml.supported_extensions, ['gles2', 'gles1']) # Also don't add GLES extension commands to libGL proc table extension_commands = [] for extension_name, ext_cmd_names in sorted(glesxml.ext_data.items()): extension_commands.extend(glesxml.ext_data[extension_name]) for name in extension_commands: name_no_suffix = name for suffix in strip_suffixes: if name_no_suffix.endswith(suffix): name_no_suffix = name_no_suffix[0:-len(suffix)] gles_data = glesxml.all_cmd_names.get_all_commands() eglxml = registry_xml.RegistryXML('egl.xml', 'egl_angle_ext.xml') for annotation in _get_annotations(registry_xml.EGL_VERSIONS): name_prefix = "EGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) eglxml.AddCommands(feature_name, annotation) eglxml.AddExtensionCommands(registry_xml.supported_egl_extensions, ['gles2', 'gles1']) gles_data.extend(eglxml.all_cmd_names.get_all_commands()) gles_data.append("ANGLEGetDisplayPlatform") gles_data.append("ANGLEResetDisplayPlatform") all_functions = {} for function in gles_data: if function.startswith("gl"): all_functions[function] = "GL_" + function[2:] # Special handling for EGL_ANGLE_explicit_context extension if support_egl_ANGLE_explicit_context: all_functions[ function + "ContextANGLE"] = "GL_" + function[2:] + "ContextANGLE" elif function.startswith("egl"): all_functions[function] = "EGL_" + function[3:] else: all_functions[function] = function proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.items())] with open(out_file_name_gles, 'w') as out_file: output_cpp = template_cpp.format( script_name=sys.argv[0], data_source_name= "gl.xml, gl_angle_ext.xml, egl.xml, egl_angle_ext.xml", includes=includes_gles, cast="__eglMustCastToProperFunctionPointerType", namespace="egl", proc_data=",\n".join(proc_data), num_procs=len(proc_data)) out_file.write(output_cpp) out_file.close() # libGL proc table glxml = registry_xml.RegistryXML('gl.xml') for annotation in _get_annotations(registry_xml.DESKTOP_GL_VERSIONS): name_prefix = "GL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) glxml.AddCommands(feature_name, annotation) gl_data = [cmd for cmd in glxml.all_cmd_names.get_all_commands()] wglxml = registry_xml.RegistryXML('wgl.xml') for annotation in _get_annotations(registry_xml.WGL_VERSIONS): name_prefix = "WGL_VERSION_" feature_name = "{}{}".format(name_prefix, annotation) wglxml.AddCommands(feature_name, annotation) gl_commands = wglxml.all_cmd_names.get_all_commands() gl_data.extend( [cmd if cmd[:3] == 'wgl' else 'wgl' + cmd for cmd in gl_commands]) all_functions = {} for function in gl_data: if function.startswith("gl"): all_functions[function] = "GL_" + function[2:] else: all_functions[function] = function proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.items())] with open(out_file_name_gl, 'w') as out_file: output_cpp = template_cpp.format(script_name=sys.argv[0], data_source_name="gl.xml, wgl.xml", includes=includes_gl, cast="PROC", namespace="wgl", proc_data=",\n".join(proc_data), num_procs=len(proc_data)) out_file.write(output_cpp) out_file.close() # libCL proc table clxml = registry_xml.RegistryXML('cl.xml') symbol_maps = [] symbol_map_dependency = "" for major_version, minor_version in registry_xml.CL_VERSIONS: name_prefix = "CL_VERSION_" annotation = "%d_%d" % (major_version, minor_version) feature_name = "%s%s" % (name_prefix, annotation) clxml.AddCommands(feature_name, annotation) symbol_version = "OPENCL_%d.%d" % (major_version, minor_version) symbol_maps += ["\n%s {\n global:" % symbol_version] symbol_maps += [ ' %s;' % cmd for cmd in clxml.commands[annotation] ] if not symbol_map_dependency: symbol_maps += [" local:\n *;\n};"] else: symbol_maps += ["} %s;" % symbol_map_dependency] symbol_map_dependency = symbol_version clxml.AddExtensionCommands(registry_xml.supported_cl_extensions, ['cl']) cl_commands = clxml.all_cmd_names.get_all_commands() proc_data = ['{"%s", P(::cl::%s)}' % (cmd, cmd) for cmd in cl_commands] with open(out_file_name_cl, 'w') as out_file: output_cpp = template_map_cpp.format( script_name=sys.argv[0], data_source_name="cl.xml", includes=includes_cl, cast="void *", namespace="cl", proc_data=",\n ".join(proc_data)) out_file.write(output_cpp) out_file.close() with open(out_file_name_cl_map, 'w') as out_file: output_map = template_map.format(script_name=sys.argv[0], data_source_name="cl.xml", symbol_maps="\n".join(symbol_maps)) out_file.write(output_map) out_file.close() return 0