Commit 1b413197 by Jamie Madill Committed by Commit Bot

generate_entry_points.py clean-ups.

Use all upper-case for Python constants. Also use line breaks to make the templates more readable. No functional changes, refactoring only. Bug: angleproject:2621 Change-Id: I3ec1c07089b33fd1655ffbacc8c3a8cdcb919a3b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2553967 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com>
parent fb82b119
......@@ -6,7 +6,7 @@
"scripts/entry_point_packed_gl_enums.json":
"846be5dc8cb36076207699b025633fcc",
"scripts/generate_entry_points.py":
"8cac2161436060a0ba9c55696aba2069",
"bce338a2d1cae08cd5836405759107bc",
"scripts/gl.xml":
"f66967f3f3d696b5d8306fd80bbd49a8",
"scripts/gl_angle_ext.xml":
......
......@@ -13,13 +13,13 @@ from datetime import date
import registry_xml
# List of GLES1 extensions for which we don't need to add Context.h decls.
gles1_no_context_decl_extensions = [
GLES1_NO_CONTEXT_DECL_EXTENSIONS = [
"GL_OES_framebuffer_object",
]
# This is a list of exceptions for entry points which don't want to have
# the EVENT macro. This is required for some debug marker entry points.
no_event_marker_exceptions_list = sorted([
NO_EVENT_MARKER_EXCEPTIONS_LIST = sorted([
"glPushGroupMarkerEXT",
"glPopGroupMarkerEXT",
"glInsertEventMarkerEXT",
......@@ -28,19 +28,16 @@ no_event_marker_exceptions_list = sorted([
# glRenderbufferStorageMultisampleEXT aliases glRenderbufferStorageMultisample on desktop GL, and is
# marked as such in the registry. However, that is not correct for GLES where this entry point
# comes from GL_EXT_multisampled_render_to_texture which is never promoted to core GLES.
aliasing_exceptions = [
ALIASING_EXCEPTIONS = [
'glRenderbufferStorageMultisampleEXT',
'renderbufferStorageMultisampleEXT',
]
def is_aliasing_excepted(cmd_name, is_gles):
return is_gles and cmd_name in aliasing_exceptions
# Strip these suffixes from Context entry point names. NV is excluded (for now).
strip_suffixes = ["ANGLE", "EXT", "KHR", "OES", "CHROMIUM", "OVR"]
STRIP_SUFFIXES = ["ANGLE", "EXT", "KHR", "OES", "CHROMIUM", "OVR"]
template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_ENTRY_POINT_HEADER = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -63,7 +60,8 @@ namespace gl
#endif // {lib}_ENTRY_POINTS_{annotation_upper}_AUTOGEN_H_
"""
template_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_ENTRY_POINT_SOURCE = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -80,7 +78,8 @@ namespace gl
{entry_points}}} // namespace gl
"""
template_entry_points_enum_header = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_ENTRY_POINTS_ENUM_HEADER = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -105,10 +104,12 @@ const char *GetEntryPointName(EntryPoint ep);
#endif // COMMON_ENTRY_POINTS_ENUM_AUTOGEN_H_
"""
template_entry_points_name_case = """ case EntryPoint::{enum}:
TEMPLATE_ENTRY_POINTS_NAME_CASE = """\
case EntryPoint::{enum}:
return "gl{enum}";"""
template_entry_points_enum_source = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_ENTRY_POINTS_ENUM_SOURCE = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -137,7 +138,8 @@ const char *GetEntryPointName(EntryPoint ep)
}} // namespace gl
"""
template_lib_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_LIB_ENTRY_POINT_SOURCE = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -152,9 +154,10 @@ extern "C" {{
}} // extern "C"
"""
template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
TEMPLATE_ENTRY_POINT_DECL = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
template_entry_point_no_return = """void GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
TEMPLATE_ENTRY_POINT_NO_RETURN = """\
void GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
{{
Context *context = {context_getter};
{event_comment}EVENT(context, gl::EntryPoint::{name}, "gl{name}", "context = %d{comma_if_needed}{format_params}", CID(context){comma_if_needed}{pass_params});
......@@ -176,7 +179,8 @@ template_entry_point_no_return = """void GL_APIENTRY {name}{explicit_context_suf
}}
"""
template_entry_point_with_return = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
TEMPLATE_ENTRY_POINT_WITH_RETURN = """\
{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
{{
Context *context = {context_getter};
{event_comment}EVENT(context, gl::EntryPoint::{name}, "gl{name}", "context = %d{comma_if_needed}{format_params}", CID(context){comma_if_needed}{pass_params});
......@@ -205,7 +209,8 @@ template_entry_point_with_return = """{return_type}GL_APIENTRY {name}{explicit_c
}}
"""
context_header = """// GENERATED FILE - DO NOT EDIT.
CONTEXT_HEADER = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -223,15 +228,17 @@ context_header = """// GENERATED FILE - DO NOT EDIT.
#endif // ANGLE_CONTEXT_API_{version}_AUTOGEN_H_
"""
context_decl_format = """ {return_type} {name_lower_no_suffix}({internal_params}){maybe_const}; \\"""
CONTEXT_DECL_FORMAT = """ {return_type} {name_lower_no_suffix}({internal_params}){maybe_const}; \\"""
libgles_entry_point_def = """{return_type}GL_APIENTRY gl{name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
LIBGLES_ENTRY_POINT_DEF = """\
{return_type}GL_APIENTRY gl{name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
{{
return gl::{name}{explicit_context_suffix}({explicit_context_internal_param}{explicit_context_comma}{internal_params});
}}
"""
template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_GLEXT_EXPLICIT_CONTEXT_INC = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -247,10 +254,11 @@ template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT.
#endif
"""
template_glext_function_pointer = """typedef {return_type}(GL_APIENTRYP PFN{name_upper}{explicit_context_suffix_upper}PROC)({explicit_context_param}{explicit_context_comma}{params});"""
template_glext_function_prototype = """{apicall} {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
TEMPLATE_GLEXT_FUNCTION_POINTER = """typedef {return_type}(GL_APIENTRYP PFN{name_upper}{explicit_context_suffix_upper}PROC)({explicit_context_param}{explicit_context_comma}{params});"""
TEMPLATE_GLEXT_FUNCTION_PROTOTYPE = """{apicall} {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
template_validation_header = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_VALIDATION_HEADER = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -275,7 +283,8 @@ class Context;
#endif // LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_
"""
template_capture_header = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_CAPTURE_HEADER = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -299,7 +308,8 @@ namespace gl
#endif // LIBANGLE_CAPTURE_GLES_{annotation}_AUTOGEN_H_
"""
template_capture_source = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_CAPTURE_SOURCE = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -324,7 +334,7 @@ namespace gl
}} // namespace gl
"""
template_capture_method_with_return_value = """
TEMPLATE_CAPTURE_METHOD_WITH_RETURN_VALUE = """
CallCapture Capture{short_name}({params_with_type}, {return_value_type_original} returnValue)
{{
ParamBuffer paramBuffer;
......@@ -339,7 +349,7 @@ CallCapture Capture{short_name}({params_with_type}, {return_value_type_original}
}}
"""
template_capture_method_no_return_value = """
TEMPLATE_CAPTURE_METHOD_NO_RETURN_VALUE = """
CallCapture Capture{short_name}({params_with_type})
{{
ParamBuffer paramBuffer;
......@@ -350,11 +360,11 @@ CallCapture Capture{short_name}({params_with_type})
}}
"""
template_parameter_capture_value = """paramBuffer.addValueParam("{name}", ParamType::T{type}, {name});"""
TEMPLATE_PARAMETER_CAPTURE_VALUE = """paramBuffer.addValueParam("{name}", ParamType::T{type}, {name});"""
template_parameter_capture_gl_enum = """paramBuffer.addEnumParam("{name}", GLenumGroup::{group}, ParamType::T{type}, {name});"""
TEMPLATE_PARAMETER_CAPTURE_GL_ENUM = """paramBuffer.addEnumParam("{name}", GLenumGroup::{group}, ParamType::T{type}, {name});"""
template_parameter_capture_pointer = """
TEMPLATE_PARAMETER_CAPTURE_POINTER = """
if (isCallValid)
{{
ParamCapture {name}Param("{name}", ParamType::T{type});
......@@ -370,9 +380,10 @@ template_parameter_capture_pointer = """
}}
"""
template_parameter_capture_pointer_func = """void {name}({params});"""
TEMPLATE_PARAMETER_CAPTURE_POINTER_FUNC = """void {name}({params});"""
template_capture_replay_source = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_CAPTURE_REPLAY_SOURCE = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -412,16 +423,16 @@ void FrameCapture::ReplayCall(gl::Context *context,
"""
template_capture_replay_call_case = """case gl::EntryPoint::{entry_point}:
TEMPLATE_CAPTURE_REPLAY_CALL_CASE = """case gl::EntryPoint::{entry_point}:
context->{context_call}({param_value_access});break;"""
static_cast_to_dict = {
STATIC_CAST_TO_DICT = {
"GLintptr": "unsigned long long",
"GLsizeiptr": "unsigned long long",
"GLuint64": "unsigned long long",
}
reinterpret_cast_to_dict = {
REINTERPRET_CAST_TO_DICT = {
"GLsync": "uintptr_t",
"GLDEBUGPROC": "uintptr_t",
"GLDEBUGPROCKHR": "uintptr_t",
......@@ -429,7 +440,7 @@ reinterpret_cast_to_dict = {
"GLeglImageOES": "uintptr_t",
}
format_dict = {
FORMAT_DICT = {
"GLbitfield": "%s",
"GLboolean": "%s",
"GLbyte": "%d",
......@@ -465,10 +476,12 @@ format_dict = {
"UINT": "%u",
}
template_header_includes = """#include <GLES{major}/gl{major}{minor}.h>
TEMPLATE_HEADER_INCLUDES = """\
#include <GLES{major}/gl{major}{minor}.h>
#include <export.h>"""
template_sources_includes = """#include "libGLESv2/entry_points_{header_version}_autogen.h"
TEMPLATE_SOURCES_INCLUDES = """\
#include "libGLESv2/entry_points_{header_version}_autogen.h"
#include "common/entry_points_enum_autogen.h"
#include "libANGLE/Context.h"
......@@ -480,12 +493,13 @@ template_sources_includes = """#include "libGLESv2/entry_points_{header_version}
#include "libGLESv2/global_state.h"
"""
template_header_includes_gl32 = """#include <export.h>
TEMPLATE_HEADER_INCLUDES_GL32 = """#include <export.h>
#include "angle_gl.h"
"""
template_sources_includes_gl32 = """#include "libGL/entry_points_{}_autogen.h"
TEMPLATE_SOURCES_INCLUDES_GL32 = """\
#include "libGL/entry_points_{}_autogen.h"
#include "libANGLE/Context.h"
#include "libANGLE/Context.inl.h"
......@@ -503,15 +517,17 @@ template_sources_includes_gl32 = """#include "libGL/entry_points_{}_autogen.h"
#include "libGLESv2/global_state.h"
"""
template_event_comment = """// Don't run the EVENT() macro on the EXT_debug_marker entry points.
TEMPLATE_EVENT_COMMENT = """\
// Don't run the EVENT() macro on the EXT_debug_marker entry points.
// It can interfere with the debug events being set by the caller.
// """
template_capture_proto = "angle::CallCapture Capture%s(%s);"
TEMPLATE_CAPTURE_PROTO = "angle::CallCapture Capture%s(%s);"
template_validation_proto = "bool Validate%s(%s);"
TEMPLATE_VALIDATION_PROTO = "bool Validate%s(%s);"
template_windows_def_file = """; GENERATED FILE - DO NOT EDIT.
TEMPLATE_WINDOWS_DEF_FILE = """\
; GENERATED FILE - DO NOT EDIT.
; Generated by {script_name} using data from {data_source_name}.
;
; Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -522,7 +538,8 @@ EXPORTS
{exports}
"""
template_frame_capture_utils_header = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_FRAME_CAPTURE_UTILS_HEADER = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -610,7 +627,8 @@ const char *GetResourceIDTypeName(ResourceIDType resourceIDType);
#endif // LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_H_
"""
template_frame_capture_utils_source = """// GENERATED FILE - DO NOT EDIT.
TEMPLATE_FRAME_CAPTURE_UTILS_SOURCE = """\
// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
......@@ -671,45 +689,58 @@ const char *GetResourceIDTypeName(ResourceIDType resourceIDType)
}} // namespace angle
"""
template_get_param_val_specialization = """template <>
TEMPLATE_GET_PARAM_VAL_SPECIALIZATION = """\
template <>
inline {type} GetParamVal<ParamType::T{enum}, {type}>(const ParamValue &value)
{{
return value.{union_name};
}}"""
template_access_param_value_case = """ case ParamType::T{enum}:
return GetParamVal<ParamType::T{enum}, T>(value);"""
TEMPLATE_ACCESS_PARAM_VALUE_CASE = """\
case ParamType::T{enum}:
return GetParamVal<ParamType::T{enum}, T>(value);"""
template_set_param_val_specialization = """template <>
TEMPLATE_SET_PARAM_VAL_SPECIALIZATION = """\
template <>
inline void SetParamVal<ParamType::T{enum}>({type} valueIn, ParamValue *valueOut)
{{
valueOut->{union_name} = valueIn;
}}"""
template_init_param_value_case = """ case ParamType::T{enum}:
TEMPLATE_INIT_PARAM_VALUE_CASE = """\
case ParamType::T{enum}:
SetParamVal<ParamType::T{enum}>(valueIn, valueOut);
break;"""
template_write_param_type_to_stream_case = """ case ParamType::T{enum_in}:
TEMPLATE_WRITE_PARAM_TYPE_TO_STREAM_CASE = """\
case ParamType::T{enum_in}:
WriteParamValueReplay<ParamType::T{enum_out}>(os, call, param.value.{union_name});
break;"""
template_param_type_to_string_case = """ case ParamType::T{enum}:
TEMPLATE_PARAM_TYPE_TO_STRING_CASE = """\
case ParamType::T{enum}:
return "{type}";"""
template_param_type_to_resource_id_type_case = """ case ParamType::T{enum}:
TEMPLATE_PARAM_TYPE_TO_RESOURCE_ID_TYPE_CASE = """\
case ParamType::T{enum}:
return ResourceIDType::{resource_id_type};"""
template_resource_id_type_name_case = """ case ResourceIDType::{resource_id_type}:
TEMPLATE_RESOURCE_ID_TYPE_NAME_CASE = """\
case ResourceIDType::{resource_id_type}:
return "{resource_id_type}";"""
def is_aliasing_excepted(cmd_name, is_gles):
return is_gles and cmd_name in ALIASING_EXCEPTIONS
def script_relative(path):
return os.path.join(os.path.dirname(sys.argv[0]), path)
def format_entry_point_decl(cmd_name, proto, params, is_explicit_context):
comma_if_needed = ", " if len(params) > 0 else ""
return template_entry_point_decl.format(
return TEMPLATE_ENTRY_POINT_DECL.format(
name=cmd_name[2:],
return_type=proto[:-len(cmd_name)],
params=", ".join(params),
......@@ -762,11 +793,11 @@ def param_print_argument(command_node, param):
if "*" in param:
return "(uintptr_t)" + name_only
if type_only in reinterpret_cast_to_dict:
return "(" + reinterpret_cast_to_dict[type_only] + ")" + name_only
if type_only in REINTERPRET_CAST_TO_DICT:
return "(" + REINTERPRET_CAST_TO_DICT[type_only] + ")" + name_only
if type_only in static_cast_to_dict:
return "static_cast<" + static_cast_to_dict[type_only] + ">(" + name_only + ")"
if type_only in STATIC_CAST_TO_DICT:
return "static_cast<" + STATIC_CAST_TO_DICT[type_only] + ">(" + name_only + ")"
if type_only == "GLboolean":
return "GLbooleanToString(%s)" % (name_only,)
......@@ -787,10 +818,10 @@ def param_format_string(param):
return just_the_name(param) + " = 0x%016\" PRIxPTR \""
else:
type_only = just_the_type(param)
if type_only not in format_dict:
raise Exception(type_only + " is not a known type in 'format_dict'")
if type_only not in FORMAT_DICT:
raise Exception(type_only + " is not a known type in 'FORMAT_DICT'")
return just_the_name(param) + " = " + format_dict[type_only]
return just_the_name(param) + " = " + FORMAT_DICT[type_only]
def default_return_value(cmd_name, return_type):
......@@ -851,7 +882,7 @@ def strip_suffix(name, is_gles):
if is_aliasing_excepted(name, is_gles):
return name
for suffix in strip_suffixes:
for suffix in STRIP_SUFFIXES:
if name.endswith(suffix):
name = name[0:-len(suffix)]
return name
......@@ -894,7 +925,7 @@ def format_entry_point_def(command_node, cmd_name, proto, params, is_explicit_co
format_params = [param_format_string(param) for param in params]
return_type = proto[:-len(cmd_name)]
default_return = default_return_value(cmd_name, return_type.strip())
event_comment = template_event_comment if cmd_name in no_event_marker_exceptions_list else ""
event_comment = TEMPLATE_EVENT_COMMENT if cmd_name in NO_EVENT_MARKER_EXCEPTIONS_LIST else ""
name_lower_no_suffix = strip_suffix(cmd_name[2:3].lower() + cmd_name[3:], is_gles)
format_params = {
......@@ -937,9 +968,9 @@ def format_entry_point_def(command_node, cmd_name, proto, params, is_explicit_co
}
if return_type.strip() == "void":
return template_entry_point_no_return.format(**format_params)
return TEMPLATE_ENTRY_POINT_NO_RETURN.format(**format_params)
else:
return template_entry_point_with_return.format(**format_params)
return TEMPLATE_ENTRY_POINT_WITH_RETURN.format(**format_params)
def get_capture_param_type_name(param_type):
......@@ -981,22 +1012,22 @@ def format_capture_method(command, cmd_name, proto, params, all_param_types, cap
if pointer_count > 0:
params = params_just_name
capture_name = "Capture%s_%s" % (cmd_name[2:], param_name)
capture = template_parameter_capture_pointer.format(
capture = TEMPLATE_PARAMETER_CAPTURE_POINTER.format(
name=param_name,
type=capture_param_type,
capture_name=capture_name,
params=params,
cast_type=param_type)
capture_pointer_func = template_parameter_capture_pointer_func.format(
capture_pointer_func = TEMPLATE_PARAMETER_CAPTURE_POINTER_FUNC.format(
name=capture_name, params=params_with_type + ", angle::ParamCapture *paramCapture")
capture_pointer_funcs += [capture_pointer_func]
elif capture_param_type in ('GLenum', 'GLbitfield'):
gl_enum_group = find_gl_enum_group_in_command(command, param_name)
capture = template_parameter_capture_gl_enum.format(
capture = TEMPLATE_PARAMETER_CAPTURE_GL_ENUM.format(
name=param_name, type=capture_param_type, group=gl_enum_group)
else:
capture = template_parameter_capture_value.format(
capture = TEMPLATE_PARAMETER_CAPTURE_VALUE.format(
name=param_name, type=capture_param_type)
all_param_types.add(capture_param_type)
......@@ -1016,9 +1047,9 @@ def format_capture_method(command, cmd_name, proto, params, all_param_types, cap
}
if return_type == "void":
return template_capture_method_no_return_value.format(**format_args)
return TEMPLATE_CAPTURE_METHOD_NO_RETURN_VALUE.format(**format_args)
else:
return template_capture_method_with_return_value.format(**format_args)
return TEMPLATE_CAPTURE_METHOD_WITH_RETURN_VALUE.format(**format_args)
def const_pointer_type(param, packed_gl_enums):
......@@ -1069,7 +1100,7 @@ def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context)
internal_params = [just_the_name(param) for param in params]
return_type = proto[:-len(cmd_name)]
return libgles_entry_point_def.format(
return LIBGLES_ENTRY_POINT_DEF.format(
name=cmd_name[2:],
return_type=return_type,
params=", ".join(params),
......@@ -1083,7 +1114,7 @@ def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context)
def format_validation_proto(cmd_name, params, cmd_packed_gl_enums, is_gles):
internal_params = get_validation_params(cmd_name, ["Context *context"] + params,
cmd_packed_gl_enums, is_gles)
return template_validation_proto % (cmd_name[2:], internal_params)
return TEMPLATE_VALIDATION_PROTO % (cmd_name[2:], internal_params)
def format_capture_proto(cmd_name, proto, params, cmd_packed_gl_enums, is_gles):
......@@ -1093,7 +1124,7 @@ def format_capture_proto(cmd_name, proto, params, cmd_packed_gl_enums, is_gles):
return_type = proto[:-len(cmd_name)].strip()
if return_type != "void":
internal_params += ", %s returnValue" % return_type
return template_capture_proto % (cmd_name[2:], internal_params)
return TEMPLATE_CAPTURE_PROTO % (cmd_name[2:], internal_params)
def path_to(folder, file):
......@@ -1198,8 +1229,8 @@ def get_glext_decls(all_commands, gles_commands, version, is_explicit_context):
"explicit_context_param": "GLeglContext ctx" if is_explicit_context else ""
}
glext_ptrs.append(template_glext_function_pointer.format(**format_params))
glext_protos.append(template_glext_function_prototype.format(**format_params))
glext_ptrs.append(TEMPLATE_GLEXT_FUNCTION_POINTER.format(**format_params))
glext_protos.append(TEMPLATE_GLEXT_FUNCTION_PROTOTYPE.format(**format_params))
return glext_ptrs, glext_protos
......@@ -1224,7 +1255,7 @@ def write_file(annotation, comment, template, entry_points, suffix, includes, li
def write_export_files(entry_points, includes, source, lib_name, lib_description):
content = template_lib_entry_point_source.format(
content = TEMPLATE_LIB_ENTRY_POINT_SOURCE.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name=source,
lib_name=lib_name,
......@@ -1291,7 +1322,7 @@ def write_glext_explicit_context_inc(version, ptrs, protos):
possible_versions = ["31", "32"]
folder_version = version if version not in possible_versions else "3"
content = template_glext_explicit_context_inc.format(
content = TEMPLATE_GLEXT_EXPLICIT_CONTEXT_INC.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
version=version,
......@@ -1308,7 +1339,7 @@ def write_glext_explicit_context_inc(version, ptrs, protos):
def write_validation_header(annotation, comment, protos, source):
content = template_validation_header.format(
content = TEMPLATE_VALIDATION_HEADER.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name=source,
annotation=annotation,
......@@ -1323,7 +1354,7 @@ def write_validation_header(annotation, comment, protos, source):
def write_capture_header(annotation, comment, protos, capture_pointer_funcs):
content = template_capture_header.format(
content = TEMPLATE_CAPTURE_HEADER.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
annotation=annotation,
......@@ -1339,7 +1370,7 @@ def write_capture_header(annotation, comment, protos, capture_pointer_funcs):
def write_capture_source(annotation_with_dash, annotation_no_dash, comment, capture_methods):
content = template_capture_source.format(
content = TEMPLATE_CAPTURE_SOURCE.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
annotation_with_dash=annotation_with_dash,
......@@ -1405,31 +1436,31 @@ def format_param_type_union_type(param_type):
def format_get_param_val_specialization(param_type):
return template_get_param_val_specialization.format(
return TEMPLATE_GET_PARAM_VAL_SPECIALIZATION.format(
enum=param_type,
type=get_param_type_type(param_type),
union_name=get_param_type_union_name(param_type))
def format_access_param_value_case(param_type):
return template_access_param_value_case.format(enum=param_type)
return TEMPLATE_ACCESS_PARAM_VALUE_CASE.format(enum=param_type)
def format_set_param_val_specialization(param_type):
return template_set_param_val_specialization.format(
return TEMPLATE_SET_PARAM_VAL_SPECIALIZATION.format(
enum=param_type,
type=get_param_type_type(param_type),
union_name=get_param_type_union_name(param_type))
def format_init_param_value_case(param_type):
return template_init_param_value_case.format(enum=param_type)
return TEMPLATE_INIT_PARAM_VALUE_CASE.format(enum=param_type)
def format_write_param_type_to_stream_case(param_type):
# Force all enum printing to go through "const void *"
param_out = "voidConstPointer" if "Pointer" in param_type else param_type
return template_write_param_type_to_stream_case.format(
return TEMPLATE_WRITE_PARAM_TYPE_TO_STREAM_CASE.format(
enum_in=param_type, enum_out=param_out, union_name=get_param_type_union_name(param_out))
......@@ -1457,7 +1488,7 @@ def write_capture_helper_header(all_param_types):
init_param_value_cases = "\n".join([format_init_param_value_case(t) for t in all_param_types])
resource_id_types = format_resource_id_types(all_param_types)
content = template_frame_capture_utils_header.format(
content = TEMPLATE_FRAME_CAPTURE_UTILS_HEADER.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
param_types=param_types,
......@@ -1477,7 +1508,7 @@ def write_capture_helper_header(all_param_types):
def format_param_type_to_string_case(param_type):
return template_param_type_to_string_case.format(
return TEMPLATE_PARAM_TYPE_TO_STRING_CASE.format(
enum=param_type, type=get_gl_param_type_type(param_type))
......@@ -1490,7 +1521,7 @@ def get_resource_id_type_from_param_type(param_type):
def format_param_type_to_resource_id_type_case(param_type):
return template_param_type_to_resource_id_type_case.format(
return TEMPLATE_PARAM_TYPE_TO_RESOURCE_ID_TYPE_CASE.format(
enum=param_type, resource_id_type=get_resource_id_type_from_param_type(param_type))
......@@ -1502,7 +1533,7 @@ def format_param_type_resource_id_cases(all_param_types):
def format_resource_id_type_name_case(resource_id_type):
return template_resource_id_type_name_case.format(resource_id_type=resource_id_type)
return TEMPLATE_RESOURCE_ID_TYPE_NAME_CASE.format(resource_id_type=resource_id_type)
def write_capture_helper_source(all_param_types):
......@@ -1518,7 +1549,7 @@ def write_capture_helper_source(all_param_types):
resource_id_type_name_cases = "\n".join(
[format_resource_id_type_name_case(t) for t in resource_id_types])
content = template_frame_capture_utils_source.format(
content = TEMPLATE_FRAME_CAPTURE_UTILS_SOURCE.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
write_param_type_to_stream_cases=write_param_type_to_stream_cases,
......@@ -1580,7 +1611,7 @@ def format_capture_replay_call_case(command_to_param_types_mapping, cmd_packed_g
entry_point_name = command_name[2:] # strip the 'gl' prefix
call_str_list.append(
template_capture_replay_call_case.format(
TEMPLATE_CAPTURE_REPLAY_CALL_CASE.format(
entry_point=entry_point_name,
param_value_access=format_capture_replay_param_access(
command_name, cmd_param_texts, cmd_packed_gl_enums, is_gles),
......@@ -1606,7 +1637,7 @@ def write_capture_replay_source(all_commands_nodes, gles_command_names, cmd_pack
call_replay_cases = format_capture_replay_call_case(command_to_param_types_mapping,
cmd_packed_gl_enums, is_gles)
source_content = template_capture_replay_source.format(
source_content = TEMPLATE_CAPTURE_REPLAY_SOURCE.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
call_replay_cases=call_replay_cases,
......@@ -1619,7 +1650,7 @@ def write_capture_replay_source(all_commands_nodes, gles_command_names, cmd_pack
def write_windows_def_file(data_source_name, lib, libexport, folder, exports):
content = template_windows_def_file.format(
content = TEMPLATE_WINDOWS_DEF_FILE.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name=data_source_name,
exports="\n".join(exports),
......@@ -1872,7 +1903,7 @@ def main():
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(
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.
......@@ -1880,16 +1911,16 @@ def main():
header_includes += "\n#include \"common/platform.h\"\n"
version_annotation = "%s%s" % (major_version, minor_if_not_zero)
source_includes = template_sources_includes.format(
source_includes = TEMPLATE_SOURCES_INCLUDES.format(
header_version=annotation.lower(), validation_header_version="ES" + version_annotation)
write_file(annotation, "GLES " + comment, template_entry_point_header, "\n".join(decls),
write_file(annotation, "GLES " + comment, TEMPLATE_ENTRY_POINT_HEADER, "\n".join(decls),
"h", header_includes, "libGLESv2", "gl.xml")
write_file(annotation, "GLES " + comment, template_entry_point_source, "\n".join(defs),
write_file(annotation, "GLES " + comment, TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(defs),
"cpp", source_includes, "libGLESv2", "gl.xml")
glesdecls['core'][(major_version,
minor_version)] = get_decls(context_decl_format, all_commands,
minor_version)] = get_decls(CONTEXT_DECL_FORMAT, all_commands,
gles_commands, [], cmd_packed_gl_enums,
True)
......@@ -1952,17 +1983,17 @@ def main():
libgles_ep_exports += get_exports(ext_cmd_names)
if (extension_name in registry_xml.gles1_extensions and
extension_name not in gles1_no_context_decl_extensions):
extension_name not in GLES1_NO_CONTEXT_DECL_EXTENSIONS):
glesdecls['exts']['GLES1 Extensions'][extension_name] = get_decls(
context_decl_format, all_commands, ext_cmd_names, all_commands_no_suffix,
CONTEXT_DECL_FORMAT, all_commands, ext_cmd_names, all_commands_no_suffix,
cmd_packed_gl_enums, True)
if extension_name in registry_xml.gles_extensions:
glesdecls['exts']['GLES2+ Extensions'][extension_name] = get_decls(
context_decl_format, all_commands, ext_cmd_names, all_commands_no_suffix,
CONTEXT_DECL_FORMAT, all_commands, ext_cmd_names, all_commands_no_suffix,
cmd_packed_gl_enums, True)
if extension_name in registry_xml.angle_extensions:
glesdecls['exts']['ANGLE Extensions'][extension_name] = get_decls(
context_decl_format, all_commands, ext_cmd_names, all_commands_no_suffix,
CONTEXT_DECL_FORMAT, all_commands, ext_cmd_names, all_commands_no_suffix,
cmd_packed_gl_enums, True)
for name in extension_commands:
......@@ -2073,18 +2104,18 @@ def main():
minor_if_not_zero = minor_version if minor_version != 0 else ""
header_includes = template_header_includes_gl32
source_includes = template_sources_includes_gl32.format(annotation.lower(), major_version,
header_includes = TEMPLATE_HEADER_INCLUDES_GL32
source_includes = TEMPLATE_SOURCES_INCLUDES_GL32.format(annotation.lower(), major_version,
minor_if_not_zero)
# Entry point files
write_file(annotation, "GL " + comment, template_entry_point_header, "\n".join(decls_gl),
write_file(annotation, "GL " + comment, TEMPLATE_ENTRY_POINT_HEADER, "\n".join(decls_gl),
"h", header_includes, "libGL", "gl.xml")
write_file(annotation, "GL " + comment, template_entry_point_source, "\n".join(defs_gl),
write_file(annotation, "GL " + comment, TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(defs_gl),
"cpp", source_includes, "libGL", "gl.xml")
gldecls['core'][(major_version,
minor_version)] = get_decls(context_decl_format, all_commands32,
minor_version)] = get_decls(CONTEXT_DECL_FORMAT, all_commands32,
just_libgl_commands, all_commands_no_suffix,
cmd_packed_gl_enums, False)
......@@ -2119,7 +2150,7 @@ def main():
libgl_ep_exports += get_exports(wgl_commands)
header_includes = template_header_includes.format(major="", minor="")
header_includes = TEMPLATE_HEADER_INCLUDES.format(major="", minor="")
header_includes += """
#include <GLES/glext.h>
#include <GLES2/gl2.h>
......@@ -2127,7 +2158,7 @@ def main():
#include <GLES3/gl32.h>
"""
source_includes = template_sources_includes.format(
source_includes = TEMPLATE_SOURCES_INCLUDES.format(
header_version="gles_ext", validation_header_version="ESEXT")
source_includes += """
#include "libANGLE/capture_gles_1_0_autogen.h"
......@@ -2142,10 +2173,10 @@ def main():
#include "libANGLE/validationES32.h"
"""
write_file("gles_ext", "GLES extension", template_entry_point_header,
write_file("gles_ext", "GLES extension", TEMPLATE_ENTRY_POINT_HEADER,
"\n".join([item for item in extension_decls]), "h", header_includes, "libGLESv2",
"gl.xml and gl_angle_ext.xml")
write_file("gles_ext", "GLES extension", template_entry_point_source,
write_file("gles_ext", "GLES extension", TEMPLATE_ENTRY_POINT_SOURCE,
"\n".join([item for item in extension_defs]), "cpp", source_includes, "libGLESv2",
"gl.xml and gl_angle_ext.xml")
......@@ -2154,8 +2185,8 @@ def main():
write_capture_header("ext", "extension", ext_capture_protos, ext_capture_param_funcs)
write_capture_source("ext", "ESEXT", "extension", ext_capture_methods)
write_context_api_decls(context_header, glesdecls, "gles")
write_context_api_decls(context_header, gldecls, "gl")
write_context_api_decls(CONTEXT_HEADER, glesdecls, "gles")
write_context_api_decls(CONTEXT_HEADER, gldecls, "gl")
# Entry point enum
cmd_names = ["Invalid"] + [cmd[2:] for cmd in xml.all_cmd_names.get_all_commands()]
......@@ -2166,7 +2197,7 @@ def main():
# Ensure there are no duplicates
assert (len(sorted_cmd_names) == len(set(sorted_cmd_names))), "Duplicate command names found"
entry_points_enum_header = template_entry_points_enum_header.format(
entry_points_enum_header = TEMPLATE_ENTRY_POINTS_ENUM_HEADER.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
lib="GL/GLES",
......@@ -2178,9 +2209,9 @@ def main():
out.close()
entry_points_cases = [
template_entry_points_name_case.format(enum=cmd) for cmd in sorted_cmd_names
TEMPLATE_ENTRY_POINTS_NAME_CASE.format(enum=cmd) for cmd in sorted_cmd_names
]
entry_points_enum_source = template_entry_points_enum_source.format(
entry_points_enum_source = TEMPLATE_ENTRY_POINTS_ENUM_SOURCE.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
lib="GL/GLES",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment