blob: b574da2762248b3ebcd04f283c8b152d29c7e5f0 [file] [log] [blame]
Jeff Gilbert1b605ee2017-10-30 18:41:46 -07001#!/usr/bin/python2
Jamie Madill2e16d962017-04-19 14:06:36 -04002#
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
Corentin Wallez2e568cf2017-09-18 17:05:22 -040010import sys, os, pprint, json
Jamie Madill2e16d962017-04-19 14:06:36 -040011import xml.etree.ElementTree as etree
12from datetime import date
13
Jamie Madillfa920eb2018-01-04 11:45:50 -050014# List of supported extensions. Add to this list to enable new extensions
15# available in gl.xml.
Brandon Jones416aaf92018-04-10 08:10:16 -070016
17angle_extensions = [
18 # ANGLE extensions
19 "GL_CHROMIUM_bind_uniform_location",
20 "GL_CHROMIUM_framebuffer_mixed_samples",
21 "GL_CHROMIUM_path_rendering",
22 "GL_CHROMIUM_copy_texture",
23 "GL_CHROMIUM_copy_compressed_texture",
24 "GL_ANGLE_request_extension",
25 "GL_ANGLE_robust_client_memory",
26 "GL_ANGLE_multiview",
27]
28
Lingfeng Yanga0648782018-03-12 14:45:25 -070029gles1_extensions = [
30 # ES1 (Possibly the min set of extensions needed by Android)
31 "GL_OES_draw_texture",
32 "GL_OES_framebuffer_object",
33 "GL_OES_matrix_palette",
Geoff Lang2aaa7b42018-01-12 17:17:27 -050034 "GL_OES_point_size_array",
35 "GL_OES_query_matrix",
Lingfeng Yanga0648782018-03-12 14:45:25 -070036 "GL_OES_texture_cube_map",
37]
38
39# List of GLES1 extensions for which we don't need to add Context.h decls.
40gles1_no_context_decl_extensions = [
41 "GL_OES_framebuffer_object",
42]
43
44# List of GLES1 API calls that have had their semantics changed in later GLES versions, but the
45# name was kept the same
46gles1_overloaded = [
47 "glGetPointerv",
48]
49
Brandon Jones416aaf92018-04-10 08:10:16 -070050supported_extensions = sorted(angle_extensions + gles1_extensions + [
Geoff Lang2aaa7b42018-01-12 17:17:27 -050051 # ES2+
Jamie Madillfa920eb2018-01-04 11:45:50 -050052 "GL_ANGLE_framebuffer_blit",
53 "GL_ANGLE_framebuffer_multisample",
54 "GL_ANGLE_instanced_arrays",
55 "GL_ANGLE_translated_shader_source",
56 "GL_EXT_debug_marker",
57 "GL_EXT_discard_framebuffer",
58 "GL_EXT_disjoint_timer_query",
59 "GL_EXT_draw_buffers",
Jiawei Shao5f9482f2018-05-18 09:00:09 +080060 "GL_EXT_geometry_shader",
Jamie Madillfa920eb2018-01-04 11:45:50 -050061 "GL_EXT_map_buffer_range",
62 "GL_EXT_occlusion_query_boolean",
63 "GL_EXT_robustness",
64 "GL_EXT_texture_storage",
65 "GL_KHR_debug",
66 "GL_NV_fence",
67 "GL_OES_EGL_image",
68 "GL_OES_get_program_binary",
69 "GL_OES_mapbuffer",
Olli Etuaho064458a2018-08-30 14:02:02 +030070 "GL_OES_texture_storage_multisample_2d_array",
Jamie Madillfa920eb2018-01-04 11:45:50 -050071 "GL_OES_vertex_array_object",
jchen1082af6202018-06-22 10:59:52 +080072 "GL_KHR_parallel_shader_compile",
Jamie Madillfa920eb2018-01-04 11:45:50 -050073])
74
Brandon Jones2b0cdcc2018-05-02 08:02:50 -070075# The EGL_ANGLE_explicit_context extension is generated differently from other extensions.
76# Toggle generation here.
77support_EGL_ANGLE_explicit_context = True
78
Jamie Madillfa920eb2018-01-04 11:45:50 -050079# This is a list of exceptions for entry points which don't want to have
80# the EVENT macro. This is required for some debug marker entry points.
81no_event_marker_exceptions_list = sorted([
82 "glPushGroupMarkerEXT",
83 "glPopGroupMarkerEXT",
84 "glInsertEventMarkerEXT",
85])
86
87# Strip these suffixes from Context entry point names. NV is excluded (for now).
Brandon Jones416aaf92018-04-10 08:10:16 -070088strip_suffixes = ["ANGLE", "EXT", "KHR", "OES", "CHROMIUM"]
Jamie Madillfa920eb2018-01-04 11:45:50 -050089
Jamie Madill2e16d962017-04-19 14:06:36 -040090template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
91// Generated by {script_name} using data from {data_source_name}.
92//
93// Copyright {year} The ANGLE Project Authors. All rights reserved.
94// Use of this source code is governed by a BSD-style license that can be
95// found in the LICENSE file.
96//
Jamie Madillc8c9a242018-01-02 13:39:00 -050097// entry_points_gles_{annotation_lower}_autogen.h:
98// Defines the GLES {comment} entry points.
Jamie Madill2e16d962017-04-19 14:06:36 -040099
Jamie Madillc8c9a242018-01-02 13:39:00 -0500100#ifndef LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
101#define LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
Jamie Madill2e16d962017-04-19 14:06:36 -0400102
Jamie Madillc8c9a242018-01-02 13:39:00 -0500103{includes}
104
Jamie Madill2e16d962017-04-19 14:06:36 -0400105namespace gl
106{{
107{entry_points}
108}} // namespace gl
109
Jamie Madillc8c9a242018-01-02 13:39:00 -0500110#endif // LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
Jamie Madill2e16d962017-04-19 14:06:36 -0400111"""
112
Jamie Madillee769dd2017-05-04 11:38:30 -0400113template_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
114// Generated by {script_name} using data from {data_source_name}.
115//
116// Copyright {year} The ANGLE Project Authors. All rights reserved.
117// Use of this source code is governed by a BSD-style license that can be
118// found in the LICENSE file.
119//
Jamie Madillc8c9a242018-01-02 13:39:00 -0500120// entry_points_gles_{annotation_lower}_autogen.cpp:
121// Defines the GLES {comment} entry points.
Jamie Madillee769dd2017-05-04 11:38:30 -0400122
Jamie Madillc8c9a242018-01-02 13:39:00 -0500123{includes}
Jamie Madillee769dd2017-05-04 11:38:30 -0400124
125namespace gl
126{{
127{entry_points}}} // namespace gl
128"""
129
130template_entry_points_enum_header = """// GENERATED FILE - DO NOT EDIT.
131// Generated by {script_name} using data from {data_source_name}.
132//
133// Copyright {year} The ANGLE Project Authors. All rights reserved.
134// Use of this source code is governed by a BSD-style license that can be
135// found in the LICENSE file.
136//
137// entry_points_enum_autogen.h:
138// Defines the GLES entry points enumeration.
139
140#ifndef LIBGLESV2_ENTRYPOINTSENUM_AUTOGEN_H_
141#define LIBGLESV2_ENTRYPOINTSENUM_AUTOGEN_H_
142
143namespace gl
144{{
145enum class EntryPoint
146{{
147{entry_points_list}
148}};
149}} // namespace gl
150#endif // LIBGLESV2_ENTRY_POINTS_ENUM_AUTOGEN_H_
151"""
152
Brandon Jones41e59f52018-05-02 12:45:28 -0700153template_libgles_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
154// Generated by {script_name} using data from {data_source_name}.
155//
156// Copyright {year} The ANGLE Project Authors. All rights reserved.
157// Use of this source code is governed by a BSD-style license that can be
158// found in the LICENSE file.
159//
160// libGLESv2.cpp: Implements the exported OpenGL ES functions.
161
162{includes}
163extern "C" {{
164{entry_points}
165}} // extern "C"
166"""
167
168template_libgles_entry_point_export = """; GENERATED FILE - DO NOT EDIT.
169; Generated by {script_name} using data from {data_source_name}.
170;
171; Copyright {year} The ANGLE Project Authors. All rights reserved.
172; Use of this source code is governed by a BSD-style license that can be
173; found in the LICENSE file.
174LIBRARY libGLESv2
175EXPORTS
176{exports}
177"""
178
Jamie Madill2e16d962017-04-19 14:06:36 -0400179template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}({params});"""
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700180template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
Jamie Madill2e16d962017-04-19 14:06:36 -0400181
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700182template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
Jamie Madillee769dd2017-05-04 11:38:30 -0400183{{
Geoff Langb02fc662018-08-21 09:48:01 -0400184 ANGLE_SCOPED_GLOBAL_LOCK();
Jamie Madillfa920eb2018-01-04 11:45:50 -0500185 {event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400186
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700187 Context *context = {context_getter};
Jamie Madillee769dd2017-05-04 11:38:30 -0400188 if (context)
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700189 {{{assert_explicit_context}{packed_gl_enum_conversions}
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400190 context->gatherParams<EntryPoint::{name}>({internal_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400191
Jamie Madill53d38412017-04-20 11:33:00 -0400192 if (context->skipValidation() || Validate{name}({validate_params}))
Jamie Madillee769dd2017-05-04 11:38:30 -0400193 {{
Jamie Madillc8c9a242018-01-02 13:39:00 -0500194 {return_if_needed}context->{name_lower_no_suffix}({internal_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400195 }}
Jamie Madillee769dd2017-05-04 11:38:30 -0400196 }}
197{default_return_if_needed}}}
198"""
199
Lingfeng Yanga0648782018-03-12 14:45:25 -0700200context_gles_header = """// GENERATED FILE - DO NOT EDIT.
201// Generated by {script_name} using data from {data_source_name}.
202//
203// Copyright {year} The ANGLE Project Authors. All rights reserved.
204// Use of this source code is governed by a BSD-style license that can be
205// found in the LICENSE file.
206//
207// Context_gles_{annotation_lower}_autogen.h: Creates a macro for interfaces in Context.
208
209#ifndef ANGLE_CONTEXT_GLES_{annotation_upper}_AUTOGEN_H_
210#define ANGLE_CONTEXT_GLES_{annotation_upper}_AUTOGEN_H_
211
212#define ANGLE_GLES1_CONTEXT_API \\
213{interface}
214
215#endif // ANGLE_CONTEXT_API_{annotation_upper}_AUTOGEN_H_
216"""
217
218context_gles_decl = """ {return_type} {name_lower_no_suffix}({internal_params}); \\"""
219
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700220libgles_entry_point_def = """{return_type}GL_APIENTRY gl{name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
Brandon Jones41e59f52018-05-02 12:45:28 -0700221{{
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700222 return gl::{name}{explicit_context_suffix}({explicit_context_internal_param}{explicit_context_comma}{internal_params});
Brandon Jones41e59f52018-05-02 12:45:28 -0700223}}
224"""
225
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700226libgles_entry_point_export = """ {name}{explicit_context_suffix}{spaces}@{ordinal}"""
227
228template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT.
229// Generated by {script_name} using data from {data_source_name}.
230//
231// Copyright {year} The ANGLE Project Authors. All rights reserved.
232// Use of this source code is governed by a BSD-style license that can be
233// found in the LICENSE file.
234//
235// gl{version}ext_explicit_context_autogen.inc:
236// Function declarations for the EGL_ANGLE_explicit_context extension
237
238{function_pointers}
239#ifdef GL_GLEXT_PROTOTYPES
240{function_prototypes}
241#endif
242"""
243
244template_glext_function_pointer = """typedef {return_type}(GL_APIENTRYP PFN{name_upper}{explicit_context_suffix_upper})({explicit_context_param}{explicit_context_comma}{params});"""
245template_glext_function_prototype = """{apicall} {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
Brandon Jones41e59f52018-05-02 12:45:28 -0700246
Jamie Madill16daadb2017-08-26 23:34:31 -0400247def script_relative(path):
248 return os.path.join(os.path.dirname(sys.argv[0]), path)
249
250tree = etree.parse(script_relative('gl.xml'))
251root = tree.getroot()
Jamie Madill2e16d962017-04-19 14:06:36 -0400252commands = root.find(".//commands[@namespace='GL']")
Jamie Madill2e16d962017-04-19 14:06:36 -0400253
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400254with open(script_relative('entry_point_packed_gl_enums.json')) as f:
255 cmd_packed_gl_enums = json.loads(f.read())
256
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700257def format_entry_point_decl(cmd_name, proto, params, is_explicit_context):
258 comma_if_needed = ", " if len(params) > 0 else ""
Jamie Madill2e16d962017-04-19 14:06:36 -0400259 return template_entry_point_decl.format(
260 name = cmd_name[2:],
261 return_type = proto[:-len(cmd_name)],
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700262 params = ", ".join(params),
263 comma_if_needed = comma_if_needed,
264 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
265 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
266 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "")
Jamie Madill2e16d962017-04-19 14:06:36 -0400267
Jamie Madillee769dd2017-05-04 11:38:30 -0400268def type_name_sep_index(param):
269 space = param.rfind(" ")
270 pointer = param.rfind("*")
271 return max(space, pointer)
272
273def just_the_type(param):
Lingfeng Yanga0648782018-03-12 14:45:25 -0700274 if "*" in param:
275 return param[:type_name_sep_index(param) + 1]
Jamie Madillee769dd2017-05-04 11:38:30 -0400276 return param[:type_name_sep_index(param)]
277
278def just_the_name(param):
279 return param[type_name_sep_index(param)+1:]
280
Lingfeng Yanga0648782018-03-12 14:45:25 -0700281def make_param(param_type, param_name):
282 return param_type + " " + param_name
283
284def just_the_type_packed(param, entry):
285 name = just_the_name(param)
286 if entry.has_key(name):
287 return entry[name]
288 else:
289 return just_the_type(param)
290
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400291def just_the_name_packed(param, reserved_set):
292 name = just_the_name(param)
293 if name in reserved_set:
294 return name + 'Packed'
295 else:
296 return name
297
Jamie Madillee769dd2017-05-04 11:38:30 -0400298format_dict = {
299 "GLbitfield": "0x%X",
300 "GLboolean": "%u",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500301 "GLclampx": "0x%X",
Jamie Madillee769dd2017-05-04 11:38:30 -0400302 "GLenum": "0x%X",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500303 "GLfixed": "0x%X",
Jamie Madillee769dd2017-05-04 11:38:30 -0400304 "GLfloat": "%f",
305 "GLint": "%d",
306 "GLintptr": "%d",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500307 "GLshort": "%d",
Jamie Madillee769dd2017-05-04 11:38:30 -0400308 "GLsizei": "%d",
309 "GLsizeiptr": "%d",
Jamie Madill16daadb2017-08-26 23:34:31 -0400310 "GLsync": "0x%0.8p",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500311 "GLubyte": "%d",
Jamie Madillff161f82017-08-26 23:49:10 -0400312 "GLuint": "%u",
Jamie Madillfa920eb2018-01-04 11:45:50 -0500313 "GLuint64": "%llu",
314 "GLDEBUGPROC": "0x%0.8p",
315 "GLDEBUGPROCKHR": "0x%0.8p",
316 "GLeglImageOES": "0x%0.8p",
Jamie Madillee769dd2017-05-04 11:38:30 -0400317}
318
319def param_format_string(param):
320 if "*" in param:
321 return param + " = 0x%0.8p"
322 else:
Jamie Madill16daadb2017-08-26 23:34:31 -0400323 type_only = just_the_type(param)
324 if type_only not in format_dict:
325 raise Exception(type_only + " is not a known type in 'format_dict'")
326
327 return param + " = " + format_dict[type_only]
Jamie Madillee769dd2017-05-04 11:38:30 -0400328
Jamie Madill2e29b132017-08-28 17:22:11 -0400329def default_return_value(cmd_name, return_type):
Jamie Madillee769dd2017-05-04 11:38:30 -0400330 if return_type == "void":
331 return ""
Jamie Madill2e29b132017-08-28 17:22:11 -0400332 return "GetDefaultReturnValue<EntryPoint::" + cmd_name[2:] + ", " + return_type + ">()"
Jamie Madillee769dd2017-05-04 11:38:30 -0400333
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700334def get_context_getter_function(cmd_name, is_explicit_context):
Geoff Langcae72d62017-06-01 11:53:45 -0400335 if cmd_name == "glGetError":
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700336 return "GetGlobalContext()"
337 elif is_explicit_context:
338 return "static_cast<gl::Context *>(ctx)"
Geoff Langcae72d62017-06-01 11:53:45 -0400339 else:
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700340 return "GetValidGlobalContext()"
Geoff Langcae72d62017-06-01 11:53:45 -0400341
Jamie Madillfa920eb2018-01-04 11:45:50 -0500342template_event_comment = """// Don't run an EVENT() macro on the EXT_debug_marker entry points.
343 // It can interfere with the debug events being set by the caller.
344 // """
345
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700346def format_entry_point_def(cmd_name, proto, params, is_explicit_context):
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400347 packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
348 internal_params = [just_the_name_packed(param, packed_gl_enums) for param in params]
349 packed_gl_enum_conversions = []
350 for param in params:
351 name = just_the_name(param)
352 if name in packed_gl_enums:
353 internal_name = name + "Packed"
354 internal_type = packed_gl_enums[name]
355 packed_gl_enum_conversions += ["\n " + internal_type + " " + internal_name +" = FromGLenum<" +
356 internal_type + ">(" + name + ");"]
357
Jamie Madillee769dd2017-05-04 11:38:30 -0400358 pass_params = [just_the_name(param) for param in params]
359 format_params = [param_format_string(param) for param in params]
360 return_type = proto[:-len(cmd_name)]
Jamie Madill2e29b132017-08-28 17:22:11 -0400361 default_return = default_return_value(cmd_name, return_type.strip())
Jamie Madillfa920eb2018-01-04 11:45:50 -0500362 event_comment = template_event_comment if cmd_name in no_event_marker_exceptions_list else ""
Jamie Madillc8c9a242018-01-02 13:39:00 -0500363 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:]
364
Jamie Madillfa920eb2018-01-04 11:45:50 -0500365 for suffix in strip_suffixes:
366 if name_lower_no_suffix.endswith(suffix):
367 name_lower_no_suffix = name_lower_no_suffix[0:-len(suffix)]
368
Jamie Madillee769dd2017-05-04 11:38:30 -0400369 return template_entry_point_def.format(
370 name = cmd_name[2:],
Jamie Madillc8c9a242018-01-02 13:39:00 -0500371 name_lower_no_suffix = name_lower_no_suffix,
Jamie Madillee769dd2017-05-04 11:38:30 -0400372 return_type = return_type,
373 params = ", ".join(params),
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400374 internal_params = ", ".join(internal_params),
375 packed_gl_enum_conversions = "".join(packed_gl_enum_conversions),
Jamie Madillee769dd2017-05-04 11:38:30 -0400376 pass_params = ", ".join(pass_params),
377 comma_if_needed = ", " if len(params) > 0 else "",
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400378 validate_params = ", ".join(["context"] + internal_params),
Jamie Madillee769dd2017-05-04 11:38:30 -0400379 format_params = ", ".join(format_params),
Jamie Madillee769dd2017-05-04 11:38:30 -0400380 return_if_needed = "" if default_return == "" else "return ",
Geoff Langcae72d62017-06-01 11:53:45 -0400381 default_return_if_needed = "" if default_return == "" else "\n return " + default_return + ";\n",
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700382 context_getter = get_context_getter_function(cmd_name, is_explicit_context),
383 event_comment = event_comment,
384 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
385 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
386 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
387 assert_explicit_context = "\nASSERT(context == GetValidGlobalContext());"
388 if is_explicit_context else "")
Jamie Madillee769dd2017-05-04 11:38:30 -0400389
Lingfeng Yanga0648782018-03-12 14:45:25 -0700390def format_context_gles_decl(cmd_name, proto, params):
391 packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
392 internal_params = ", ".join([make_param(just_the_type_packed(param, packed_gl_enums),
393 just_the_name_packed(param, packed_gl_enums)) for param in params])
394
395 return_type = proto[:-len(cmd_name)]
396 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:]
397
398 for suffix in strip_suffixes:
399 if name_lower_no_suffix.endswith(suffix):
400 name_lower_no_suffix = name_lower_no_suffix[0:-len(suffix)]
401
402 return context_gles_decl.format(
403 return_type = return_type,
404 name_lower_no_suffix = name_lower_no_suffix,
405 internal_params = internal_params)
406
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700407def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context):
Brandon Jones41e59f52018-05-02 12:45:28 -0700408 internal_params = [just_the_name(param) for param in params]
409 return_type = proto[:-len(cmd_name)]
410
411 return libgles_entry_point_def.format(
412 name = cmd_name[2:],
413 return_type = return_type,
414 params = ", ".join(params),
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700415 internal_params = ", ".join(internal_params),
416 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
417 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
418 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
419 explicit_context_internal_param = "ctx" if is_explicit_context else "")
Brandon Jones41e59f52018-05-02 12:45:28 -0700420
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700421def format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context):
Brandon Jones41e59f52018-05-02 12:45:28 -0700422 return libgles_entry_point_export.format(
423 name = cmd_name,
424 ordinal = ordinal,
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700425 spaces = " "*(50 - len(cmd_name)),
426 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "")
Brandon Jones41e59f52018-05-02 12:45:28 -0700427
Jiajia Qincb59a902017-11-22 13:03:42 +0800428def path_to(folder, file):
429 return os.path.join(script_relative(".."), "src", folder, file)
Jamie Madill2e16d962017-04-19 14:06:36 -0400430
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700431def get_entry_points(all_commands, gles_commands, ordinal, is_explicit_context):
Jamie Madillc8c9a242018-01-02 13:39:00 -0500432 decls = []
433 defs = []
Brandon Jones41e59f52018-05-02 12:45:28 -0700434 export_defs = []
435 exports = []
436
Jamie Madillffa2cd02017-12-28 14:57:53 -0500437 for command in all_commands:
438 proto = command.find('proto')
439 cmd_name = proto.find('name').text
440
441 if cmd_name not in gles_commands:
442 continue
443
444 param_text = ["".join(param.itertext()) for param in command.findall('param')]
445 proto_text = "".join(proto.itertext())
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700446 decls.append(format_entry_point_decl(cmd_name, proto_text, param_text,
447 is_explicit_context))
448 defs.append(format_entry_point_def(cmd_name, proto_text, param_text, is_explicit_context))
Brandon Jones41e59f52018-05-02 12:45:28 -0700449
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700450 export_defs.append(format_libgles_entry_point_def(cmd_name, proto_text, param_text,
451 is_explicit_context))
452 exports.append(format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context))
Brandon Jones41e59f52018-05-02 12:45:28 -0700453 ordinal = ordinal + 1
454
455 return decls, defs, export_defs, exports
Jamie Madill16daadb2017-08-26 23:34:31 -0400456
Lingfeng Yanga0648782018-03-12 14:45:25 -0700457def get_gles1_decls(all_commands, gles_commands):
458 decls = []
459 for command in all_commands:
460 proto = command.find('proto')
461 cmd_name = proto.find('name').text
462
463 if cmd_name not in gles_commands:
464 continue
465
466 if cmd_name in gles1_overloaded:
467 continue
468
469 param_text = ["".join(param.itertext()) for param in command.findall('param')]
470 proto_text = "".join(proto.itertext())
471 decls.append(format_context_gles_decl(cmd_name, proto_text, param_text))
472
473 return decls
474
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700475def get_glext_decls(all_commands, gles_commands, version, is_explicit_context):
476 glext_ptrs = []
477 glext_protos = []
478 is_gles1 = False
479
480 if(version == ""):
481 is_gles1 = True
482
483 for command in all_commands:
484 proto = command.find('proto')
485 cmd_name = proto.find('name').text
486
487 if cmd_name not in gles_commands:
488 continue
489
490 param_text = ["".join(param.itertext()) for param in command.findall('param')]
491 proto_text = "".join(proto.itertext())
492
493 return_type = proto_text[:-len(cmd_name)]
494 params = ", ".join(param_text)
495
496 format_params = {
497 "apicall": "GL_API" if is_gles1 else "GL_APICALL",
498 "name": cmd_name,
499 "name_upper": cmd_name.upper(),
500 "return_type": return_type,
501 "params": params,
502 "explicit_context_comma": ", " if is_explicit_context and len(params) > 0 else "",
503 "explicit_context_suffix": "ContextANGLE" if is_explicit_context else "",
504 "explicit_context_suffix_upper": "CONTEXTANGLE" if is_explicit_context else "",
505 "explicit_context_param": "GLeglContext ctx" if is_explicit_context else ""}
506
507 glext_ptrs.append(template_glext_function_pointer.format(
508 **format_params))
509 glext_protos.append(template_glext_function_prototype.format(
510 **format_params))
511
512 return glext_ptrs, glext_protos
513
Brandon Jones416aaf92018-04-10 08:10:16 -0700514def write_file(annotation, comment, template, entry_points, suffix, includes, file):
Jiajia Qincb59a902017-11-22 13:03:42 +0800515
Jamie Madillc8c9a242018-01-02 13:39:00 -0500516 content = template.format(
517 script_name = os.path.basename(sys.argv[0]),
Brandon Jones416aaf92018-04-10 08:10:16 -0700518 data_source_name = file,
Jamie Madillc8c9a242018-01-02 13:39:00 -0500519 year = date.today().year,
520 annotation_lower = annotation.lower(),
521 annotation_upper = annotation.upper(),
522 comment = comment,
523 includes = includes,
524 entry_points = entry_points)
Jiajia Qincb59a902017-11-22 13:03:42 +0800525
Jamie Madillc8c9a242018-01-02 13:39:00 -0500526 path = path_to("libGLESv2", "entry_points_gles_{}_autogen.{}".format(
527 annotation.lower(), suffix))
528
529 with open(path, "w") as out:
530 out.write(content)
531 out.close()
532
Brandon Jones41e59f52018-05-02 12:45:28 -0700533def write_export_files(entry_points, includes, exports):
534
535 content = template_libgles_entry_point_source.format(
536 script_name = os.path.basename(sys.argv[0]),
537 data_source_name = "gl.xml and gl_angle_ext.xml",
538 year = date.today().year,
539 includes = includes,
540 entry_points = entry_points)
541
542 path = path_to("libGLESv2", "libGLESv2_autogen.cpp")
543
544 with open(path, "w") as out:
545 out.write(content)
546 out.close()
547
548 content = template_libgles_entry_point_export.format(
549 script_name = os.path.basename(sys.argv[0]),
550 data_source_name = "gl.xml and gl_angle_ext.xml",
551 exports = exports,
552 year = date.today().year)
553
554 path = path_to("libGLESv2", "libGLESv2_autogen.def")
555
556 with open(path, "w") as out:
557 out.write(content)
558 out.close()
559
Lingfeng Yanga0648782018-03-12 14:45:25 -0700560def write_context_api_decls(annotation, template, decls):
561
562 interface_lines = []
563
564 for i in decls['core']:
565 interface_lines.append(i)
566
567 for extname in sorted(decls['exts'].keys()):
568 interface_lines.append(" /* " + extname + " */ \\")
569 interface_lines.extend(decls['exts'][extname])
570
571 content = template.format(
572 annotation_lower = annotation.lower(),
573 annotation_upper = annotation.upper(),
574 script_name = os.path.basename(sys.argv[0]),
575 data_source_name = "gl.xml",
576 year = date.today().year,
577 interface = "\n".join(interface_lines))
578
579 path = path_to("libANGLE", "Context_gles_%s_autogen.h" % annotation.lower())
580
581 with open(path, "w") as out:
582 out.write(content)
583 out.close()
584
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700585def write_glext_explicit_context_inc(version, ptrs, protos):
586 folder_version = version if version != "31" else "3"
587
588 content = template_glext_explicit_context_inc.format(
589 script_name = os.path.basename(sys.argv[0]),
590 data_source_name = "gl.xml and gl_angle_ext.xml",
591 year = date.today().year,
592 version = version,
593 function_pointers = ptrs,
594 function_prototypes = protos)
595
Brandon Jones795ab712018-05-24 15:45:40 -0700596 path = os.path.join(script_relative(".."), "include", "GLES{}".format(folder_version),
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700597 "gl{}ext_explicit_context_autogen.inc".format(version))
598
599 with open(path, "w") as out:
600 out.write(content)
601 out.close()
602
Brandon Jones416aaf92018-04-10 08:10:16 -0700603def append_angle_extensions(base_root):
604 angle_ext_tree = etree.parse(script_relative('gl_angle_ext.xml'))
605 angle_ext_root = angle_ext_tree.getroot()
606
607 insertion_point = base_root.findall("./commands")[0]
608 for command in angle_ext_root.iter('commands'):
609 insertion_point.extend(command)
610
611 insertion_point = base_root.findall("./extensions")[0]
612 for extension in angle_ext_root.iter('extensions'):
613 insertion_point.extend(extension)
614 return base_root
615
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700616class GLCommandNames:
617 def __init__(self):
618 self.command_names = {}
619
620 def get_commands(self, version):
621 return self.command_names[version]
622
623 def get_all_commands(self):
624 cmd_names = []
625 # Combine all the version lists into a single list
626 for version, version_cmd_names in sorted(self.command_names.iteritems()):
627 cmd_names += version_cmd_names
628
629 return cmd_names
630
631 def add_commands(self, version, commands):
632 # Add key if it doesn't exist
633 if version not in self.command_names:
634 self.command_names[version] = []
635 # Add the commands that aren't duplicates
636 self.command_names[version] += commands
637
Brandon Jones416aaf92018-04-10 08:10:16 -0700638root = append_angle_extensions(root)
639
Jamie Madillc8c9a242018-01-02 13:39:00 -0500640all_commands = root.findall('commands/command')
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700641all_cmd_names = GLCommandNames()
Jamie Madillc8c9a242018-01-02 13:39:00 -0500642
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500643template_header_includes = """#include <GLES{major}/gl{major}{minor}.h>
Jamie Madillc8c9a242018-01-02 13:39:00 -0500644#include <export.h>"""
645
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500646template_sources_includes = """#include "libGLESv2/entry_points_gles_{}_autogen.h"
647
648#include "libANGLE/Context.h"
Jamie Madillc8c9a242018-01-02 13:39:00 -0500649#include "libANGLE/validationES{}{}.h"
650#include "libGLESv2/global_state.h"
651"""
652
Lingfeng Yanga0648782018-03-12 14:45:25 -0700653gles1decls = {}
654
655gles1decls['core'] = []
656gles1decls['exts'] = {}
657
Brandon Jones41e59f52018-05-02 12:45:28 -0700658libgles_ep_defs = []
659libgles_ep_exports = []
660
661ordinal_start = 1
662
Lingfeng Yanga0648782018-03-12 14:45:25 -0700663# First run through the main GLES entry points. Since ES2+ is the primary use
664# case, we go through those first and then add ES1-only APIs at the end.
665for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]:
Jamie Madillc8c9a242018-01-02 13:39:00 -0500666 annotation = "{}_{}".format(major_version, minor_version)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500667 name_prefix = "GL_ES_VERSION_"
Lingfeng Yanga0648782018-03-12 14:45:25 -0700668
669 is_gles1 = major_version == 1
670 if is_gles1:
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500671 name_prefix = "GL_VERSION_ES_CM_"
Lingfeng Yanga0648782018-03-12 14:45:25 -0700672
Jamie Madillc8c9a242018-01-02 13:39:00 -0500673 comment = annotation.replace("_", ".")
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500674 gles_xpath = ".//feature[@name='{}{}']//command".format(name_prefix, annotation)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500675 gles_commands = [cmd.attrib['name'] for cmd in root.findall(gles_xpath)]
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500676
677 # Remove commands that have already been processed
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700678 gles_commands = [cmd for cmd in gles_commands if cmd not in all_cmd_names.get_all_commands()]
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500679
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700680 all_cmd_names.add_commands(annotation, gles_commands)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500681
Brandon Jones41e59f52018-05-02 12:45:28 -0700682 decls, defs, libgles_defs, libgles_exports = get_entry_points(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700683 all_commands, gles_commands, ordinal_start, False)
Brandon Jones41e59f52018-05-02 12:45:28 -0700684
685 # Increment the ordinal before inserting the version comment
686 ordinal_start += len(libgles_exports)
687
688 # Write the version as a comment before the first EP.
689 libgles_defs.insert(0, "\n// OpenGL ES {}.{}".format(major_version, minor_version))
690 libgles_exports.insert(0, "\n ; OpenGL ES {}.{}".format(major_version, minor_version))
691
692 libgles_ep_defs += libgles_defs
693 libgles_ep_exports += libgles_exports
Jamie Madillc8c9a242018-01-02 13:39:00 -0500694
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500695 major_if_not_one = major_version if major_version != 1 else ""
Jamie Madillc8c9a242018-01-02 13:39:00 -0500696 minor_if_not_zero = minor_version if minor_version != 0 else ""
697
698 header_includes = template_header_includes.format(
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500699 major=major_if_not_one, minor=minor_if_not_zero)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500700
701 # We include the platform.h header since it undefines the conflicting MemoryBarrier macro.
702 if major_version == 3 and minor_version == 1:
703 header_includes += "\n#include \"common/platform.h\"\n"
704
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500705 source_includes = template_sources_includes.format(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700706 annotation.lower(), major_version, minor_if_not_zero)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500707
708 write_file(annotation, comment, template_entry_point_header,
Brandon Jones416aaf92018-04-10 08:10:16 -0700709 "\n".join(decls), "h", header_includes, "gl.xml")
Jamie Madillc8c9a242018-01-02 13:39:00 -0500710 write_file(annotation, comment, template_entry_point_source,
Brandon Jones416aaf92018-04-10 08:10:16 -0700711 "\n".join(defs), "cpp", source_includes, "gl.xml")
Lingfeng Yanga0648782018-03-12 14:45:25 -0700712 if is_gles1:
713 gles1decls['core'] = get_gles1_decls(all_commands, gles_commands)
714
Jamie Madill57ae8c12017-08-30 12:14:29 -0400715
Jamie Madillfa920eb2018-01-04 11:45:50 -0500716# After we finish with the main entry points, we process the extensions.
717extension_defs = []
718extension_decls = []
719
720# Use a first step to run through the extensions so we can generate them
721# in sorted order.
722ext_data = {}
723
Lingfeng Yanga0648782018-03-12 14:45:25 -0700724for gles1ext in gles1_extensions:
725 gles1decls['exts'][gles1ext] = []
726
Jamie Madillfa920eb2018-01-04 11:45:50 -0500727for extension in root.findall("extensions/extension"):
728 extension_name = extension.attrib['name']
729 if not extension_name in supported_extensions:
730 continue
731
732 ext_cmd_names = []
733
734 # There's an extra step here to filter out 'api=gl' extensions. This
735 # is necessary for handling KHR extensions, which have separate entry
736 # point signatures (without the suffix) for desktop GL. Note that this
737 # extra step is necessary because of Etree's limited Xpath support.
738 for require in extension.findall('require'):
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500739 if 'api' in require.attrib and require.attrib['api'] != 'gles2' and require.attrib['api'] != 'gles1':
Jamie Madillfa920eb2018-01-04 11:45:50 -0500740 continue
741
742 # Another special case for EXT_texture_storage
743 filter_out_comment = "Supported only if GL_EXT_direct_state_access is supported"
744 if 'comment' in require.attrib and require.attrib['comment'] == filter_out_comment:
745 continue
746
747 extension_commands = require.findall('command')
748 ext_cmd_names += [command.attrib['name'] for command in extension_commands]
749
750 ext_data[extension_name] = sorted(ext_cmd_names)
751
752for extension_name, ext_cmd_names in sorted(ext_data.iteritems()):
753
754 # Detect and filter duplicate extensions.
755 dupes = []
756 for ext_cmd in ext_cmd_names:
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700757 if ext_cmd in all_cmd_names.get_all_commands():
Jamie Madillfa920eb2018-01-04 11:45:50 -0500758 dupes.append(ext_cmd)
759
760 for dupe in dupes:
761 ext_cmd_names.remove(dupe)
762
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700763 if extension_name in gles1_extensions:
764 all_cmd_names.add_commands("glext", ext_cmd_names)
765 else:
766 all_cmd_names.add_commands("gl2ext", ext_cmd_names)
Jamie Madillfa920eb2018-01-04 11:45:50 -0500767
Brandon Jones41e59f52018-05-02 12:45:28 -0700768 decls, defs, libgles_defs, libgles_exports = get_entry_points(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700769 all_commands, ext_cmd_names, ordinal_start, False)
Jamie Madillfa920eb2018-01-04 11:45:50 -0500770
771 # Avoid writing out entry points defined by a prior extension.
772 for dupe in dupes:
773 msg = "// {} is already defined.\n".format(dupe[2:])
774 defs.append(msg)
775
Brandon Jones41e59f52018-05-02 12:45:28 -0700776 # Increment starting ordinal before adding extension comment
777 ordinal_start += len(libgles_exports)
778
Jamie Madillfa920eb2018-01-04 11:45:50 -0500779 # Write the extension name as a comment before the first EP.
780 comment = "\n// {}".format(extension_name)
781 defs.insert(0, comment)
782 decls.insert(0, comment)
Brandon Jones41e59f52018-05-02 12:45:28 -0700783 libgles_defs.insert(0, comment)
784 libgles_exports.insert(0, "\n ; {}".format(extension_name))
Jamie Madillfa920eb2018-01-04 11:45:50 -0500785
786 extension_defs += defs
787 extension_decls += decls
788
Brandon Jones41e59f52018-05-02 12:45:28 -0700789 libgles_ep_defs += libgles_defs
790 libgles_ep_exports += libgles_exports
791
Lingfeng Yanga0648782018-03-12 14:45:25 -0700792 if extension_name in gles1_extensions:
793 if extension_name not in gles1_no_context_decl_extensions:
794 gles1decls['exts'][extension_name] = get_gles1_decls(all_commands, ext_cmd_names)
795
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700796# Special handling for EGL_ANGLE_explicit_context extension
797if support_EGL_ANGLE_explicit_context:
798 comment = "\n// EGL_ANGLE_explicit_context"
799 extension_defs.append(comment)
800 extension_decls.append(comment)
801 libgles_ep_defs.append(comment)
802 libgles_ep_exports.append("\n ; EGL_ANGLE_explicit_context")
803
804 # Get the explicit context entry points
805 decls, defs, libgles_defs, libgles_exports = get_entry_points(all_commands,
806 all_cmd_names.get_all_commands(), ordinal_start, True)
807
808 # Append the explicit context entry points
809 extension_decls += decls
810 extension_defs += defs
811 libgles_ep_defs += libgles_defs
812 libgles_ep_exports += libgles_exports
813
814 # Generate .inc files for extension function pointers and declarations
815 for major, minor in [[2, 0], [3, 0], [3, 1], [1, 0]]:
816 annotation = "{}_{}".format(major, minor)
817
818 major_if_not_one = major if major != 1 else ""
819 minor_if_not_zero = minor if minor != 0 else ""
820 version = "{}{}".format(major_if_not_one, minor_if_not_zero)
821
822 glext_ptrs, glext_protos = get_glext_decls(all_commands,
823 all_cmd_names.get_commands(annotation), version, True)
824
825 glext_ext_ptrs = []
826 glext_ext_protos = []
827
828 # Append extensions for 1.0 and 2.0
829 if(annotation == "1_0"):
830 glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands,
831 all_cmd_names.get_commands("glext"), version, True)
832 elif(annotation == "2_0"):
833 glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands,
834 all_cmd_names.get_commands("gl2ext"), version, True)
835
836 glext_ptrs += glext_ext_ptrs
837 glext_protos += glext_ext_protos
838
839 write_glext_explicit_context_inc(version, "\n".join(glext_ptrs), "\n".join(glext_protos))
840
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500841header_includes = template_header_includes.format(
842 major="", minor="")
843header_includes += """
844#include <GLES/gl.h>
845#include <GLES/glext.h>
846#include <GLES2/gl2.h>
847#include <GLES2/gl2ext.h>
848"""
Jamie Madillfa920eb2018-01-04 11:45:50 -0500849
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500850source_includes = template_sources_includes.format("ext", "", "")
851source_includes += """
852#include "libANGLE/validationES.h"
853#include "libANGLE/validationES1.h"
Jamie Madillfa920eb2018-01-04 11:45:50 -0500854#include "libANGLE/validationES3.h"
855#include "libANGLE/validationES31.h"
856"""
857
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500858write_file("ext", "extension", template_entry_point_header,
Brandon Jones416aaf92018-04-10 08:10:16 -0700859 "\n".join([item for item in extension_decls]), "h", header_includes,
860 "gl.xml and gl_angle_ext.xml")
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500861write_file("ext", "extension", template_entry_point_source,
Brandon Jones416aaf92018-04-10 08:10:16 -0700862 "\n".join([item for item in extension_defs]), "cpp", source_includes,
863 "gl.xml and gl_angle_ext.xml")
Jamie Madillc8c9a242018-01-02 13:39:00 -0500864
Lingfeng Yanga0648782018-03-12 14:45:25 -0700865write_context_api_decls("1_0", context_gles_header, gles1decls)
866
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700867sorted_cmd_names = ["Invalid"] + [cmd[2:] for cmd in sorted(all_cmd_names.get_all_commands())]
Jamie Madillc8c9a242018-01-02 13:39:00 -0500868
Jamie Madillee769dd2017-05-04 11:38:30 -0400869entry_points_enum = template_entry_points_enum_header.format(
870 script_name = os.path.basename(sys.argv[0]),
Brandon Jones416aaf92018-04-10 08:10:16 -0700871 data_source_name = "gl.xml and gl_angle_ext.xml",
Jamie Madillee769dd2017-05-04 11:38:30 -0400872 year = date.today().year,
Jamie Madillc8c9a242018-01-02 13:39:00 -0500873 entry_points_list = ",\n".join([" " + cmd for cmd in sorted_cmd_names]))
Jamie Madillee769dd2017-05-04 11:38:30 -0400874
Jamie Madillee769dd2017-05-04 11:38:30 -0400875entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h")
Jamie Madillee769dd2017-05-04 11:38:30 -0400876with open(entry_points_enum_header_path, "w") as out:
877 out.write(entry_points_enum)
Geoff Langcae72d62017-06-01 11:53:45 -0400878 out.close()
Brandon Jones41e59f52018-05-02 12:45:28 -0700879
880source_includes = """
881#include "angle_gl.h"
882
883#include "libGLESv2/entry_points_gles_1_0_autogen.h"
884#include "libGLESv2/entry_points_gles_2_0_autogen.h"
885#include "libGLESv2/entry_points_gles_3_0_autogen.h"
886#include "libGLESv2/entry_points_gles_3_1_autogen.h"
887#include "libGLESv2/entry_points_gles_ext_autogen.h"
888
889#include "common/event_tracer.h"
890"""
891
jchen1082af6202018-06-22 10:59:52 +0800892write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes, "\n".join([item for item in libgles_ep_exports]))