GLES3: Auto-generate entry point header.
BUG=angleproject:1309
Change-Id: I40e3580c99df44338dfd1d06677e80fd0c57853e
Reviewed-on: https://chromium-review.googlesource.com/636520
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/scripts/generate_entry_points.py b/scripts/generate_entry_points.py
index 59fa775..5af3dd1 100644
--- a/scripts/generate_entry_points.py
+++ b/scripts/generate_entry_points.py
@@ -11,15 +11,6 @@
import xml.etree.ElementTree as etree
from datetime import date
-def script_relative(path):
- return os.path.join(os.path.dirname(sys.argv[0]), path)
-
-tree = etree.parse(script_relative('gl.xml'))
-root = tree.getroot()
-
-gles2_xpath = ".//feature[@name='GL_ES_VERSION_2_0']//command"
-gles2_commands = [cmd.attrib['name'] for cmd in root.findall(gles2_xpath)]
-
template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
@@ -33,7 +24,7 @@
#ifndef LIBGLESV2_ENTRYPOINTSGLES{major_version}{minor_version}_AUTOGEN_H_
#define LIBGLESV2_ENTRYPOINTSGLES{major_version}{minor_version}_AUTOGEN_H_
-#include <GLES2/gl{major_version}.h>
+#include <GLES{major_version}/gl{major_version}.h>
#include <export.h>
namespace gl
@@ -105,9 +96,23 @@
{default_return_if_needed}}}
"""
+def script_relative(path):
+ return os.path.join(os.path.dirname(sys.argv[0]), path)
+
+tree = etree.parse(script_relative('gl.xml'))
+root = tree.getroot()
+
+gles2_xpath = ".//feature[@name='GL_ES_VERSION_2_0']//command"
+gles2_commands = [cmd.attrib['name'] for cmd in root.findall(gles2_xpath)]
+
+gles3_xpath = ".//feature[@name='GL_ES_VERSION_3_0']//command"
+gles3_commands = [cmd.attrib['name'] for cmd in root.findall(gles3_xpath)]
+
commands = root.find(".//commands[@namespace='GL']")
entry_point_decls_gles_2_0 = []
entry_point_defs_gles_2_0 = []
+entry_point_decls_gles_3_0 = []
+entry_point_defs_gles_3_0 = []
cmd_names = []
def format_entry_point_decl(cmd_name, proto, params):
@@ -136,14 +141,20 @@
"GLintptr": "%d",
"GLsizei": "%d",
"GLsizeiptr": "%d",
- "GLuint": "%d"
+ "GLsync": "0x%0.8p",
+ "GLuint": "%d",
+ "GLuint64": "%llu"
}
def param_format_string(param):
if "*" in param:
return param + " = 0x%0.8p"
else:
- return param + " = " + format_dict[just_the_type(param)]
+ 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'")
+
+ return param + " = " + format_dict[type_only]
def default_return_value(return_type):
if return_type == "void":
@@ -152,10 +163,10 @@
return "0"
elif return_type == "GLboolean":
return "GL_FALSE"
- elif "*" in return_type:
+ elif "*" in return_type or return_type == "GLsync":
return "nullptr"
else:
- print(return_type)
+ raise Exception("Don't know default return type for " + return_type)
def get_context_getter_function(cmd_name):
if cmd_name == "glGetError":
@@ -190,6 +201,15 @@
entry_point_decls_gles_2_0 += [format_entry_point_decl(cmd_name, proto, params)]
entry_point_defs_gles_2_0 += [format_entry_point_def(cmd_name, proto, params)]
+for cmd_name in gles3_commands:
+ command_xpath = "command/proto[name='" + cmd_name + "']/.."
+ command = commands.find(command_xpath)
+ params = ["".join(param.itertext()) for param in command.findall("./param")]
+ proto = "".join(command.find("./proto").itertext())
+ cmd_names += [cmd_name]
+ entry_point_decls_gles_3_0 += [format_entry_point_decl(cmd_name, proto, params)]
+ entry_point_defs_gles_3_0 += [format_entry_point_def(cmd_name, proto, params)]
+
gles_2_0_header = template_entry_point_header.format(
script_name = os.path.basename(sys.argv[0]),
data_source_name = "gl.xml",
@@ -206,8 +226,16 @@
minor_version = 0,
entry_points = "\n".join(entry_point_defs_gles_2_0))
-# TODO(jmadill): Remove manually added entry points.
-manual_cmd_names = ["Invalid"] + [cmd[2:] for cmd in cmd_names] + ["DrawElementsInstanced", "DrawRangeElements", "DrawElementsInstancedANGLE"]
+gles_3_0_header = template_entry_point_header.format(
+ script_name = os.path.basename(sys.argv[0]),
+ data_source_name = "gl.xml",
+ year = date.today().year,
+ major_version = 3,
+ minor_version = 0,
+ entry_points = "\n".join(entry_point_decls_gles_3_0))
+
+# TODO(jmadill): Remove manually added entry points once we auto-gen them.
+manual_cmd_names = ["Invalid"] + [cmd[2:] for cmd in cmd_names] + ["DrawElementsInstancedANGLE"]
entry_points_enum = template_entry_points_enum_header.format(
script_name = os.path.basename(sys.argv[0]),
data_source_name = "gl.xml",
@@ -219,6 +247,8 @@
gles_2_0_header_path = path_to("libGLESv2", "entry_points_gles_2_0_autogen.h")
gles_2_0_source_path = path_to("libGLESv2", "entry_points_gles_2_0_autogen.cpp")
+gles_3_0_header_path = path_to("libGLESv2", "entry_points_gles_3_0_autogen.h")
+gles_3_0_source_path = path_to("libGLESv2", "entry_points_gles_3_0_autogen.cpp")
entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h")
with open(gles_2_0_header_path, "w") as out:
@@ -229,6 +259,10 @@
out.write(gles_2_0_source)
out.close()
+with open(gles_3_0_header_path, "w") as out:
+ out.write(gles_3_0_header)
+ out.close()
+
with open(entry_points_enum_header_path, "w") as out:
out.write(entry_points_enum)
out.close()