Commit 16daadba by Jamie Madill Committed by Commit Bot

GLES3: Auto-generate entry point header.

BUG=angleproject:1309 Change-Id: I40e3580c99df44338dfd1d06677e80fd0c57853e Reviewed-on: https://chromium-review.googlesource.com/636520Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 9696d073
...@@ -11,15 +11,6 @@ import sys, os, pprint ...@@ -11,15 +11,6 @@ import sys, os, pprint
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
from datetime import date 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. template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}. // Generated by {script_name} using data from {data_source_name}.
// //
...@@ -33,7 +24,7 @@ template_entry_point_header = """// GENERATED FILE - DO NOT EDIT. ...@@ -33,7 +24,7 @@ template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
#ifndef LIBGLESV2_ENTRYPOINTSGLES{major_version}{minor_version}_AUTOGEN_H_ #ifndef LIBGLESV2_ENTRYPOINTSGLES{major_version}{minor_version}_AUTOGEN_H_
#define 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> #include <export.h>
namespace gl namespace gl
...@@ -105,9 +96,23 @@ template_entry_point_def = """{return_type}GL_APIENTRY {name}({params}) ...@@ -105,9 +96,23 @@ template_entry_point_def = """{return_type}GL_APIENTRY {name}({params})
{default_return_if_needed}}} {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']") commands = root.find(".//commands[@namespace='GL']")
entry_point_decls_gles_2_0 = [] entry_point_decls_gles_2_0 = []
entry_point_defs_gles_2_0 = [] entry_point_defs_gles_2_0 = []
entry_point_decls_gles_3_0 = []
entry_point_defs_gles_3_0 = []
cmd_names = [] cmd_names = []
def format_entry_point_decl(cmd_name, proto, params): def format_entry_point_decl(cmd_name, proto, params):
...@@ -136,14 +141,20 @@ format_dict = { ...@@ -136,14 +141,20 @@ format_dict = {
"GLintptr": "%d", "GLintptr": "%d",
"GLsizei": "%d", "GLsizei": "%d",
"GLsizeiptr": "%d", "GLsizeiptr": "%d",
"GLuint": "%d" "GLsync": "0x%0.8p",
"GLuint": "%d",
"GLuint64": "%llu"
} }
def param_format_string(param): def param_format_string(param):
if "*" in param: if "*" in param:
return param + " = 0x%0.8p" return param + " = 0x%0.8p"
else: 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): def default_return_value(return_type):
if return_type == "void": if return_type == "void":
...@@ -152,10 +163,10 @@ def default_return_value(return_type): ...@@ -152,10 +163,10 @@ def default_return_value(return_type):
return "0" return "0"
elif return_type == "GLboolean": elif return_type == "GLboolean":
return "GL_FALSE" return "GL_FALSE"
elif "*" in return_type: elif "*" in return_type or return_type == "GLsync":
return "nullptr" return "nullptr"
else: else:
print(return_type) raise Exception("Don't know default return type for " + return_type)
def get_context_getter_function(cmd_name): def get_context_getter_function(cmd_name):
if cmd_name == "glGetError": if cmd_name == "glGetError":
...@@ -190,6 +201,15 @@ for cmd_name in gles2_commands: ...@@ -190,6 +201,15 @@ for cmd_name in gles2_commands:
entry_point_decls_gles_2_0 += [format_entry_point_decl(cmd_name, proto, params)] 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)] 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( gles_2_0_header = template_entry_point_header.format(
script_name = os.path.basename(sys.argv[0]), script_name = os.path.basename(sys.argv[0]),
data_source_name = "gl.xml", data_source_name = "gl.xml",
...@@ -206,8 +226,16 @@ gles_2_0_source = template_entry_point_source.format( ...@@ -206,8 +226,16 @@ gles_2_0_source = template_entry_point_source.format(
minor_version = 0, minor_version = 0,
entry_points = "\n".join(entry_point_defs_gles_2_0)) entry_points = "\n".join(entry_point_defs_gles_2_0))
# TODO(jmadill): Remove manually added entry points. gles_3_0_header = template_entry_point_header.format(
manual_cmd_names = ["Invalid"] + [cmd[2:] for cmd in cmd_names] + ["DrawElementsInstanced", "DrawRangeElements", "DrawElementsInstancedANGLE"] 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( entry_points_enum = template_entry_points_enum_header.format(
script_name = os.path.basename(sys.argv[0]), script_name = os.path.basename(sys.argv[0]),
data_source_name = "gl.xml", data_source_name = "gl.xml",
...@@ -219,6 +247,8 @@ def path_to(folder, file): ...@@ -219,6 +247,8 @@ def path_to(folder, file):
gles_2_0_header_path = path_to("libGLESv2", "entry_points_gles_2_0_autogen.h") 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_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") entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h")
with open(gles_2_0_header_path, "w") as out: with open(gles_2_0_header_path, "w") as out:
...@@ -229,6 +259,10 @@ with open(gles_2_0_source_path, "w") as out: ...@@ -229,6 +259,10 @@ with open(gles_2_0_source_path, "w") as out:
out.write(gles_2_0_source) out.write(gles_2_0_source)
out.close() 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: with open(entry_points_enum_header_path, "w") as out:
out.write(entry_points_enum) out.write(entry_points_enum)
out.close() out.close()
...@@ -158,8 +158,110 @@ enum class EntryPoint ...@@ -158,8 +158,110 @@ enum class EntryPoint
VertexAttrib4fv, VertexAttrib4fv,
VertexAttribPointer, VertexAttribPointer,
Viewport, Viewport,
DrawElementsInstanced, ReadBuffer,
DrawRangeElements, DrawRangeElements,
TexImage3D,
TexSubImage3D,
CopyTexSubImage3D,
CompressedTexImage3D,
CompressedTexSubImage3D,
GenQueries,
DeleteQueries,
IsQuery,
BeginQuery,
EndQuery,
GetQueryiv,
GetQueryObjectuiv,
UnmapBuffer,
GetBufferPointerv,
DrawBuffers,
UniformMatrix2x3fv,
UniformMatrix3x2fv,
UniformMatrix2x4fv,
UniformMatrix4x2fv,
UniformMatrix3x4fv,
UniformMatrix4x3fv,
BlitFramebuffer,
RenderbufferStorageMultisample,
FramebufferTextureLayer,
MapBufferRange,
FlushMappedBufferRange,
BindVertexArray,
DeleteVertexArrays,
GenVertexArrays,
IsVertexArray,
GetIntegeri_v,
BeginTransformFeedback,
EndTransformFeedback,
BindBufferRange,
BindBufferBase,
TransformFeedbackVaryings,
GetTransformFeedbackVarying,
VertexAttribIPointer,
GetVertexAttribIiv,
GetVertexAttribIuiv,
VertexAttribI4i,
VertexAttribI4ui,
VertexAttribI4iv,
VertexAttribI4uiv,
GetUniformuiv,
GetFragDataLocation,
Uniform1ui,
Uniform2ui,
Uniform3ui,
Uniform4ui,
Uniform1uiv,
Uniform2uiv,
Uniform3uiv,
Uniform4uiv,
ClearBufferiv,
ClearBufferuiv,
ClearBufferfv,
ClearBufferfi,
GetStringi,
CopyBufferSubData,
GetUniformIndices,
GetActiveUniformsiv,
GetUniformBlockIndex,
GetActiveUniformBlockiv,
GetActiveUniformBlockName,
UniformBlockBinding,
DrawArraysInstanced,
DrawElementsInstanced,
FenceSync,
IsSync,
DeleteSync,
ClientWaitSync,
WaitSync,
GetInteger64v,
GetSynciv,
GetInteger64i_v,
GetBufferParameteri64v,
GenSamplers,
DeleteSamplers,
IsSampler,
BindSampler,
SamplerParameteri,
SamplerParameteriv,
SamplerParameterf,
SamplerParameterfv,
GetSamplerParameteriv,
GetSamplerParameterfv,
VertexAttribDivisor,
BindTransformFeedback,
DeleteTransformFeedbacks,
GenTransformFeedbacks,
IsTransformFeedback,
PauseTransformFeedback,
ResumeTransformFeedback,
GetProgramBinary,
ProgramBinary,
ProgramParameteri,
InvalidateFramebuffer,
InvalidateSubFramebuffer,
TexStorage2D,
TexStorage3D,
GetInternalformativ,
DrawElementsInstancedANGLE DrawElementsInstancedANGLE
}; };
} // namespace gl } // namespace gl
......
...@@ -799,7 +799,7 @@ ...@@ -799,7 +799,7 @@
'libGLESv2/entry_points_gles_2_0_ext.cpp', 'libGLESv2/entry_points_gles_2_0_ext.cpp',
'libGLESv2/entry_points_gles_2_0_ext.h', 'libGLESv2/entry_points_gles_2_0_ext.h',
'libGLESv2/entry_points_gles_3_0.cpp', 'libGLESv2/entry_points_gles_3_0.cpp',
'libGLESv2/entry_points_gles_3_0.h', 'libGLESv2/entry_points_gles_3_0_autogen.h',
'libGLESv2/entry_points_gles_3_1.cpp', 'libGLESv2/entry_points_gles_3_1.cpp',
'libGLESv2/entry_points_gles_3_1.h', 'libGLESv2/entry_points_gles_3_1.h',
'libGLESv2/global_state.cpp', 'libGLESv2/global_state.cpp',
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "libGLESv2/entry_points_egl_ext.h" #include "libGLESv2/entry_points_egl_ext.h"
#include "libGLESv2/entry_points_gles_2_0_autogen.h" #include "libGLESv2/entry_points_gles_2_0_autogen.h"
#include "libGLESv2/entry_points_gles_2_0_ext.h" #include "libGLESv2/entry_points_gles_2_0_ext.h"
#include "libGLESv2/entry_points_gles_3_0.h" #include "libGLESv2/entry_points_gles_3_0_autogen.h"
#include "libGLESv2/entry_points_gles_3_1.h" #include "libGLESv2/entry_points_gles_3_1.h"
#include "libGLESv2/global_state.h" #include "libGLESv2/global_state.h"
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
// entry_points_gles_3_0.cpp : Implements the GLES 3.0 entry points. // entry_points_gles_3_0.cpp : Implements the GLES 3.0 entry points.
#include "libGLESv2/entry_points_gles_3_0.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/validationES3.h" #include "libANGLE/validationES3.h"
#include "libGLESv2/global_state.h" #include "libGLESv2/global_state.h"
......
// GENERATED FILE - DO NOT EDIT.
// Generated by generate_entry_points.py using data from gl.xml.
// //
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved. // Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// entry_points_gles_3_0_autogen.h:
// Defines the GLES 3.0 entry points.
// entry_points_gles_3_0.h : Defines the GLES 3.0 entry points. #ifndef LIBGLESV2_ENTRYPOINTSGLES30_AUTOGEN_H_
#define LIBGLESV2_ENTRYPOINTSGLES30_AUTOGEN_H_
#ifndef LIBGLESV2_ENTRYPOINTGLES30_H_
#define LIBGLESV2_ENTRYPOINTGLES30_H_
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#include <export.h> #include <export.h>
namespace gl namespace gl
{ {
ANGLE_EXPORT void GL_APIENTRY ReadBuffer(GLenum src);
ANGLE_EXPORT void GL_APIENTRY ReadBuffer(GLenum mode);
ANGLE_EXPORT void GL_APIENTRY DrawRangeElements(GLenum mode, ANGLE_EXPORT void GL_APIENTRY DrawRangeElements(GLenum mode,
GLuint start, GLuint start,
GLuint end, GLuint end,
...@@ -136,7 +137,7 @@ ANGLE_EXPORT void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint *arrays); ...@@ -136,7 +137,7 @@ ANGLE_EXPORT void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint *arrays);
ANGLE_EXPORT GLboolean GL_APIENTRY IsVertexArray(GLuint array); ANGLE_EXPORT GLboolean GL_APIENTRY IsVertexArray(GLuint array);
ANGLE_EXPORT void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint *data); ANGLE_EXPORT void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint *data);
ANGLE_EXPORT void GL_APIENTRY BeginTransformFeedback(GLenum primitiveMode); ANGLE_EXPORT void GL_APIENTRY BeginTransformFeedback(GLenum primitiveMode);
ANGLE_EXPORT void GL_APIENTRY EndTransformFeedback(void); ANGLE_EXPORT void GL_APIENTRY EndTransformFeedback();
ANGLE_EXPORT void GL_APIENTRY ANGLE_EXPORT void GL_APIENTRY
BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
ANGLE_EXPORT void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer); ANGLE_EXPORT void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer);
...@@ -210,18 +211,18 @@ ANGLE_EXPORT void GL_APIENTRY UniformBlockBinding(GLuint program, ...@@ -210,18 +211,18 @@ ANGLE_EXPORT void GL_APIENTRY UniformBlockBinding(GLuint program,
ANGLE_EXPORT void GL_APIENTRY DrawArraysInstanced(GLenum mode, ANGLE_EXPORT void GL_APIENTRY DrawArraysInstanced(GLenum mode,
GLint first, GLint first,
GLsizei count, GLsizei count,
GLsizei instanceCount); GLsizei instancecount);
ANGLE_EXPORT void GL_APIENTRY DrawElementsInstanced(GLenum mode, ANGLE_EXPORT void GL_APIENTRY DrawElementsInstanced(GLenum mode,
GLsizei count, GLsizei count,
GLenum type, GLenum type,
const void *indices, const void *indices,
GLsizei instanceCount); GLsizei instancecount);
ANGLE_EXPORT GLsync GL_APIENTRY FenceSync(GLenum condition, GLbitfield flags); ANGLE_EXPORT GLsync GL_APIENTRY FenceSync(GLenum condition, GLbitfield flags);
ANGLE_EXPORT GLboolean GL_APIENTRY IsSync(GLsync sync); ANGLE_EXPORT GLboolean GL_APIENTRY IsSync(GLsync sync);
ANGLE_EXPORT void GL_APIENTRY DeleteSync(GLsync sync); ANGLE_EXPORT void GL_APIENTRY DeleteSync(GLsync sync);
ANGLE_EXPORT GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); ANGLE_EXPORT GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
ANGLE_EXPORT void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); ANGLE_EXPORT void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
ANGLE_EXPORT void GL_APIENTRY GetInteger64v(GLenum pname, GLint64 *params); ANGLE_EXPORT void GL_APIENTRY GetInteger64v(GLenum pname, GLint64 *data);
ANGLE_EXPORT void GL_APIENTRY ANGLE_EXPORT void GL_APIENTRY
GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
ANGLE_EXPORT void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64 *data); ANGLE_EXPORT void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64 *data);
...@@ -243,8 +244,8 @@ ANGLE_EXPORT void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id); ...@@ -243,8 +244,8 @@ ANGLE_EXPORT void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id);
ANGLE_EXPORT void GL_APIENTRY DeleteTransformFeedbacks(GLsizei n, const GLuint *ids); ANGLE_EXPORT void GL_APIENTRY DeleteTransformFeedbacks(GLsizei n, const GLuint *ids);
ANGLE_EXPORT void GL_APIENTRY GenTransformFeedbacks(GLsizei n, GLuint *ids); ANGLE_EXPORT void GL_APIENTRY GenTransformFeedbacks(GLsizei n, GLuint *ids);
ANGLE_EXPORT GLboolean GL_APIENTRY IsTransformFeedback(GLuint id); ANGLE_EXPORT GLboolean GL_APIENTRY IsTransformFeedback(GLuint id);
ANGLE_EXPORT void GL_APIENTRY PauseTransformFeedback(void); ANGLE_EXPORT void GL_APIENTRY PauseTransformFeedback();
ANGLE_EXPORT void GL_APIENTRY ResumeTransformFeedback(void); ANGLE_EXPORT void GL_APIENTRY ResumeTransformFeedback();
ANGLE_EXPORT void GL_APIENTRY GetProgramBinary(GLuint program, ANGLE_EXPORT void GL_APIENTRY GetProgramBinary(GLuint program,
GLsizei bufSize, GLsizei bufSize,
GLsizei *length, GLsizei *length,
...@@ -278,6 +279,6 @@ ANGLE_EXPORT void GL_APIENTRY GetInternalformativ(GLenum target, ...@@ -278,6 +279,6 @@ ANGLE_EXPORT void GL_APIENTRY GetInternalformativ(GLenum target,
GLenum pname, GLenum pname,
GLsizei bufSize, GLsizei bufSize,
GLint *params); GLint *params);
} } // namespace gl
#endif // LIBGLESV2_ENTRYPOINTGLES30_H_ #endif // LIBGLESV2_ENTRYPOINTSGLES30_AUTOGEN_H_
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "libGLESv2/entry_points_gles_2_0_autogen.h" #include "libGLESv2/entry_points_gles_2_0_autogen.h"
#include "libGLESv2/entry_points_gles_2_0_ext.h" #include "libGLESv2/entry_points_gles_2_0_ext.h"
#include "libGLESv2/entry_points_gles_3_0.h" #include "libGLESv2/entry_points_gles_3_0_autogen.h"
#include "libGLESv2/entry_points_gles_3_1.h" #include "libGLESv2/entry_points_gles_3_1.h"
#include "common/event_tracer.h" #include "common/event_tracer.h"
......
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