1#!/usr/bin/python2 2# 3# Copyright 2017 The ANGLE Project Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6# 7# generate_entry_points.py: 8# Generates the OpenGL bindings and entry point layers for ANGLE. 9# NOTE: don't run this script directly. Run scripts/run_code_generation.py. 10 11import sys, os, pprint, json 12from datetime import date 13import registry_xml 14 15# List of GLES1 extensions for which we don't need to add Context.h decls. 16gles1_no_context_decl_extensions = [ 17 "GL_OES_framebuffer_object", 18] 19 20# List of GLES1 API calls that have had their semantics changed in later GLES versions, but the 21# name was kept the same 22gles1_overloaded = [ 23 "glGetPointerv", 24] 25 26# This is a list of exceptions for entry points which don't want to have 27# the EVENT macro. This is required for some debug marker entry points. 28no_event_marker_exceptions_list = sorted([ 29 "glPushGroupMarkerEXT", 30 "glPopGroupMarkerEXT", 31 "glInsertEventMarkerEXT", 32]) 33 34# Strip these suffixes from Context entry point names. NV is excluded (for now). 35strip_suffixes = ["ANGLE", "EXT", "KHR", "OES", "CHROMIUM", "OVR"] 36 37template_entry_point_header = """// GENERATED FILE - DO NOT EDIT. 38// Generated by {script_name} using data from {data_source_name}. 39// 40// Copyright {year} The ANGLE Project Authors. All rights reserved. 41// Use of this source code is governed by a BSD-style license that can be 42// found in the LICENSE file. 43// 44// entry_points_{annotation_lower}_autogen.h: 45// Defines the {comment} entry points. 46 47#ifndef {lib}_ENTRY_POINTS_{annotation_upper}_AUTOGEN_H_ 48#define {lib}_ENTRY_POINTS_{annotation_upper}_AUTOGEN_H_ 49 50{includes} 51 52namespace gl 53{{ 54{entry_points} 55}} // namespace gl 56 57#endif // {lib}_ENTRY_POINTS_{annotation_upper}_AUTOGEN_H_ 58""" 59 60template_entry_point_source = """// GENERATED FILE - DO NOT EDIT. 61// Generated by {script_name} using data from {data_source_name}. 62// 63// Copyright {year} The ANGLE Project Authors. All rights reserved. 64// Use of this source code is governed by a BSD-style license that can be 65// found in the LICENSE file. 66// 67// entry_points_{annotation_lower}_autogen.cpp: 68// Defines the {comment} entry points. 69 70{includes} 71 72namespace gl 73{{ 74{entry_points}}} // namespace gl 75""" 76 77template_entry_points_enum_header = """// GENERATED FILE - DO NOT EDIT. 78// Generated by {script_name} using data from {data_source_name}. 79// 80// Copyright {year} The ANGLE Project Authors. All rights reserved. 81// Use of this source code is governed by a BSD-style license that can be 82// found in the LICENSE file. 83// 84// entry_points_enum_autogen.h: 85// Defines the {lib} entry points enumeration. 86 87#ifndef LIBANGLE_ENTRYPOINTSENUM_AUTOGEN_H_ 88#define LIBANGLE_ENTRYPOINTSENUM_AUTOGEN_H_ 89 90namespace gl 91{{ 92enum class EntryPoint 93{{ 94{entry_points_list} 95}}; 96 97const char *GetEntryPointName(EntryPoint ep); 98}} // namespace gl 99#endif // LIBANGLE_ENTRY_POINTS_ENUM_AUTOGEN_H_ 100""" 101 102template_entry_points_name_case = """ case EntryPoint::{enum}: 103 return "gl{enum}";""" 104 105template_entry_points_enum_source = """// GENERATED FILE - DO NOT EDIT. 106// Generated by {script_name} using data from {data_source_name}. 107// 108// Copyright {year} The ANGLE Project Authors. All rights reserved. 109// Use of this source code is governed by a BSD-style license that can be 110// found in the LICENSE file. 111// 112// entry_points_enum_autogen.cpp: 113// Helper methods for the {lib} entry points enumeration. 114 115#include "libANGLE/entry_points_enum_autogen.h" 116 117#include "common/debug.h" 118 119namespace gl 120{{ 121const char *GetEntryPointName(EntryPoint ep) 122{{ 123 switch (ep) 124 {{ 125{entry_points_name_cases} 126 default: 127 UNREACHABLE(); 128 return "error"; 129 }} 130}} 131}} // namespace gl 132""" 133 134template_lib_entry_point_source = """// GENERATED FILE - DO NOT EDIT. 135// Generated by {script_name} using data from {data_source_name}. 136// 137// Copyright {year} The ANGLE Project Authors. All rights reserved. 138// Use of this source code is governed by a BSD-style license that can be 139// found in the LICENSE file. 140// 141// {lib_name}.cpp: Implements the exported {lib_description} functions. 142 143{includes} 144extern "C" {{ 145{entry_points} 146}} // extern "C" 147""" 148 149template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});""" 150 151template_entry_point_no_return = """void GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params}) 152{{ 153 {event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params}); 154 155 Context *context = {context_getter}; 156 if (context) 157 {{{assert_explicit_context}{packed_gl_enum_conversions} 158 std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context); 159 bool isCallValid = (context->skipValidation() || Validate{name}({validate_params})); 160 if (isCallValid) 161 {{ 162 context->{name_lower_no_suffix}({internal_params}); 163 }} 164 ANGLE_CAPTURE({name}, isCallValid, {validate_params}); 165 }} 166}} 167""" 168 169template_entry_point_with_return = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params}) 170{{ 171 {event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params}); 172 173 Context *context = {context_getter}; 174 {return_type} returnValue; 175 if (context) 176 {{{assert_explicit_context}{packed_gl_enum_conversions} 177 std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context); 178 bool isCallValid = (context->skipValidation() || Validate{name}({validate_params})); 179 if (isCallValid) 180 {{ 181 returnValue = context->{name_lower_no_suffix}({internal_params}); 182 }} 183 else 184 {{ 185 returnValue = GetDefaultReturnValue<EntryPoint::{name}, {return_type}>(); 186 }} 187 ANGLE_CAPTURE({name}, isCallValid, {validate_params}, returnValue); 188 }} 189 else 190 {{ 191 returnValue = GetDefaultReturnValue<EntryPoint::{name}, {return_type}>(); 192 }} 193 return returnValue; 194}} 195""" 196 197context_header = """// GENERATED FILE - DO NOT EDIT. 198// Generated by {script_name} using data from {data_source_name}. 199// 200// Copyright {year} The ANGLE Project Authors. All rights reserved. 201// Use of this source code is governed by a BSD-style license that can be 202// found in the LICENSE file. 203// 204// Context_{annotation_lower}_autogen.h: Creates a macro for interfaces in Context. 205 206#ifndef ANGLE_CONTEXT_{annotation_upper}_AUTOGEN_H_ 207#define ANGLE_CONTEXT_{annotation_upper}_AUTOGEN_H_ 208 209#define ANGLE_{annotation_upper}_CONTEXT_API \\ 210{interface} 211 212#endif // ANGLE_CONTEXT_API_{version}_AUTOGEN_H_ 213""" 214 215context_decl_format = """ {return_type} {name_lower_no_suffix}({internal_params}); \\""" 216 217libgles_entry_point_def = """{return_type}GL_APIENTRY gl{name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params}) 218{{ 219 return gl::{name}{explicit_context_suffix}({explicit_context_internal_param}{explicit_context_comma}{internal_params}); 220}} 221""" 222 223template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT. 224// Generated by {script_name} using data from {data_source_name}. 225// 226// Copyright {year} The ANGLE Project Authors. All rights reserved. 227// Use of this source code is governed by a BSD-style license that can be 228// found in the LICENSE file. 229// 230// gl{version}ext_explicit_context_autogen.inc: 231// Function declarations for the EGL_ANGLE_explicit_context extension 232 233{function_pointers} 234#ifdef GL_GLEXT_PROTOTYPES 235{function_prototypes} 236#endif 237""" 238 239template_glext_function_pointer = """typedef {return_type}(GL_APIENTRYP PFN{name_upper}{explicit_context_suffix_upper}PROC)({explicit_context_param}{explicit_context_comma}{params});""" 240template_glext_function_prototype = """{apicall} {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});""" 241 242template_validation_header = """// GENERATED FILE - DO NOT EDIT. 243// Generated by {script_name} using data from {data_source_name}. 244// 245// Copyright {year} The ANGLE Project Authors. All rights reserved. 246// Use of this source code is governed by a BSD-style license that can be 247// found in the LICENSE file. 248// 249// validation{annotation}_autogen.h: 250// Validation functions for the OpenGL {comment} entry points. 251 252#ifndef LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_ 253#define LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_ 254 255#include "common/PackedEnums.h" 256 257namespace gl 258{{ 259class Context; 260 261{prototypes} 262}} // namespace gl 263 264#endif // LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_ 265""" 266 267template_capture_header = """// GENERATED FILE - DO NOT EDIT. 268// Generated by {script_name} using data from {data_source_name}. 269// 270// Copyright {year} The ANGLE Project Authors. All rights reserved. 271// Use of this source code is governed by a BSD-style license that can be 272// found in the LICENSE file. 273// 274// capture_gles_{annotation}_autogen.h: 275// Capture functions for the OpenGL ES {comment} entry points. 276 277#ifndef LIBANGLE_CAPTURE_GLES_{annotation}_AUTOGEN_H_ 278#define LIBANGLE_CAPTURE_GLES_{annotation}_AUTOGEN_H_ 279 280#include "common/PackedEnums.h" 281#include "libANGLE/FrameCapture.h" 282 283namespace gl 284{{ 285class Context; 286 287{prototypes} 288}} // namespace gl 289 290#endif // LIBANGLE_CAPTURE_GLES_{annotation}_AUTOGEN_H_ 291""" 292 293template_capture_source = """// GENERATED FILE - DO NOT EDIT. 294// Generated by {script_name} using data from {data_source_name}. 295// 296// Copyright {year} The ANGLE Project Authors. All rights reserved. 297// Use of this source code is governed by a BSD-style license that can be 298// found in the LICENSE file. 299// 300// capture_gles_{annotation_with_dash}_autogen.cpp: 301// Capture functions for the OpenGL ES {comment} entry points. 302 303#include "libANGLE/capture_gles_{annotation_with_dash}_autogen.h" 304 305#include "libANGLE/Context.h" 306#include "libANGLE/FrameCapture.h" 307#include "libANGLE/gl_enum_utils_autogen.h" 308#include "libANGLE/validation{annotation_no_dash}.h" 309 310using namespace angle; 311 312namespace gl 313{{ 314{capture_methods} 315}} // namespace gl 316""" 317 318template_capture_method_with_return_value = """ 319CallCapture Capture{short_name}({params_with_type}, {return_value_type_original} returnValue) 320{{ 321 ParamBuffer paramBuffer; 322 323 {parameter_captures} 324 325 ParamCapture returnValueCapture("returnValue", ParamType::T{return_value_type_custom}); 326 InitParamValue(ParamType::T{return_value_type_custom}, returnValue, &returnValueCapture.value); 327 paramBuffer.addReturnValue(std::move(returnValueCapture)); 328 329 return CallCapture(gl::EntryPoint::{short_name}, std::move(paramBuffer)); 330}} 331""" 332 333template_capture_method_no_return_value = """ 334CallCapture Capture{short_name}({params_with_type}) 335{{ 336 ParamBuffer paramBuffer; 337 338 {parameter_captures} 339 340 return CallCapture(gl::EntryPoint::{short_name}, std::move(paramBuffer)); 341}} 342""" 343 344template_parameter_capture_value = """paramBuffer.addValueParam("{name}", ParamType::T{type}, {name});""" 345 346template_parameter_capture_gl_enum = """paramBuffer.addEnumParam("{name}", GLenumGroup::{group}, ParamType::T{type}, {name});""" 347 348template_parameter_capture_pointer = """ 349 ParamCapture {name}Param("{name}", ParamType::T{type}); 350 InitParamValue(ParamType::T{type}, {name}, &{name}Param.value); 351 {capture_name}({params}, &{name}Param); 352 paramBuffer.addParam(std::move({name}Param)); 353""" 354 355template_parameter_capture_pointer_func = """void {name}({params});""" 356 357static_cast_to_dict = { 358 "GLintptr": "unsigned long long", 359 "GLsizeiptr": "unsigned long long", 360 "GLuint64": "unsigned long long", 361} 362 363reinterpret_cast_to_dict = { 364 "GLsync": "uintptr_t", 365 "GLDEBUGPROC": "uintptr_t", 366 "GLDEBUGPROCKHR": "uintptr_t", 367 "GLeglImageOES": "uintptr_t", 368} 369 370format_dict = { 371 "GLbitfield": "%s", 372 "GLboolean": "%s", 373 "GLbyte": "%d", 374 "GLclampx": "0x%X", 375 "GLDEBUGPROC": "0x%016\" PRIxPTR \"", 376 "GLDEBUGPROCKHR": "0x%016\" PRIxPTR \"", 377 "GLdouble": "%f", 378 "GLeglImageOES": "0x%016\" PRIxPTR \"", 379 "GLenum": "%s", 380 "GLfixed": "0x%X", 381 "GLfloat": "%f", 382 "GLint": "%d", 383 "GLintptr": "%llu", 384 "GLshort": "%d", 385 "GLsizei": "%d", 386 "GLsizeiptr": "%llu", 387 "GLsync": "0x%016\" PRIxPTR \"", 388 "GLubyte": "%d", 389 "GLuint": "%u", 390 "GLuint64": "%llu", 391 "GLushort": "%u", 392 "int": "%d", 393 # WGL specific types 394 "BOOL": "%u", 395 "DWORD": "0x%016\" PRIxPTR \"", 396 "FLOAT": "%f", 397 "HDC": "0x%016\" PRIxPTR \"", 398 "HENHMETAFILE": "0x%016\" PRIxPTR \"", 399 "HGLRC": "0x%016\" PRIxPTR \"", 400 "LPCSTR": "0x%016\" PRIxPTR \"", 401 "LPGLYPHMETRICSFLOAT": "0x%016\" PRIxPTR \"", 402 "UINT": "%u", 403} 404 405template_header_includes = """#include <GLES{major}/gl{major}{minor}.h> 406#include <export.h>""" 407 408template_sources_includes = """#include "libGLESv2/entry_points_{header_version}_autogen.h" 409 410#include "libANGLE/Context.h" 411#include "libANGLE/Context.inl.h" 412#include "libANGLE/capture_{header_version}_autogen.h" 413#include "libANGLE/gl_enum_utils_autogen.h" 414#include "libANGLE/validation{validation_header_version}.h" 415#include "libANGLE/entry_points_utils.h" 416#include "libGLESv2/global_state.h" 417""" 418 419template_header_includes_gl32 = """#include <export.h> 420#include "angle_gl.h" 421 422""" 423 424template_sources_includes_gl32 = """#include "libGL/entry_points_{}_autogen.h" 425 426#include "libANGLE/Context.h" 427#include "libANGLE/Context.inl.h" 428#include "libANGLE/gl_enum_utils_autogen.h" 429#include "libANGLE/validationEGL.h" 430#include "libANGLE/validationES.h" 431#include "libANGLE/validationES1.h" 432#include "libANGLE/validationES2.h" 433#include "libANGLE/validationES3.h" 434#include "libANGLE/validationES31.h" 435#include "libANGLE/validationESEXT.h" 436#include "libANGLE/validationGL{}{}_autogen.h" 437#include "libANGLE/entry_points_utils.h" 438#include "libGLESv2/global_state.h" 439""" 440 441template_event_comment = """// Don't run an EVENT() macro on the EXT_debug_marker entry points. 442 // It can interfere with the debug events being set by the caller. 443 // """ 444 445template_capture_proto = "angle::CallCapture Capture%s(%s);" 446 447template_validation_proto = "bool Validate%s(%s);" 448 449template_windows_def_file = """; GENERATED FILE - DO NOT EDIT. 450; Generated by {script_name} using data from {data_source_name}. 451; 452; Copyright {year} The ANGLE Project Authors. All rights reserved. 453; Use of this source code is governed by a BSD-style license that can be 454; found in the LICENSE file. 455LIBRARY {lib} 456EXPORTS 457{exports} 458""" 459 460template_frame_capture_utils_header = """// GENERATED FILE - DO NOT EDIT. 461// Generated by {script_name} using data from {data_source_name}. 462// 463// Copyright {year} The ANGLE Project Authors. All rights reserved. 464// Use of this source code is governed by a BSD-style license that can be 465// found in the LICENSE file. 466// 467// frame_capture_utils_autogen.h: 468// ANGLE Frame capture types and helper functions. 469 470#ifndef LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_H_ 471#define LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_H_ 472 473#include "common/PackedEnums.h" 474 475namespace angle 476{{ 477enum class ParamType 478{{ 479 {param_types} 480}}; 481 482union ParamValue 483{{ 484 {param_union_values} 485}}; 486 487template <ParamType PType, typename T> 488void SetParamVal(T valueIn, ParamValue *valueOut); 489 490{set_param_val_specializations} 491 492template <ParamType PType, typename T> 493void SetParamVal(T valueIn, ParamValue *valueOut) 494{{ 495 UNREACHABLE(); 496}} 497 498template <typename T> 499void InitParamValue(ParamType paramType, T valueIn, ParamValue *valueOut) 500{{ 501 switch (paramType) 502 {{ 503{init_param_value_cases} 504 }} 505}} 506 507void WriteParamTypeToStream(std::ostream &os, ParamType paramType, const ParamValue& paramValue); 508const char *ParamTypeToString(ParamType paramType); 509}} // namespace angle 510 511#endif // LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_H_ 512""" 513 514template_frame_capture_utils_source = """// GENERATED FILE - DO NOT EDIT. 515// Generated by {script_name} using data from {data_source_name}. 516// 517// Copyright {year} The ANGLE Project Authors. All rights reserved. 518// Use of this source code is governed by a BSD-style license that can be 519// found in the LICENSE file. 520// 521// frame_capture_utils_autogen.cpp: 522// ANGLE Frame capture types and helper functions. 523 524#include "libANGLE/frame_capture_utils_autogen.h" 525 526#include "libANGLE/FrameCapture.h" 527 528namespace angle 529{{ 530void WriteParamTypeToStream(std::ostream &os, ParamType paramType, const ParamValue& paramValue) 531{{ 532 switch (paramType) 533 {{ 534{write_param_type_to_stream_cases} 535 default: 536 os << "unknown"; 537 break; 538 }} 539}} 540 541const char *ParamTypeToString(ParamType paramType) 542{{ 543 switch (paramType) 544 {{ 545{param_type_to_string_cases} 546 default: 547 UNREACHABLE(); 548 return "unknown"; 549 }} 550}} 551}} // namespace angle 552""" 553 554template_set_param_val_specialization = """template <> 555inline void SetParamVal<ParamType::T{enum}>({type} valueIn, ParamValue *valueOut) 556{{ 557 valueOut->{union_name} = valueIn; 558}}""" 559 560template_init_param_value_case = """ case ParamType::T{enum}: 561 SetParamVal<ParamType::T{enum}>(valueIn, valueOut); 562 break;""" 563 564template_write_param_type_to_stream_case = """ case ParamType::T{enum}: 565 WriteParamValueToStream<ParamType::T{enum}>(os, paramValue.{union_name}); 566 break;""" 567 568template_param_type_to_string_case = """ case ParamType::T{enum}: 569 return "{type}";""" 570 571 572def script_relative(path): 573 return os.path.join(os.path.dirname(sys.argv[0]), path) 574 575 576def format_entry_point_decl(cmd_name, proto, params, is_explicit_context): 577 comma_if_needed = ", " if len(params) > 0 else "" 578 return template_entry_point_decl.format( 579 name=cmd_name[2:], 580 return_type=proto[:-len(cmd_name)], 581 params=", ".join(params), 582 comma_if_needed=comma_if_needed, 583 explicit_context_suffix="ContextANGLE" if is_explicit_context else "", 584 explicit_context_param="GLeglContext ctx" if is_explicit_context else "", 585 explicit_context_comma=", " if is_explicit_context and len(params) > 0 else "") 586 587 588def type_name_sep_index(param): 589 space = param.rfind(" ") 590 pointer = param.rfind("*") 591 return max(space, pointer) 592 593 594def just_the_type(param): 595 if "*" in param: 596 return param[:type_name_sep_index(param) + 1] 597 return param[:type_name_sep_index(param)] 598 599 600def just_the_name(param): 601 return param[type_name_sep_index(param) + 1:] 602 603 604def make_param(param_type, param_name): 605 return param_type + " " + param_name 606 607 608def just_the_type_packed(param, entry): 609 name = just_the_name(param) 610 if entry.has_key(name): 611 return entry[name] 612 else: 613 return just_the_type(param) 614 615 616def just_the_name_packed(param, reserved_set): 617 name = just_the_name(param) 618 if name in reserved_set: 619 return name + 'Packed' 620 else: 621 return name 622 623 624def param_print_argument(command_node, param): 625 name_only = just_the_name(param) 626 type_only = just_the_type(param) 627 628 if "*" in param: 629 return "(uintptr_t)" + name_only 630 631 if type_only in reinterpret_cast_to_dict: 632 return "(" + reinterpret_cast_to_dict[type_only] + ")" + name_only 633 634 if type_only in static_cast_to_dict: 635 return "static_cast<" + static_cast_to_dict[type_only] + ">(" + name_only + ")" 636 637 if type_only == "GLboolean": 638 return "GLbooleanToString(%s)" % (name_only,) 639 640 if type_only == "GLbitfield": 641 group_name = find_gl_enum_group_in_command(command_node, name_only) 642 return "GLbitfieldToString(GLenumGroup::%s, %s).c_str()" % (group_name, name_only) 643 644 if type_only == "GLenum": 645 group_name = find_gl_enum_group_in_command(command_node, name_only) 646 return "GLenumToString(GLenumGroup::%s, %s)" % (group_name, name_only) 647 648 return name_only 649 650 651def param_format_string(param): 652 if "*" in param: 653 return param + " = 0x%016\" PRIxPTR \"" 654 else: 655 type_only = just_the_type(param) 656 if type_only not in format_dict: 657 raise Exception(type_only + " is not a known type in 'format_dict'") 658 659 return param + " = " + format_dict[type_only] 660 661 662def default_return_value(cmd_name, return_type): 663 if return_type == "void": 664 return "" 665 return "GetDefaultReturnValue<EntryPoint::" + cmd_name[2:] + ", " + return_type + ">()" 666 667 668def get_context_getter_function(cmd_name, is_explicit_context): 669 if is_explicit_context: 670 return "static_cast<gl::Context *>(ctx)" 671 672 lost_context_acceptable_cmds = [ 673 "glGetError", 674 "glGetSync", 675 "glGetQueryObjecti", 676 "glGetProgramiv", 677 "glGetGraphicsResetStatus", 678 "glGetShaderiv", 679 ] 680 for context_lost_entry_pont in lost_context_acceptable_cmds: 681 if cmd_name.startswith(context_lost_entry_pont): 682 return "GetGlobalContext()" 683 return "GetValidGlobalContext()" 684 685 686def strip_suffix(name): 687 for suffix in strip_suffixes: 688 if name.endswith(suffix): 689 name = name[0:-len(suffix)] 690 return name 691 692 693def find_gl_enum_group_in_command(command_node, param_name): 694 group_name = None 695 for param_node in command_node.findall('./param'): 696 if param_node.find('./name').text == param_name: 697 group_name = param_node.attrib.get('group', None) 698 break 699 700 if group_name is None or group_name in registry_xml.unsupported_enum_group_names: 701 group_name = registry_xml.default_enum_group_name 702 703 return group_name 704 705 706def get_packed_enums(cmd_packed_gl_enums, cmd_name): 707 # Always strip the suffix when querying packed enums. 708 return cmd_packed_gl_enums.get(strip_suffix(cmd_name), {}) 709 710 711def format_entry_point_def(command_node, cmd_name, proto, params, is_explicit_context, 712 cmd_packed_gl_enums): 713 packed_gl_enums = get_packed_enums(cmd_packed_gl_enums, cmd_name) 714 internal_params = [just_the_name_packed(param, packed_gl_enums) for param in params] 715 packed_gl_enum_conversions = [] 716 for param in params: 717 name = just_the_name(param) 718 if name in packed_gl_enums: 719 internal_name = name + "Packed" 720 internal_type = packed_gl_enums[name] 721 packed_gl_enum_conversions += [ 722 "\n " + internal_type + " " + internal_name + " = FromGL<" + internal_type + 723 ">(" + name + ");" 724 ] 725 726 pass_params = [param_print_argument(command_node, param) for param in params] 727 format_params = [param_format_string(param) for param in params] 728 return_type = proto[:-len(cmd_name)] 729 default_return = default_return_value(cmd_name, return_type.strip()) 730 event_comment = template_event_comment if cmd_name in no_event_marker_exceptions_list else "" 731 name_lower_no_suffix = strip_suffix(cmd_name[2:3].lower() + cmd_name[3:]) 732 733 format_params = { 734 "name": 735 cmd_name[2:], 736 "name_lower_no_suffix": 737 name_lower_no_suffix, 738 "return_type": 739 return_type, 740 "params": 741 ", ".join(params), 742 "internal_params": 743 ", ".join(internal_params), 744 "packed_gl_enum_conversions": 745 "".join(packed_gl_enum_conversions), 746 "pass_params": 747 ", ".join(pass_params), 748 "comma_if_needed": 749 ", " if len(params) > 0 else "", 750 "validate_params": 751 ", ".join(["context"] + internal_params), 752 "format_params": 753 ", ".join(format_params), 754 "context_getter": 755 get_context_getter_function(cmd_name, is_explicit_context), 756 "event_comment": 757 event_comment, 758 "explicit_context_suffix": 759 "ContextANGLE" if is_explicit_context else "", 760 "explicit_context_param": 761 "GLeglContext ctx" if is_explicit_context else "", 762 "explicit_context_comma": 763 ", " if is_explicit_context and len(params) > 0 else "", 764 "assert_explicit_context": 765 "\nASSERT(context == GetValidGlobalContext());" if is_explicit_context else "" 766 } 767 768 if return_type.strip() == "void": 769 return template_entry_point_no_return.format(**format_params) 770 else: 771 return template_entry_point_with_return.format(**format_params) 772 773 774def get_capture_param_type_name(param_type): 775 776 pointer_count = param_type.count("*") 777 is_const = "const" in param_type.split() 778 779 param_type = param_type.replace("*", "").strip() 780 param_type = " ".join([param for param in param_type.split() if param != "const"]) 781 782 if is_const: 783 param_type += "Const" 784 for x in range(pointer_count): 785 param_type += "Pointer" 786 787 return param_type 788 789 790def format_capture_method(command, cmd_name, proto, params, all_param_types, capture_pointer_funcs, 791 cmd_packed_gl_enums): 792 793 packed_gl_enums = get_packed_enums(cmd_packed_gl_enums, cmd_name) 794 795 params_with_type = get_internal_params( 796 cmd_name, ["const Context *context", "bool isCallValid"] + params, cmd_packed_gl_enums) 797 params_just_name = ", ".join( 798 ["context", "isCallValid"] + 799 [just_the_name_packed(param, packed_gl_enums) for param in params]) 800 801 parameter_captures = [] 802 for param in params: 803 804 param_name = just_the_name_packed(param, packed_gl_enums) 805 param_type = just_the_type_packed(param, packed_gl_enums).strip() 806 807 pointer_count = param_type.count("*") 808 param_type = get_capture_param_type_name(param_type) 809 810 if pointer_count > 0: 811 params = params_just_name 812 capture_name = "Capture%s_%s" % (cmd_name[2:], param_name) 813 capture = template_parameter_capture_pointer.format( 814 name=param_name, type=param_type, capture_name=capture_name, params=params) 815 816 capture_pointer_func = template_parameter_capture_pointer_func.format( 817 name=capture_name, params=params_with_type + ", angle::ParamCapture *paramCapture") 818 capture_pointer_funcs += [capture_pointer_func] 819 elif param_type in ('GLenum', 'GLbitfield'): 820 gl_enum_group = find_gl_enum_group_in_command(command, param_name) 821 capture = template_parameter_capture_gl_enum.format( 822 name=param_name, type=param_type, group=gl_enum_group) 823 else: 824 capture = template_parameter_capture_value.format(name=param_name, type=param_type) 825 826 all_param_types.add(param_type) 827 828 parameter_captures += [capture] 829 830 return_type = proto[:-len(cmd_name)].strip() 831 832 format_args = { 833 "full_name": cmd_name, 834 "short_name": cmd_name[2:], 835 "params_with_type": params_with_type, 836 "params_just_name": params_just_name, 837 "parameter_captures": "\n ".join(parameter_captures), 838 "return_value_type_original": return_type, 839 "return_value_type_custom": get_capture_param_type_name(return_type) 840 } 841 842 if return_type == "void": 843 return template_capture_method_no_return_value.format(**format_args) 844 else: 845 return template_capture_method_with_return_value.format(**format_args) 846 847 848def get_internal_params(cmd_name, params, cmd_packed_gl_enums): 849 packed_gl_enums = get_packed_enums(cmd_packed_gl_enums, cmd_name) 850 return ", ".join([ 851 make_param( 852 just_the_type_packed(param, packed_gl_enums), 853 just_the_name_packed(param, packed_gl_enums)) for param in params 854 ]) 855 856 857def format_context_decl(cmd_name, proto, params, template, cmd_packed_gl_enums): 858 internal_params = get_internal_params(cmd_name, params, cmd_packed_gl_enums) 859 860 return_type = proto[:-len(cmd_name)] 861 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:] 862 name_lower_no_suffix = strip_suffix(name_lower_no_suffix) 863 864 return template.format( 865 return_type=return_type, 866 name_lower_no_suffix=name_lower_no_suffix, 867 internal_params=internal_params) 868 869 870def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context): 871 internal_params = [just_the_name(param) for param in params] 872 return_type = proto[:-len(cmd_name)] 873 874 return libgles_entry_point_def.format( 875 name=cmd_name[2:], 876 return_type=return_type, 877 params=", ".join(params), 878 internal_params=", ".join(internal_params), 879 explicit_context_suffix="ContextANGLE" if is_explicit_context else "", 880 explicit_context_param="GLeglContext ctx" if is_explicit_context else "", 881 explicit_context_comma=", " if is_explicit_context and len(params) > 0 else "", 882 explicit_context_internal_param="ctx" if is_explicit_context else "") 883 884 885def format_validation_proto(cmd_name, params, cmd_packed_gl_enums): 886 internal_params = get_internal_params(cmd_name, ["Context *context"] + params, 887 cmd_packed_gl_enums) 888 return template_validation_proto % (cmd_name[2:], internal_params) 889 890 891def format_capture_proto(cmd_name, proto, params, cmd_packed_gl_enums): 892 internal_params = get_internal_params( 893 cmd_name, ["const Context *context", "bool isCallValid"] + params, cmd_packed_gl_enums) 894 return_type = proto[:-len(cmd_name)].strip() 895 if return_type != "void": 896 internal_params += ", %s returnValue" % return_type 897 return template_capture_proto % (cmd_name[2:], internal_params) 898 899 900def path_to(folder, file): 901 return os.path.join(script_relative(".."), "src", folder, file) 902 903 904def get_entry_points(all_commands, commands, is_explicit_context, is_wgl, all_param_types, 905 cmd_packed_gl_enums): 906 decls = [] 907 defs = [] 908 export_defs = [] 909 validation_protos = [] 910 capture_protos = [] 911 capture_methods = [] 912 capture_pointer_funcs = [] 913 914 for command in all_commands: 915 proto = command.find('proto') 916 cmd_name = proto.find('name').text 917 918 if is_wgl: 919 cmd_name = cmd_name if cmd_name[:3] == 'wgl' else 'wgl' + cmd_name 920 921 if cmd_name not in commands: 922 continue 923 924 param_text = ["".join(param.itertext()) for param in command.findall('param')] 925 proto_text = "".join(proto.itertext()) 926 decls.append( 927 format_entry_point_decl(cmd_name, proto_text, param_text, is_explicit_context)) 928 defs.append( 929 format_entry_point_def(command, cmd_name, proto_text, param_text, is_explicit_context, 930 cmd_packed_gl_enums)) 931 932 export_defs.append( 933 format_libgles_entry_point_def(cmd_name, proto_text, param_text, is_explicit_context)) 934 935 validation_protos.append( 936 format_validation_proto(cmd_name, param_text, cmd_packed_gl_enums)) 937 capture_protos.append( 938 format_capture_proto(cmd_name, proto_text, param_text, cmd_packed_gl_enums)) 939 capture_methods.append( 940 format_capture_method(command, cmd_name, proto_text, param_text, all_param_types, 941 capture_pointer_funcs, cmd_packed_gl_enums)) 942 943 return decls, defs, export_defs, validation_protos, capture_protos, capture_methods, capture_pointer_funcs 944 945 946def get_decls(formatter, all_commands, gles_commands, already_included, overloaded, 947 cmd_packed_gl_enums): 948 decls = [] 949 for command in all_commands: 950 proto = command.find('proto') 951 cmd_name = proto.find('name').text 952 953 if cmd_name not in gles_commands: 954 continue 955 956 if cmd_name in overloaded: 957 continue 958 959 name_no_suffix = strip_suffix(cmd_name) 960 if name_no_suffix in already_included: 961 continue 962 963 param_text = ["".join(param.itertext()) for param in command.findall('param')] 964 proto_text = "".join(proto.itertext()) 965 decls.append( 966 format_context_decl(cmd_name, proto_text, param_text, formatter, cmd_packed_gl_enums)) 967 968 return decls 969 970 971def get_glext_decls(all_commands, gles_commands, version, is_explicit_context): 972 glext_ptrs = [] 973 glext_protos = [] 974 is_gles1 = False 975 976 if (version == ""): 977 is_gles1 = True 978 979 for command in all_commands: 980 proto = command.find('proto') 981 cmd_name = proto.find('name').text 982 983 if cmd_name not in gles_commands: 984 continue 985 986 param_text = ["".join(param.itertext()) for param in command.findall('param')] 987 proto_text = "".join(proto.itertext()) 988 989 return_type = proto_text[:-len(cmd_name)] 990 params = ", ".join(param_text) 991 992 format_params = { 993 "apicall": "GL_API" if is_gles1 else "GL_APICALL", 994 "name": cmd_name, 995 "name_upper": cmd_name.upper(), 996 "return_type": return_type, 997 "params": params, 998 "explicit_context_comma": ", " if is_explicit_context and len(params) > 0 else "", 999 "explicit_context_suffix": "ContextANGLE" if is_explicit_context else "", 1000 "explicit_context_suffix_upper": "CONTEXTANGLE" if is_explicit_context else "", 1001 "explicit_context_param": "GLeglContext ctx" if is_explicit_context else "" 1002 } 1003 1004 glext_ptrs.append(template_glext_function_pointer.format(**format_params)) 1005 glext_protos.append(template_glext_function_prototype.format(**format_params)) 1006 1007 return glext_ptrs, glext_protos 1008 1009 1010def write_file(annotation, comment, template, entry_points, suffix, includes, lib, file): 1011 content = template.format( 1012 script_name=os.path.basename(sys.argv[0]), 1013 data_source_name=file, 1014 year=date.today().year, 1015 annotation_lower=annotation.lower(), 1016 annotation_upper=annotation.upper(), 1017 comment=comment, 1018 lib=lib.upper(), 1019 includes=includes, 1020 entry_points=entry_points) 1021 1022 path = path_to(lib, "entry_points_{}_autogen.{}".format(annotation.lower(), suffix)) 1023 1024 with open(path, "w") as out: 1025 out.write(content) 1026 out.close() 1027 1028 1029def write_export_files(entry_points, includes, source, lib_name, lib_description): 1030 content = template_lib_entry_point_source.format( 1031 script_name=os.path.basename(sys.argv[0]), 1032 data_source_name=source, 1033 year=date.today().year, 1034 lib_name=lib_name, 1035 lib_description=lib_description, 1036 includes=includes, 1037 entry_points=entry_points) 1038 1039 path = path_to(lib_name, "{}_autogen.cpp".format(lib_name)) 1040 1041 with open(path, "w") as out: 1042 out.write(content) 1043 out.close() 1044 1045 1046def write_context_api_decls(template, decls, api): 1047 for ver in decls['core'].keys(): 1048 interface_lines = [] 1049 1050 for i in decls['core'][ver]: 1051 interface_lines.append(i) 1052 1053 annotation = '{}_{}_{}'.format(api, ver[0], ver[1]) 1054 version = '{}_{}'.format(ver[0], ver[1]) 1055 1056 content = template.format( 1057 annotation_lower=annotation.lower(), 1058 annotation_upper=annotation.upper(), 1059 script_name=os.path.basename(sys.argv[0]), 1060 data_source_name="gl.xml", 1061 year=date.today().year, 1062 version=version, 1063 interface="\n".join(interface_lines)) 1064 1065 path = path_to("libANGLE", "Context_%s_autogen.h" % annotation.lower()) 1066 1067 with open(path, "w") as out: 1068 out.write(content) 1069 out.close() 1070 1071 if 'exts' in decls.keys(): 1072 interface_lines = [] 1073 for annotation in decls['exts'].keys(): 1074 interface_lines.append("\\\n /* " + annotation + " */ \\\n\\") 1075 1076 for extname in sorted(decls['exts'][annotation].keys()): 1077 interface_lines.append(" /* " + extname + " */ \\") 1078 interface_lines.extend(decls['exts'][annotation][extname]) 1079 1080 content = template.format( 1081 annotation_lower='gles_ext', 1082 annotation_upper='GLES_EXT', 1083 script_name=os.path.basename(sys.argv[0]), 1084 data_source_name="gl.xml", 1085 year=date.today().year, 1086 version='EXT', 1087 interface="\n".join(interface_lines)) 1088 1089 path = path_to("libANGLE", "Context_gles_ext_autogen.h") 1090 1091 with open(path, "w") as out: 1092 out.write(content) 1093 out.close() 1094 1095 1096def write_glext_explicit_context_inc(version, ptrs, protos): 1097 folder_version = version if version != "31" else "3" 1098 1099 content = template_glext_explicit_context_inc.format( 1100 script_name=os.path.basename(sys.argv[0]), 1101 data_source_name="gl.xml and gl_angle_ext.xml", 1102 year=date.today().year, 1103 version=version, 1104 function_pointers=ptrs, 1105 function_prototypes=protos) 1106 1107 path = os.path.join( 1108 script_relative(".."), "include", "GLES{}".format(folder_version), 1109 "gl{}ext_explicit_context_autogen.inc".format(version)) 1110 1111 with open(path, "w") as out: 1112 out.write(content) 1113 out.close() 1114 1115 1116def write_validation_header(annotation, comment, protos, source): 1117 content = template_validation_header.format( 1118 script_name=os.path.basename(sys.argv[0]), 1119 data_source_name=source, 1120 year=date.today().year, 1121 annotation=annotation, 1122 comment=comment, 1123 prototypes="\n".join(protos)) 1124 1125 path = path_to("libANGLE", "validation%s_autogen.h" % annotation) 1126 1127 with open(path, "w") as out: 1128 out.write(content) 1129 out.close() 1130 1131 1132def write_capture_header(annotation, comment, protos, capture_pointer_funcs): 1133 content = template_capture_header.format( 1134 script_name=os.path.basename(sys.argv[0]), 1135 data_source_name="gl.xml and gl_angle_ext.xml", 1136 year=date.today().year, 1137 annotation=annotation, 1138 comment=comment, 1139 prototypes="\n".join(["\n// Method Captures\n"] + protos + ["\n// Parameter Captures\n"] + 1140 capture_pointer_funcs)) 1141 1142 path = path_to("libANGLE", "capture_gles_%s_autogen.h" % annotation) 1143 1144 with open(path, "w") as out: 1145 out.write(content) 1146 out.close() 1147 1148 1149def write_capture_source(annotation_with_dash, annotation_no_dash, comment, capture_methods): 1150 content = template_capture_source.format( 1151 script_name=os.path.basename(sys.argv[0]), 1152 data_source_name="gl.xml and gl_angle_ext.xml", 1153 year=date.today().year, 1154 annotation_with_dash=annotation_with_dash, 1155 annotation_no_dash=annotation_no_dash, 1156 comment=comment, 1157 capture_methods="\n".join(capture_methods)) 1158 1159 path = path_to("libANGLE", "capture_gles_%s_autogen.cpp" % annotation_with_dash) 1160 1161 with open(path, "w") as out: 1162 out.write(content) 1163 out.close() 1164 1165 1166def is_packed_enum_param_type(param_type): 1167 return param_type[0:2] != "GL" and "void" not in param_type 1168 1169 1170def get_gl_pointer_type(param_type): 1171 1172 if "ConstPointerPointer" in param_type: 1173 return "const " + param_type.replace("ConstPointerPointer", "") + " * const *" 1174 1175 if "ConstPointer" in param_type: 1176 return "const " + param_type.replace("ConstPointer", "") + " *" 1177 1178 if "PointerPointer" in param_type: 1179 return param_type.replace("PointerPointer", "") + " **" 1180 1181 if "Pointer" in param_type: 1182 return param_type.replace("Pointer", "") + " *" 1183 1184 return param_type 1185 1186 1187def get_param_type_type(param_type): 1188 1189 if is_packed_enum_param_type(param_type): 1190 param_type = "gl::" + param_type 1191 1192 return get_gl_pointer_type(param_type) 1193 1194 1195def get_gl_param_type_type(param_type): 1196 if not is_packed_enum_param_type(param_type): 1197 return get_gl_pointer_type(param_type) 1198 else: 1199 base_type = param_type.replace("Pointer", "").replace("Const", "") 1200 if base_type[-2:] == "ID": 1201 replace_type = "GLuint" 1202 else: 1203 replace_type = "GLenum" 1204 param_type = param_type.replace(base_type, replace_type) 1205 return get_gl_pointer_type(param_type) 1206 1207 1208def get_param_type_union_name(param_type): 1209 return param_type + "Val" 1210 1211 1212def format_param_type_union_type(param_type): 1213 return "%s %s;" % (get_param_type_type(param_type), get_param_type_union_name(param_type)) 1214 1215 1216def format_set_param_val_specialization(param_type): 1217 return template_set_param_val_specialization.format( 1218 enum=param_type, 1219 type=get_param_type_type(param_type), 1220 union_name=get_param_type_union_name(param_type)) 1221 1222 1223def format_init_param_value_case(param_type): 1224 return template_init_param_value_case.format(enum=param_type) 1225 1226 1227def format_write_param_type_to_stream_case(param_type): 1228 return template_write_param_type_to_stream_case.format( 1229 enum=param_type, union_name=get_param_type_union_name(param_type)) 1230 1231 1232def write_capture_helper_header(all_param_types): 1233 1234 param_types = "\n ".join(["T%s," % t for t in all_param_types]) 1235 param_union_values = "\n ".join([format_param_type_union_type(t) for t in all_param_types]) 1236 set_param_val_specializations = "\n\n".join( 1237 [format_set_param_val_specialization(t) for t in all_param_types]) 1238 init_param_value_cases = "\n".join([format_init_param_value_case(t) for t in all_param_types]) 1239 1240 content = template_frame_capture_utils_header.format( 1241 script_name=os.path.basename(sys.argv[0]), 1242 data_source_name="gl.xml and gl_angle_ext.xml", 1243 year=date.today().year, 1244 param_types=param_types, 1245 param_union_values=param_union_values, 1246 set_param_val_specializations=set_param_val_specializations, 1247 init_param_value_cases=init_param_value_cases) 1248 1249 path = path_to("libANGLE", "frame_capture_utils_autogen.h") 1250 1251 with open(path, "w") as out: 1252 out.write(content) 1253 out.close() 1254 1255 1256def format_param_type_to_string_case(param_type): 1257 return template_param_type_to_string_case.format( 1258 enum=param_type, type=get_gl_param_type_type(param_type)) 1259 1260 1261def write_capture_helper_source(all_param_types): 1262 1263 write_param_type_to_stream_cases = "\n".join( 1264 [format_write_param_type_to_stream_case(t) for t in all_param_types]) 1265 param_type_to_string_cases = "\n".join( 1266 [format_param_type_to_string_case(t) for t in all_param_types]) 1267 1268 content = template_frame_capture_utils_source.format( 1269 script_name=os.path.basename(sys.argv[0]), 1270 data_source_name="gl.xml and gl_angle_ext.xml", 1271 year=date.today().year, 1272 write_param_type_to_stream_cases=write_param_type_to_stream_cases, 1273 param_type_to_string_cases=param_type_to_string_cases) 1274 1275 path = path_to("libANGLE", "frame_capture_utils_autogen.cpp") 1276 1277 with open(path, "w") as out: 1278 out.write(content) 1279 out.close() 1280 1281 1282def write_windows_def_file(data_source_name, lib, libexport, folder, exports): 1283 1284 content = template_windows_def_file.format( 1285 script_name=os.path.basename(sys.argv[0]), 1286 data_source_name=data_source_name, 1287 exports="\n".join(exports), 1288 year=date.today().year, 1289 lib=libexport) 1290 1291 path = path_to(folder, "%s_autogen.def" % lib) 1292 1293 with open(path, "w") as out: 1294 out.write(content) 1295 out.close() 1296 1297 1298def get_exports(commands, fmt=None): 1299 if fmt: 1300 return [" %s" % fmt(cmd) for cmd in sorted(commands)] 1301 else: 1302 return [" %s" % cmd for cmd in sorted(commands)] 1303 1304 1305# Get EGL exports 1306def get_egl_exports(): 1307 1308 egl = registry_xml.RegistryXML('egl.xml', 'egl_angle_ext.xml') 1309 exports = [] 1310 1311 capser = lambda fn: "EGL_" + fn[3:] 1312 1313 for major, minor in [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]: 1314 annotation = "{}_{}".format(major, minor) 1315 name_prefix = "EGL_VERSION_" 1316 1317 feature_name = "{}{}".format(name_prefix, annotation) 1318 1319 egl.AddCommands(feature_name, annotation) 1320 1321 commands = egl.commands[annotation] 1322 1323 if len(commands) == 0: 1324 continue 1325 1326 exports.append("\n ; EGL %d.%d" % (major, minor)) 1327 exports += get_exports(commands, capser) 1328 1329 egl.AddExtensionCommands(registry_xml.supported_egl_extensions, ['egl']) 1330 1331 for extension_name, ext_cmd_names in sorted(egl.ext_data.iteritems()): 1332 1333 if len(ext_cmd_names) == 0: 1334 continue 1335 1336 exports.append("\n ; %s" % extension_name) 1337 exports += get_exports(ext_cmd_names, capser) 1338 1339 return exports 1340 1341 1342def main(): 1343 1344 # auto_script parameters. 1345 if len(sys.argv) > 1: 1346 inputs = ['entry_point_packed_gl_enums.json'] + registry_xml.xml_inputs 1347 outputs = [ 1348 '../src/libANGLE/Context_gl_1_0_autogen.h', 1349 '../src/libANGLE/Context_gl_1_1_autogen.h', 1350 '../src/libANGLE/Context_gl_1_2_autogen.h', 1351 '../src/libANGLE/Context_gl_1_3_autogen.h', 1352 '../src/libANGLE/Context_gl_1_4_autogen.h', 1353 '../src/libANGLE/Context_gl_1_5_autogen.h', 1354 '../src/libANGLE/Context_gl_2_0_autogen.h', 1355 '../src/libANGLE/Context_gl_2_1_autogen.h', 1356 '../src/libANGLE/Context_gl_3_0_autogen.h', 1357 '../src/libANGLE/Context_gl_3_1_autogen.h', 1358 '../src/libANGLE/Context_gl_3_2_autogen.h', 1359 '../src/libANGLE/Context_gl_3_3_autogen.h', 1360 '../src/libANGLE/Context_gl_4_0_autogen.h', 1361 '../src/libANGLE/Context_gl_4_1_autogen.h', 1362 '../src/libANGLE/Context_gl_4_2_autogen.h', 1363 '../src/libANGLE/Context_gl_4_3_autogen.h', 1364 '../src/libANGLE/Context_gl_4_4_autogen.h', 1365 '../src/libANGLE/Context_gl_4_5_autogen.h', 1366 '../src/libANGLE/Context_gl_4_6_autogen.h', 1367 '../src/libANGLE/Context_gles_1_0_autogen.h', 1368 '../src/libANGLE/Context_gles_2_0_autogen.h', 1369 '../src/libANGLE/Context_gles_3_0_autogen.h', 1370 '../src/libANGLE/Context_gles_3_1_autogen.h', 1371 '../src/libANGLE/Context_gles_ext_autogen.h', 1372 '../src/libANGLE/capture_gles_1_0_autogen.cpp', 1373 '../src/libANGLE/capture_gles_1_0_autogen.h', 1374 '../src/libANGLE/capture_gles_2_0_autogen.cpp', 1375 '../src/libANGLE/capture_gles_2_0_autogen.h', 1376 '../src/libANGLE/capture_gles_3_0_autogen.cpp', 1377 '../src/libANGLE/capture_gles_3_0_autogen.h', 1378 '../src/libANGLE/capture_gles_3_1_autogen.cpp', 1379 '../src/libANGLE/capture_gles_3_1_autogen.h', 1380 '../src/libANGLE/capture_gles_ext_autogen.cpp', 1381 '../src/libANGLE/capture_gles_ext_autogen.h', 1382 '../src/libANGLE/frame_capture_utils_autogen.cpp', 1383 '../src/libANGLE/frame_capture_utils_autogen.h', 1384 '../src/libANGLE/entry_points_enum_autogen.cpp', 1385 '../src/libANGLE/entry_points_enum_autogen.h', 1386 '../src/libANGLE/validationES1_autogen.h', 1387 '../src/libANGLE/validationES2_autogen.h', 1388 '../src/libANGLE/validationES31_autogen.h', 1389 '../src/libANGLE/validationES3_autogen.h', 1390 '../src/libANGLE/validationESEXT_autogen.h', 1391 '../src/libANGLE/validationGL1_autogen.h', 1392 '../src/libANGLE/validationGL2_autogen.h', 1393 '../src/libANGLE/validationGL3_autogen.h', 1394 '../src/libANGLE/validationGL4_autogen.h', 1395 '../src/libANGLE/validationGL11_autogen.h', 1396 '../src/libANGLE/validationGL12_autogen.h', 1397 '../src/libANGLE/validationGL13_autogen.h', 1398 '../src/libANGLE/validationGL14_autogen.h', 1399 '../src/libANGLE/validationGL15_autogen.h', 1400 '../src/libANGLE/validationGL21_autogen.h', 1401 '../src/libANGLE/validationGL31_autogen.h', 1402 '../src/libANGLE/validationGL32_autogen.h', 1403 '../src/libANGLE/validationGL33_autogen.h', 1404 '../src/libANGLE/validationGL41_autogen.h', 1405 '../src/libANGLE/validationGL42_autogen.h', 1406 '../src/libANGLE/validationGL43_autogen.h', 1407 '../src/libANGLE/validationGL44_autogen.h', 1408 '../src/libANGLE/validationGL45_autogen.h', 1409 '../src/libANGLE/validationGL46_autogen.h', 1410 '../src/libGLESv2/entry_points_gles_1_0_autogen.cpp', 1411 '../src/libGLESv2/entry_points_gles_1_0_autogen.h', 1412 '../src/libGLESv2/entry_points_gles_2_0_autogen.cpp', 1413 '../src/libGLESv2/entry_points_gles_2_0_autogen.h', 1414 '../src/libGLESv2/entry_points_gles_3_0_autogen.cpp', 1415 '../src/libGLESv2/entry_points_gles_3_0_autogen.h', 1416 '../src/libGLESv2/entry_points_gles_3_1_autogen.cpp', 1417 '../src/libGLESv2/entry_points_gles_3_1_autogen.h', 1418 '../src/libGLESv2/entry_points_gles_ext_autogen.cpp', 1419 '../src/libGLESv2/entry_points_gles_ext_autogen.h', 1420 '../src/libGLESv2/libGLESv2_autogen.cpp', 1421 '../src/libGLESv2/libGLESv2_autogen.def', 1422 '../src/libGLESv2/libGLESv2_no_capture_autogen.def', 1423 '../src/libGLESv2/libGLESv2_with_capture_autogen.def', 1424 '../src/libGL/entry_points_gl_1_0_autogen.cpp', 1425 '../src/libGL/entry_points_gl_1_0_autogen.h', 1426 '../src/libGL/entry_points_gl_1_1_autogen.cpp', 1427 '../src/libGL/entry_points_gl_1_1_autogen.h', 1428 '../src/libGL/entry_points_gl_1_2_autogen.cpp', 1429 '../src/libGL/entry_points_gl_1_2_autogen.h', 1430 '../src/libGL/entry_points_gl_1_3_autogen.cpp', 1431 '../src/libGL/entry_points_gl_1_3_autogen.h', 1432 '../src/libGL/entry_points_gl_1_4_autogen.cpp', 1433 '../src/libGL/entry_points_gl_1_4_autogen.h', 1434 '../src/libGL/entry_points_gl_1_5_autogen.cpp', 1435 '../src/libGL/entry_points_gl_1_5_autogen.h', 1436 '../src/libGL/entry_points_gl_2_0_autogen.cpp', 1437 '../src/libGL/entry_points_gl_2_0_autogen.h', 1438 '../src/libGL/entry_points_gl_2_1_autogen.cpp', 1439 '../src/libGL/entry_points_gl_2_1_autogen.h', 1440 '../src/libGL/entry_points_gl_3_0_autogen.cpp', 1441 '../src/libGL/entry_points_gl_3_0_autogen.h', 1442 '../src/libGL/entry_points_gl_3_1_autogen.cpp', 1443 '../src/libGL/entry_points_gl_3_1_autogen.h', 1444 '../src/libGL/entry_points_gl_3_2_autogen.cpp', 1445 '../src/libGL/entry_points_gl_3_2_autogen.h', 1446 '../src/libGL/entry_points_gl_3_3_autogen.cpp', 1447 '../src/libGL/entry_points_gl_3_3_autogen.h', 1448 '../src/libGL/entry_points_gl_4_0_autogen.cpp', 1449 '../src/libGL/entry_points_gl_4_0_autogen.h', 1450 '../src/libGL/entry_points_gl_4_1_autogen.cpp', 1451 '../src/libGL/entry_points_gl_4_1_autogen.h', 1452 '../src/libGL/entry_points_gl_4_2_autogen.cpp', 1453 '../src/libGL/entry_points_gl_4_2_autogen.h', 1454 '../src/libGL/entry_points_gl_4_3_autogen.cpp', 1455 '../src/libGL/entry_points_gl_4_3_autogen.h', 1456 '../src/libGL/entry_points_gl_4_4_autogen.cpp', 1457 '../src/libGL/entry_points_gl_4_4_autogen.h', 1458 '../src/libGL/entry_points_gl_4_5_autogen.cpp', 1459 '../src/libGL/entry_points_gl_4_5_autogen.h', 1460 '../src/libGL/entry_points_gl_4_6_autogen.cpp', 1461 '../src/libGL/entry_points_gl_4_6_autogen.h', 1462 '../src/libGL/libGL_autogen.cpp', 1463 '../src/libGL/libGL_autogen.def', 1464 ] 1465 1466 if sys.argv[1] == 'inputs': 1467 print ','.join(inputs) 1468 elif sys.argv[1] == 'outputs': 1469 print ','.join(outputs) 1470 else: 1471 print('Invalid script parameters') 1472 return 1 1473 return 0 1474 1475 with open(script_relative('entry_point_packed_gl_enums.json')) as f: 1476 cmd_packed_gl_enums = json.loads(f.read()) 1477 1478 glesdecls = {} 1479 glesdecls['core'] = {} 1480 glesdecls['exts'] = {} 1481 for ver in [(1, 0), (2, 0), (3, 0), (3, 1)]: 1482 glesdecls['core'][ver] = [] 1483 for ver in ['GLES1 Extensions', 'GLES2+ Extensions', 'ANGLE Extensions']: 1484 glesdecls['exts'][ver] = {} 1485 1486 libgles_ep_defs = [] 1487 libgles_ep_exports = [] 1488 1489 xml = registry_xml.RegistryXML('gl.xml', 'gl_angle_ext.xml') 1490 1491 # Stores core commands to keep track of duplicates 1492 all_commands_no_suffix = [] 1493 all_commands_with_suffix = [] 1494 all_gles_param_types = set() 1495 1496 # First run through the main GLES entry points. Since ES2+ is the primary use 1497 # case, we go through those first and then add ES1-only APIs at the end. 1498 for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]: 1499 version = "{}_{}".format(major_version, minor_version) 1500 annotation = "GLES_{}".format(version) 1501 name_prefix = "GL_ES_VERSION_" 1502 1503 is_gles1 = major_version == 1 1504 if is_gles1: 1505 name_prefix = "GL_VERSION_ES_CM_" 1506 1507 comment = version.replace("_", ".") 1508 feature_name = "{}{}".format(name_prefix, version) 1509 1510 xml.AddCommands(feature_name, version) 1511 1512 gles_commands = xml.commands[version] 1513 all_commands = xml.all_commands 1514 all_commands_no_suffix.extend(xml.commands[version]) 1515 all_commands_with_suffix.extend(xml.commands[version]) 1516 1517 decls, defs, libgles_defs, validation_protos, capture_protos, capture_methods, capture_pointer_funcs = get_entry_points( 1518 all_commands, gles_commands, False, False, all_gles_param_types, cmd_packed_gl_enums) 1519 1520 # Write the version as a comment before the first EP. 1521 libgles_defs.insert(0, "\n// OpenGL ES %s" % comment) 1522 libgles_ep_exports.append("\n ; OpenGL ES %s" % comment) 1523 1524 libgles_ep_defs += libgles_defs 1525 libgles_ep_exports += get_exports(gles_commands) 1526 1527 major_if_not_one = major_version if major_version != 1 else "" 1528 minor_if_not_zero = minor_version if minor_version != 0 else "" 1529 1530 header_includes = template_header_includes.format( 1531 major=major_if_not_one, minor=minor_if_not_zero) 1532 1533 # We include the platform.h header since it undefines the conflicting MemoryBarrier macro. 1534 if major_version == 3 and minor_version == 1: 1535 header_includes += "\n#include \"common/platform.h\"\n" 1536 1537 version_annotation = "%s%s" % (major_version, minor_if_not_zero) 1538 source_includes = template_sources_includes.format( 1539 header_version=annotation.lower(), validation_header_version="ES" + version_annotation) 1540 1541 write_file(annotation, "GLES " + comment, template_entry_point_header, "\n".join(decls), 1542 "h", header_includes, "libGLESv2", "gl.xml") 1543 write_file(annotation, "GLES " + comment, template_entry_point_source, "\n".join(defs), 1544 "cpp", source_includes, "libGLESv2", "gl.xml") 1545 1546 gles_overloaded = gles1_overloaded if is_gles1 else [] 1547 glesdecls['core'][(major_version, minor_version)] = get_decls( 1548 context_decl_format, all_commands, gles_commands, [], gles_overloaded, 1549 cmd_packed_gl_enums) 1550 1551 validation_annotation = "ES%s%s" % (major_version, minor_if_not_zero) 1552 write_validation_header(validation_annotation, "ES %s" % comment, validation_protos, 1553 "gl.xml and gl_angle_ext.xml") 1554 1555 write_capture_header(version, comment, capture_protos, capture_pointer_funcs) 1556 write_capture_source(version, validation_annotation, comment, capture_methods) 1557 1558 # After we finish with the main entry points, we process the extensions. 1559 extension_defs = [] 1560 extension_decls = [] 1561 extension_commands = [] 1562 1563 # Accumulated validation prototypes. 1564 ext_validation_protos = [] 1565 ext_capture_protos = [] 1566 ext_capture_methods = [] 1567 ext_capture_param_funcs = [] 1568 1569 for gles1ext in registry_xml.gles1_extensions: 1570 glesdecls['exts']['GLES1 Extensions'][gles1ext] = [] 1571 for glesext in registry_xml.gles_extensions: 1572 glesdecls['exts']['GLES2+ Extensions'][glesext] = [] 1573 for angle_ext in registry_xml.angle_extensions: 1574 glesdecls['exts']['ANGLE Extensions'][angle_ext] = [] 1575 1576 xml.AddExtensionCommands(registry_xml.supported_extensions, ['gles2', 'gles1']) 1577 1578 for extension_name, ext_cmd_names in sorted(xml.ext_data.iteritems()): 1579 extension_commands.extend(xml.ext_data[extension_name]) 1580 1581 # Detect and filter duplicate extensions. 1582 decls, defs, libgles_defs, validation_protos, capture_protos, capture_methods, capture_param_funcs = get_entry_points( 1583 xml.all_commands, ext_cmd_names, False, False, all_gles_param_types, 1584 cmd_packed_gl_enums) 1585 1586 # Avoid writing out entry points defined by a prior extension. 1587 for dupe in xml.ext_dupes[extension_name]: 1588 msg = "// {} is already defined.\n".format(dupe[2:]) 1589 defs.append(msg) 1590 1591 # Write the extension name as a comment before the first EP. 1592 comment = "\n// {}".format(extension_name) 1593 defs.insert(0, comment) 1594 decls.insert(0, comment) 1595 libgles_defs.insert(0, comment) 1596 libgles_ep_exports.append("\n ; %s" % extension_name) 1597 1598 extension_defs += defs 1599 extension_decls += decls 1600 1601 ext_validation_protos += [comment] + validation_protos 1602 ext_capture_protos += [comment] + capture_protos 1603 ext_capture_methods += capture_methods 1604 ext_capture_param_funcs += capture_param_funcs 1605 1606 libgles_ep_defs += libgles_defs 1607 libgles_ep_exports += get_exports(ext_cmd_names) 1608 1609 if (extension_name in registry_xml.gles1_extensions and 1610 extension_name not in gles1_no_context_decl_extensions): 1611 glesdecls['exts']['GLES1 Extensions'][extension_name] = get_decls( 1612 context_decl_format, all_commands, ext_cmd_names, all_commands_no_suffix, 1613 gles1_overloaded, cmd_packed_gl_enums) 1614 if extension_name in registry_xml.gles_extensions: 1615 glesdecls['exts']['GLES2+ Extensions'][extension_name] = get_decls( 1616 context_decl_format, all_commands, ext_cmd_names, all_commands_no_suffix, [], 1617 cmd_packed_gl_enums) 1618 if extension_name in registry_xml.angle_extensions: 1619 glesdecls['exts']['ANGLE Extensions'][extension_name] = get_decls( 1620 context_decl_format, all_commands, ext_cmd_names, all_commands_no_suffix, [], 1621 cmd_packed_gl_enums) 1622 1623 for name in extension_commands: 1624 all_commands_with_suffix.append(name) 1625 all_commands_no_suffix.append(strip_suffix(name)) 1626 1627 # Special handling for EGL_ANGLE_explicit_context extension 1628 if registry_xml.support_EGL_ANGLE_explicit_context: 1629 comment = "\n// EGL_ANGLE_explicit_context" 1630 extension_defs.append(comment) 1631 extension_decls.append(comment) 1632 libgles_ep_defs.append(comment) 1633 1634 cmds = xml.all_cmd_names.get_all_commands() 1635 1636 # Get the explicit context entry points 1637 decls, defs, libgles_defs, validation_protos, capture_protos, capture_methods, capture_param_funcs = get_entry_points( 1638 xml.all_commands, cmds, True, False, all_gles_param_types, cmd_packed_gl_enums) 1639 1640 # Append the explicit context entry points 1641 extension_decls += decls 1642 extension_defs += defs 1643 libgles_ep_defs += libgles_defs 1644 1645 libgles_ep_exports.append("\n ; EGL_ANGLE_explicit_context") 1646 libgles_ep_exports += get_exports(cmds, lambda x: "%sContextANGLE" % x) 1647 1648 # Generate .inc files for extension function pointers and declarations 1649 for major, minor in [[2, 0], [3, 0], [3, 1], [1, 0]]: 1650 annotation = "{}_{}".format(major, minor) 1651 1652 major_if_not_one = major if major != 1 else "" 1653 minor_if_not_zero = minor if minor != 0 else "" 1654 version = "{}{}".format(major_if_not_one, minor_if_not_zero) 1655 1656 glext_ptrs, glext_protos = get_glext_decls(all_commands, 1657 xml.all_cmd_names.get_commands(annotation), 1658 version, True) 1659 1660 glext_ext_ptrs = [] 1661 glext_ext_protos = [] 1662 1663 # Append extensions for 1.0 and 2.0 1664 if (annotation == "1_0"): 1665 glext_ext_ptrs, glext_ext_protos = get_glext_decls( 1666 all_commands, xml.all_cmd_names.get_commands("glext"), version, True) 1667 elif (annotation == "2_0"): 1668 glext_ext_ptrs, glext_ext_protos = get_glext_decls( 1669 all_commands, xml.all_cmd_names.get_commands("gl2ext"), version, True) 1670 1671 glext_ptrs += glext_ext_ptrs 1672 glext_protos += glext_ext_protos 1673 1674 write_glext_explicit_context_inc(version, "\n".join(glext_ptrs), 1675 "\n".join(glext_protos)) 1676 1677 # Now we generate entry points for the desktop implementation 1678 gldecls = {} 1679 gldecls['core'] = {} 1680 for ver in [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 0), (2, 1), (3, 0), (3, 1), 1681 (3, 2), (3, 3), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6)]: 1682 gldecls['core'][ver] = [] 1683 1684 libgl_ep_defs = [] 1685 libgl_ep_exports = [] 1686 1687 glxml = registry_xml.RegistryXML('gl.xml') 1688 1689 for major_version, minor_version in [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 0], 1690 [2, 1], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], 1691 [4, 2], [4, 3], [4, 4], [4, 5], [4, 6]]: 1692 version = "{}_{}".format(major_version, minor_version) 1693 annotation = "GL_{}".format(version) 1694 name_prefix = "GL_VERSION_" 1695 1696 comment = version.replace("_", ".") 1697 feature_name = "{}{}".format(name_prefix, version) 1698 1699 glxml.AddCommands(feature_name, version) 1700 1701 all_libgl_commands = glxml.commands[version] 1702 1703 just_libgl_commands = [ 1704 cmd for cmd in all_libgl_commands if cmd not in all_commands_no_suffix 1705 ] 1706 just_libgl_commands_suffix = [ 1707 cmd for cmd in all_libgl_commands if cmd not in all_commands_with_suffix 1708 ] 1709 1710 all_commands32 = glxml.all_commands 1711 1712 # Validation duplicates handled with suffix 1713 _, _, _, validation_protos32, _, _, _ = get_entry_points( 1714 all_commands32, just_libgl_commands_suffix, False, False, all_gles_param_types, 1715 cmd_packed_gl_enums) 1716 decls_gl, defs_gl, libgl_defs, _, _, _, _ = get_entry_points( 1717 all_commands32, all_libgl_commands, False, False, all_gles_param_types, 1718 cmd_packed_gl_enums) 1719 1720 # Write the version as a comment before the first EP. 1721 libgl_defs.insert(0, "\n// GL %s" % comment) 1722 libgl_ep_exports.append("\n ; GL %s" % comment) 1723 1724 libgl_ep_defs += libgl_defs 1725 libgl_ep_exports += get_exports(all_libgl_commands) 1726 1727 minor_if_not_zero = minor_version if minor_version != 0 else "" 1728 1729 header_includes = template_header_includes_gl32 1730 source_includes = template_sources_includes_gl32.format(annotation.lower(), major_version, 1731 minor_if_not_zero) 1732 1733 # Entry point files 1734 write_file(annotation, "GL " + comment, template_entry_point_header, "\n".join(decls_gl), 1735 "h", header_includes, "libGL", "gl.xml") 1736 write_file(annotation, "GL " + comment, template_entry_point_source, "\n".join(defs_gl), 1737 "cpp", source_includes, "libGL", "gl.xml") 1738 1739 gldecls['core'][(major_version, minor_version)] = get_decls( 1740 context_decl_format, all_commands32, just_libgl_commands, all_commands_no_suffix, [], 1741 cmd_packed_gl_enums) 1742 1743 # Validation files 1744 validation_annotation = "GL%s%s" % (major_version, minor_if_not_zero) 1745 write_validation_header(validation_annotation, "%s" % comment, validation_protos32, 1746 "gl.xml and wgl.xml") 1747 1748 # WGL 1749 wglxml = registry_xml.RegistryXML('wgl.xml') 1750 1751 name_prefix = "WGL_VERSION_" 1752 version = "1_0" 1753 comment = version.replace("_", ".") 1754 feature_name = "{}{}".format(name_prefix, version) 1755 wglxml.AddCommands(feature_name, version) 1756 wgl_commands = wglxml.commands[version] 1757 all_commands32.extend(wglxml.all_commands) 1758 1759 wgl_commands = [cmd if cmd[:3] == 'wgl' else 'wgl' + cmd for cmd in wgl_commands] 1760 1761 wgl_param_types = set() 1762 decls_wgl, defs_wgl, wgl_defs, validation_protos_wgl, _, _, _ = get_entry_points( 1763 all_commands32, wgl_commands, False, True, wgl_param_types, {}) 1764 1765 # Write the version as a comment before the first EP. 1766 libgl_ep_exports.append("\n ; WGL %s" % comment) 1767 1768 # Other versions of these functions are used 1769 wgl_commands.remove("wglUseFontBitmaps") 1770 wgl_commands.remove("wglUseFontOutlines") 1771 1772 libgl_ep_exports += get_exports(wgl_commands) 1773 1774 header_includes = template_header_includes.format(major="", minor="") 1775 header_includes += """ 1776 #include <GLES/glext.h> 1777 #include <GLES2/gl2.h> 1778 #include <GLES2/gl2ext.h> 1779 """ 1780 1781 source_includes = template_sources_includes.format( 1782 header_version="gles_ext", validation_header_version="ESEXT") 1783 source_includes += """ 1784 #include "libANGLE/capture_gles_1_0_autogen.h" 1785 #include "libANGLE/capture_gles_2_0_autogen.h" 1786 #include "libANGLE/capture_gles_3_0_autogen.h" 1787 #include "libANGLE/capture_gles_3_1_autogen.h" 1788 #include "libANGLE/validationES1.h" 1789 #include "libANGLE/validationES2.h" 1790 #include "libANGLE/validationES3.h" 1791 #include "libANGLE/validationES31.h" 1792 """ 1793 1794 write_file("gles_ext", "GLES extension", template_entry_point_header, 1795 "\n".join([item for item in extension_decls]), "h", header_includes, "libGLESv2", 1796 "gl.xml and gl_angle_ext.xml") 1797 write_file("gles_ext", "GLES extension", template_entry_point_source, 1798 "\n".join([item for item in extension_defs]), "cpp", source_includes, "libGLESv2", 1799 "gl.xml and gl_angle_ext.xml") 1800 1801 write_validation_header("ESEXT", "ES extension", ext_validation_protos, 1802 "gl.xml and gl_angle_ext.xml") 1803 write_capture_header("ext", "extension", ext_capture_protos, ext_capture_param_funcs) 1804 write_capture_source("ext", "ESEXT", "extension", ext_capture_methods) 1805 1806 write_context_api_decls(context_header, glesdecls, "gles") 1807 write_context_api_decls(context_header, gldecls, "gl") 1808 1809 # Entry point enum 1810 cmd_names = ["Invalid"] + [cmd[2:] for cmd in xml.all_cmd_names.get_all_commands()] 1811 gl_cmd_names = [cmd[2:] for cmd in glxml.all_cmd_names.get_all_commands()] 1812 cmd_names.extend([cmd for cmd in gl_cmd_names if cmd not in cmd_names]) 1813 sorted_cmd_names = sorted(cmd_names) 1814 1815 entry_points_enum_header = template_entry_points_enum_header.format( 1816 script_name=os.path.basename(sys.argv[0]), 1817 data_source_name="gl.xml and gl_angle_ext.xml", 1818 year=date.today().year, 1819 lib="GL/GLES", 1820 entry_points_list=",\n".join([" " + cmd for cmd in sorted_cmd_names])) 1821 1822 entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h") 1823 with open(entry_points_enum_header_path, "w") as out: 1824 out.write(entry_points_enum_header) 1825 out.close() 1826 1827 entry_points_cases = [ 1828 template_entry_points_name_case.format(enum=cmd) for cmd in sorted_cmd_names 1829 ] 1830 entry_points_enum_source = template_entry_points_enum_source.format( 1831 script_name=os.path.basename(sys.argv[0]), 1832 data_source_name="gl.xml and gl_angle_ext.xml", 1833 year=date.today().year, 1834 lib="GL/GLES", 1835 entry_points_name_cases="\n".join(entry_points_cases)) 1836 1837 entry_points_enum_source_path = path_to("libANGLE", "entry_points_enum_autogen.cpp") 1838 with open(entry_points_enum_source_path, "w") as out: 1839 out.write(entry_points_enum_source) 1840 out.close() 1841 1842 source_includes = """ 1843 #include "angle_gl.h" 1844 1845 #include "libGLESv2/entry_points_gles_1_0_autogen.h" 1846 #include "libGLESv2/entry_points_gles_2_0_autogen.h" 1847 #include "libGLESv2/entry_points_gles_3_0_autogen.h" 1848 #include "libGLESv2/entry_points_gles_3_1_autogen.h" 1849 #include "libGLESv2/entry_points_gles_ext_autogen.h" 1850 1851 #include "common/event_tracer.h" 1852 """ 1853 1854 write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes, 1855 "gl.xml and gl_angle_ext.xml", "libGLESv2", "OpenGL ES") 1856 1857 source_includes = """ 1858 #include "angle_gl.h" 1859 1860 #include "libGL/entry_points_gl_1_0_autogen.h" 1861 #include "libGL/entry_points_gl_1_1_autogen.h" 1862 #include "libGL/entry_points_gl_1_2_autogen.h" 1863 #include "libGL/entry_points_gl_1_3_autogen.h" 1864 #include "libGL/entry_points_gl_1_4_autogen.h" 1865 #include "libGL/entry_points_gl_1_5_autogen.h" 1866 #include "libGL/entry_points_gl_2_0_autogen.h" 1867 #include "libGL/entry_points_gl_2_1_autogen.h" 1868 #include "libGL/entry_points_gl_3_0_autogen.h" 1869 #include "libGL/entry_points_gl_3_1_autogen.h" 1870 #include "libGL/entry_points_gl_3_2_autogen.h" 1871 #include "libGL/entry_points_gl_3_3_autogen.h" 1872 #include "libGL/entry_points_gl_4_0_autogen.h" 1873 #include "libGL/entry_points_gl_4_1_autogen.h" 1874 #include "libGL/entry_points_gl_4_2_autogen.h" 1875 #include "libGL/entry_points_gl_4_3_autogen.h" 1876 #include "libGL/entry_points_gl_4_4_autogen.h" 1877 #include "libGL/entry_points_gl_4_5_autogen.h" 1878 #include "libGL/entry_points_gl_4_6_autogen.h" 1879 1880 #include "common/event_tracer.h" 1881 """ 1882 1883 write_export_files("\n".join([item for item in libgl_ep_defs]), source_includes, 1884 "gl.xml and wgl.xml", "libGL", "Windows GL") 1885 1886 libgles_ep_exports += get_egl_exports() 1887 1888 everything = "Khronos and ANGLE XML files" 1889 1890 for lib in ["libGLESv2" + suffix for suffix in ["", "_no_capture", "_with_capture"]]: 1891 write_windows_def_file(everything, lib, lib, "libGLESv2", libgles_ep_exports) 1892 write_windows_def_file(everything, "libGL", "openGL32", "libGL", libgl_ep_exports) 1893 1894 all_gles_param_types = sorted(all_gles_param_types) 1895 write_capture_helper_header(all_gles_param_types) 1896 write_capture_helper_source(all_gles_param_types) 1897 1898 1899if __name__ == '__main__': 1900 sys.exit(main()) 1901