Commit 57ae8c16 by Jamie Madill Committed by Commit Bot

GLES3: Auto-generate entry points source.

Lots of incidental fixes to formatting and naming. Adds specific default return type overloads for ClientWaitSync and GetUniformBlockIndex. BUG=angleproject:1309 Change-Id: Id67cbc0b19fc2cb94c859ab8390f1ff36b1bbd25 Reviewed-on: https://chromium-review.googlesource.com/637203Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e8ef2bc4
...@@ -46,7 +46,7 @@ template_entry_point_source = """// GENERATED FILE - DO NOT EDIT. ...@@ -46,7 +46,7 @@ template_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
// Defines the GLES {major_version}.{minor_version} entry points. // Defines the GLES {major_version}.{minor_version} entry points.
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/validationES2.h" #include "libANGLE/validationES{major_version}.h"
#include "libGLESv2/global_state.h" #include "libGLESv2/global_state.h"
namespace gl namespace gl
...@@ -96,6 +96,23 @@ template_entry_point_def = """{return_type}GL_APIENTRY {name}({params}) ...@@ -96,6 +96,23 @@ template_entry_point_def = """{return_type}GL_APIENTRY {name}({params})
{default_return_if_needed}}} {default_return_if_needed}}}
""" """
template_entry_point_def_oldstyle = """{return_type}GL_APIENTRY {name}({params})
{{
EVENT("({format_params})"{comma_if_needed}{pass_params});
Context *context = {context_getter}();
if (context)
{{
if (!context->skipValidation() && !Validate{name}({validate_params}))
{{
return{default_value_if_needed};
}}
{return_if_needed}context->{name_lower}({pass_params});
}}
{default_return_if_needed}}}
"""
def script_relative(path): def script_relative(path):
return os.path.join(os.path.dirname(sys.argv[0]), path) return os.path.join(os.path.dirname(sys.argv[0]), path)
...@@ -185,6 +202,25 @@ def format_entry_point_def(cmd_name, proto, params): ...@@ -185,6 +202,25 @@ def format_entry_point_def(cmd_name, proto, params):
default_return_if_needed = "" if default_return == "" else "\n return " + default_return + ";\n", default_return_if_needed = "" if default_return == "" else "\n return " + default_return + ";\n",
context_getter = get_context_getter_function(cmd_name)) context_getter = get_context_getter_function(cmd_name))
def format_entry_point_def_oldstyle(cmd_name, proto, params):
pass_params = [just_the_name(param) for param in params]
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())
return template_entry_point_def_oldstyle.format(
name = cmd_name[2:],
name_lower = cmd_name[2:3].lower() + cmd_name[3:],
return_type = return_type,
params = ", ".join(params),
pass_params = ", ".join(pass_params),
comma_if_needed = ", " if len(params) > 0 else "",
validate_params = ", ".join(["context"] + pass_params),
format_params = ", ".join(format_params),
return_if_needed = "" if default_return == "" else "return ",
default_return_if_needed = "" if default_return == "" else "\n return " + default_return + ";\n",
default_value_if_needed = "" if default_return == "" else (" " + default_return),
context_getter = get_context_getter_function(cmd_name))
for cmd_name in gles2_commands: for cmd_name in gles2_commands:
command_xpath = "command/proto[name='" + cmd_name + "']/.." command_xpath = "command/proto[name='" + cmd_name + "']/.."
command = commands.find(command_xpath) command = commands.find(command_xpath)
...@@ -201,7 +237,7 @@ for cmd_name in gles3_commands: ...@@ -201,7 +237,7 @@ for cmd_name in gles3_commands:
proto = "".join(command.find("./proto").itertext()) proto = "".join(command.find("./proto").itertext())
cmd_names += [cmd_name] cmd_names += [cmd_name]
entry_point_decls_gles_3_0 += [format_entry_point_decl(cmd_name, proto, params)] 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)] entry_point_defs_gles_3_0 += [format_entry_point_def_oldstyle(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]),
...@@ -227,6 +263,14 @@ gles_3_0_header = template_entry_point_header.format( ...@@ -227,6 +263,14 @@ gles_3_0_header = template_entry_point_header.format(
minor_version = 0, minor_version = 0,
entry_points = "\n".join(entry_point_decls_gles_3_0)) entry_points = "\n".join(entry_point_decls_gles_3_0))
gles_3_0_source = template_entry_point_source.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_defs_gles_3_0))
# TODO(jmadill): Remove manually added entry points once we auto-gen them. # TODO(jmadill): Remove manually added entry points once we auto-gen them.
manual_cmd_names = ["Invalid"] + [cmd[2:] for cmd in cmd_names] + ["DrawElementsInstancedANGLE"] 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(
...@@ -256,6 +300,10 @@ with open(gles_3_0_header_path, "w") as out: ...@@ -256,6 +300,10 @@ with open(gles_3_0_header_path, "w") as out:
out.write(gles_3_0_header) out.write(gles_3_0_header)
out.close() out.close()
with open(gles_3_0_source_path, "w") as out:
out.write(gles_3_0_source)
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()
...@@ -191,13 +191,33 @@ struct DefaultReturnValue<EP, GLboolean> ...@@ -191,13 +191,33 @@ struct DefaultReturnValue<EP, GLboolean>
static constexpr GLboolean kValue = GL_FALSE; static constexpr GLboolean kValue = GL_FALSE;
}; };
// Catch-all rule for pointer types. // Catch-all rules for pointer types.
template <EntryPoint EP, typename PointerType> template <EntryPoint EP, typename PointerType>
struct DefaultReturnValue<EP, const PointerType *> struct DefaultReturnValue<EP, const PointerType *>
{ {
static constexpr const PointerType *kValue = nullptr; static constexpr const PointerType *kValue = nullptr;
}; };
template <EntryPoint EP, typename PointerType>
struct DefaultReturnValue<EP, PointerType *>
{
static constexpr PointerType *kValue = nullptr;
};
// Overloaded to return invalid index
template <>
struct DefaultReturnValue<EntryPoint::GetUniformBlockIndex, GLuint>
{
static constexpr GLuint kValue = GL_INVALID_INDEX;
};
// Specialized enum error value.
template <>
struct DefaultReturnValue<EntryPoint::ClientWaitSync, GLenum>
{
static constexpr GLenum kValue = GL_WAIT_FAILED;
};
template <EntryPoint EP, typename ReturnType> template <EntryPoint EP, typename ReturnType>
constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue() constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
{ {
......
...@@ -798,7 +798,7 @@ ...@@ -798,7 +798,7 @@
'libGLESv2/entry_points_gles_2_0_autogen.h', 'libGLESv2/entry_points_gles_2_0_autogen.h',
'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_autogen.cpp',
'libGLESv2/entry_points_gles_3_0_autogen.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',
......
...@@ -955,6 +955,14 @@ TEST_P(UniformBufferTest, BlockContainingNestedStructs) ...@@ -955,6 +955,14 @@ TEST_P(UniformBufferTest, BlockContainingNestedStructs)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// Tests GetUniformBlockIndex return value on error.
TEST_P(UniformBufferTest, GetUniformBlockIndexDefaultReturn)
{
ASSERT_FALSE(glIsProgram(99));
EXPECT_EQ(GL_INVALID_INDEX, glGetUniformBlockIndex(99, "farts"));
EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(UniformBufferTest, ANGLE_INSTANTIATE_TEST(UniformBufferTest,
ES3_D3D11(), ES3_D3D11(),
......
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