Commit b8c0dc04 by Jamie Madill Committed by Commit Bot

Capture/Replay: Capture entry point enum when possible.

This should save on a few string comparisons. This CL also adds a helper function that converts from an entry point enum ID to a string entry point name. Bug: angleproject:3611 Change-Id: I47434235ca25203ef1d6814897d81afab444a7fd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1719065 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c13ca2af
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts/entry_point_packed_gl_enums.json": "scripts/entry_point_packed_gl_enums.json":
"e5282bdef690f0ec652fed0e0723d1e8", "e5282bdef690f0ec652fed0e0723d1e8",
"scripts/generate_entry_points.py": "scripts/generate_entry_points.py":
"9259c99a07d446b5a9b91989f8f02d37", "72873c3806e749bf593bea823918e520",
"scripts/gl.xml": "scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708", "b470cb06b06cbbe7adb2c8129ec85708",
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
...@@ -64,27 +64,29 @@ ...@@ -64,27 +64,29 @@
"src/libANGLE/Context_gles_ext_autogen.h": "src/libANGLE/Context_gles_ext_autogen.h":
"d924200ebeb9fd0fae9effbc8489d3e1", "d924200ebeb9fd0fae9effbc8489d3e1",
"src/libANGLE/capture_gles_1_0_autogen.cpp": "src/libANGLE/capture_gles_1_0_autogen.cpp":
"4eed3706b615e2778f6d7840af8b9a15", "bc6dbb7355d76c9ffff0d424b5ca9036",
"src/libANGLE/capture_gles_1_0_autogen.h": "src/libANGLE/capture_gles_1_0_autogen.h":
"06471d4526e8d0b824f5afc8bc8766fa", "06471d4526e8d0b824f5afc8bc8766fa",
"src/libANGLE/capture_gles_2_0_autogen.cpp": "src/libANGLE/capture_gles_2_0_autogen.cpp":
"0669611cd6c795864c5f2b36710aa223", "a7ccc51733f4c608ae79e30195ebe70f",
"src/libANGLE/capture_gles_2_0_autogen.h": "src/libANGLE/capture_gles_2_0_autogen.h":
"9876493671f3051054cb10524330c8b1", "9876493671f3051054cb10524330c8b1",
"src/libANGLE/capture_gles_3_0_autogen.cpp": "src/libANGLE/capture_gles_3_0_autogen.cpp":
"42683a08ccbf8ef84727b40480a45421", "1af4126b8eac91fd7401caa9bf4e9a7c",
"src/libANGLE/capture_gles_3_0_autogen.h": "src/libANGLE/capture_gles_3_0_autogen.h":
"3b17c1843763678272281e1f2a59e254", "3b17c1843763678272281e1f2a59e254",
"src/libANGLE/capture_gles_3_1_autogen.cpp": "src/libANGLE/capture_gles_3_1_autogen.cpp":
"4d05155fff1c3e31a1580eb1ef022e6d", "405717bc0d7a9c815fd81e119e69d219",
"src/libANGLE/capture_gles_3_1_autogen.h": "src/libANGLE/capture_gles_3_1_autogen.h":
"7f3ff3ade9045bae39ed372e0350454c", "7f3ff3ade9045bae39ed372e0350454c",
"src/libANGLE/capture_gles_ext_autogen.cpp": "src/libANGLE/capture_gles_ext_autogen.cpp":
"90b5ef88fbd3c7be9b9b27485f165049", "52f20a5a311c646510d31e6aa77b03cd",
"src/libANGLE/capture_gles_ext_autogen.h": "src/libANGLE/capture_gles_ext_autogen.h":
"2f2cfa1ee077c3b535138547db57e1af", "2f2cfa1ee077c3b535138547db57e1af",
"src/libANGLE/entry_points_enum_autogen.cpp":
"b63b359a41a524c4ec3cb4e468bc2775",
"src/libANGLE/entry_points_enum_autogen.h": "src/libANGLE/entry_points_enum_autogen.h":
"b98241dd6ce96934cc1d6f8edc0725e1", "909cf5a69dcfd6131a45fa26e6abff47",
"src/libANGLE/frame_capture_utils_autogen.cpp": "src/libANGLE/frame_capture_utils_autogen.cpp":
"ec6ca9dee86e07a0421721f2bab4fb0b", "ec6ca9dee86e07a0421721f2bab4fb0b",
"src/libANGLE/frame_capture_utils_autogen.h": "src/libANGLE/frame_capture_utils_autogen.h":
......
...@@ -93,10 +93,44 @@ enum class EntryPoint ...@@ -93,10 +93,44 @@ enum class EntryPoint
{{ {{
{entry_points_list} {entry_points_list}
}}; }};
const char *GetEntryPointName(EntryPoint ep);
}} // namespace gl }} // namespace gl
#endif // LIBANGLE_ENTRY_POINTS_ENUM_AUTOGEN_H_ #endif // LIBANGLE_ENTRY_POINTS_ENUM_AUTOGEN_H_
""" """
template_entry_points_name_case = """ case EntryPoint::{enum}:
return "gl{enum}";"""
template_entry_points_enum_source = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright {year} The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_enum_autogen.cpp:
// Helper methods for the {lib} entry points enumeration.
#include "libANGLE/entry_points_enum_autogen.h"
#include "common/debug.h"
namespace gl
{{
const char *GetEntryPointName(EntryPoint ep)
{{
switch (ep)
{{
{entry_points_name_cases}
default:
UNREACHABLE();
return "error";
}}
}}
}} // 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}. // Generated by {script_name} using data from {data_source_name}.
// //
...@@ -289,7 +323,7 @@ CallCapture Capture{short_name}({params_with_type}, {return_value_type_original} ...@@ -289,7 +323,7 @@ CallCapture Capture{short_name}({params_with_type}, {return_value_type_original}
InitParamValue(ParamType::T{return_value_type_custom}, returnValue, &returnValueCapture.value); InitParamValue(ParamType::T{return_value_type_custom}, returnValue, &returnValueCapture.value);
paramBuffer.addReturnValue(std::move(returnValueCapture)); paramBuffer.addReturnValue(std::move(returnValueCapture));
return CallCapture("gl{short_name}", std::move(paramBuffer)); return CallCapture(gl::EntryPoint::{short_name}, std::move(paramBuffer));
}} }}
""" """
...@@ -300,7 +334,7 @@ CallCapture Capture{short_name}({params_with_type}) ...@@ -300,7 +334,7 @@ CallCapture Capture{short_name}({params_with_type})
{parameter_captures} {parameter_captures}
return CallCapture("gl{short_name}", std::move(paramBuffer)); return CallCapture(gl::EntryPoint::{short_name}, std::move(paramBuffer));
}} }}
""" """
...@@ -1279,6 +1313,7 @@ def main(): ...@@ -1279,6 +1313,7 @@ def main():
'../src/libANGLE/capture_gles_ext_autogen.h', '../src/libANGLE/capture_gles_ext_autogen.h',
'../src/libANGLE/frame_capture_utils_autogen.cpp', '../src/libANGLE/frame_capture_utils_autogen.cpp',
'../src/libANGLE/frame_capture_utils_autogen.h', '../src/libANGLE/frame_capture_utils_autogen.h',
'../src/libANGLE/entry_points_enum_autogen.cpp',
'../src/libANGLE/entry_points_enum_autogen.h', '../src/libANGLE/entry_points_enum_autogen.h',
'../src/libANGLE/validationES1_autogen.h', '../src/libANGLE/validationES1_autogen.h',
'../src/libANGLE/validationES2_autogen.h', '../src/libANGLE/validationES2_autogen.h',
...@@ -1699,7 +1734,7 @@ def main(): ...@@ -1699,7 +1734,7 @@ def main():
cmd_names.extend([cmd for cmd in gl_cmd_names if cmd not in cmd_names]) cmd_names.extend([cmd for cmd in gl_cmd_names if cmd not in cmd_names])
sorted_cmd_names = sorted(cmd_names) sorted_cmd_names = sorted(cmd_names)
entry_points_enum = template_entry_points_enum_header.format( entry_points_enum_header = 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 and gl_angle_ext.xml", data_source_name="gl.xml and gl_angle_ext.xml",
year=date.today().year, year=date.today().year,
...@@ -1708,7 +1743,22 @@ def main(): ...@@ -1708,7 +1743,22 @@ def main():
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(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_header)
out.close()
entry_points_cases = [
template_entry_points_name_case.format(enum=cmd) for cmd in sorted_cmd_names
]
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",
year=date.today().year,
lib="GL/GLES",
entry_points_name_cases="\n".join(entry_points_cases))
entry_points_enum_source_path = path_to("libANGLE", "entry_points_enum_autogen.cpp")
with open(entry_points_enum_source_path, "w") as out:
out.write(entry_points_enum_source)
out.close() out.close()
source_includes = """ source_includes = """
......
...@@ -40,7 +40,7 @@ void WriteParamStaticVarName(const CallCapture &call, ...@@ -40,7 +40,7 @@ void WriteParamStaticVarName(const CallCapture &call,
int counter, int counter,
std::ostream &out) std::ostream &out)
{ {
out << call.name << "_" << param.name << "_" << counter; out << call.name() << "_" << param.name << "_" << counter;
} }
template <typename T, typename CastT = T> template <typename T, typename CastT = T>
...@@ -130,8 +130,14 @@ ParamCapture &ParamBuffer::getClientArrayPointerParameter() ...@@ -130,8 +130,14 @@ ParamCapture &ParamBuffer::getClientArrayPointerParameter()
return mParamCaptures[mClientArrayDataParam]; return mParamCaptures[mClientArrayDataParam];
} }
CallCapture::CallCapture(const char *nameIn, ParamBuffer &&paramsIn) CallCapture::CallCapture(gl::EntryPoint entryPointIn, ParamBuffer &&paramsIn)
: name(nameIn), params(std::move(paramsIn)) : entryPoint(entryPointIn), params(std::move(paramsIn))
{}
CallCapture::CallCapture(const std::string &customFunctionNameIn, ParamBuffer &&paramsIn)
: entryPoint(gl::EntryPoint::Invalid),
customFunctionName(customFunctionNameIn),
params(std::move(paramsIn))
{} {}
CallCapture::~CallCapture() = default; CallCapture::~CallCapture() = default;
...@@ -143,11 +149,23 @@ CallCapture::CallCapture(CallCapture &&other) ...@@ -143,11 +149,23 @@ CallCapture::CallCapture(CallCapture &&other)
CallCapture &CallCapture::operator=(CallCapture &&other) CallCapture &CallCapture::operator=(CallCapture &&other)
{ {
std::swap(name, other.name); std::swap(entryPoint, other.entryPoint);
std::swap(customFunctionName, other.customFunctionName);
std::swap(params, other.params); std::swap(params, other.params);
return *this; return *this;
} }
const char *CallCapture::name() const
{
if (entryPoint == gl::EntryPoint::Invalid)
{
ASSERT(!customFunctionName.empty());
return customFunctionName.c_str();
}
return gl::GetEntryPointName(entryPoint);
}
FrameCapture::FrameCapture() : mFrameIndex(0), mReadBufferSize(0) FrameCapture::FrameCapture() : mFrameIndex(0), mReadBufferSize(0)
{ {
reset(); reset();
...@@ -157,7 +175,7 @@ FrameCapture::~FrameCapture() = default; ...@@ -157,7 +175,7 @@ FrameCapture::~FrameCapture() = default;
void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call) void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
{ {
if (call.name == "glVertexAttribPointer") if (call.entryPoint == gl::EntryPoint::VertexAttribPointer)
{ {
// Get array location // Get array location
GLuint index = call.params.getParam("index", ParamType::TGLuint, 0).value.GLuintVal; GLuint index = call.params.getParam("index", ParamType::TGLuint, 0).value.GLuintVal;
...@@ -171,7 +189,7 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call) ...@@ -171,7 +189,7 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
mClientVertexArrayMap[index] = -1; mClientVertexArrayMap[index] = -1;
} }
} }
else if (call.name == "glDrawArrays") else if (call.entryPoint == gl::EntryPoint::DrawArrays)
{ {
if (context->getStateCache().hasAnyActiveClientAttrib()) if (context->getStateCache().hasAnyActiveClientAttrib())
{ {
...@@ -182,7 +200,7 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call) ...@@ -182,7 +200,7 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
captureClientArraySnapshot(context, firstVertex + drawCount, 1); captureClientArraySnapshot(context, firstVertex + drawCount, 1);
} }
} }
else if (call.name == "glDrawElements") else if (call.entryPoint == gl::EntryPoint::DrawElements)
{ {
if (context->getStateCache().hasAnyActiveClientAttrib()) if (context->getStateCache().hasAnyActiveClientAttrib())
{ {
...@@ -378,9 +396,9 @@ void FrameCapture::saveCapturedFrameAsCpp() ...@@ -378,9 +396,9 @@ void FrameCapture::saveCapturedFrameAsCpp()
printf("Saved '%s'.\n", fname.c_str()); printf("Saved '%s'.\n", fname.c_str());
} }
int FrameCapture::getAndIncrementCounter(const std::string &callName, const std::string &paramName) int FrameCapture::getAndIncrementCounter(gl::EntryPoint entryPoint, const std::string &paramName)
{ {
auto counterKey = std::tie(callName, paramName); auto counterKey = std::tie(entryPoint, paramName);
return mDataCounters[counterKey]++; return mDataCounters[counterKey]++;
} }
...@@ -389,7 +407,7 @@ void FrameCapture::writeCallReplay(const CallCapture &call, ...@@ -389,7 +407,7 @@ void FrameCapture::writeCallReplay(const CallCapture &call,
std::ostream &header, std::ostream &header,
std::vector<uint8_t> *binaryData) std::vector<uint8_t> *binaryData)
{ {
out << call.name << "("; out << call.name() << "(";
bool first = true; bool first = true;
for (const ParamCapture &param : call.params.getParamCaptures()) for (const ParamCapture &param : call.params.getParamCaptures())
...@@ -421,7 +439,7 @@ void FrameCapture::writeCallReplay(const CallCapture &call, ...@@ -421,7 +439,7 @@ void FrameCapture::writeCallReplay(const CallCapture &call,
} }
else if (param.type == ParamType::TGLcharConstPointerPointer) else if (param.type == ParamType::TGLcharConstPointerPointer)
{ {
int counter = getAndIncrementCounter(call.name, param.name); int counter = getAndIncrementCounter(call.entryPoint, param.name);
header << "const char *"; header << "const char *";
WriteParamStaticVarName(call, param, counter, header); WriteParamStaticVarName(call, param, counter, header);
...@@ -438,7 +456,7 @@ void FrameCapture::writeCallReplay(const CallCapture &call, ...@@ -438,7 +456,7 @@ void FrameCapture::writeCallReplay(const CallCapture &call,
} }
else else
{ {
int counter = getAndIncrementCounter(call.name, param.name); int counter = getAndIncrementCounter(call.entryPoint, param.name);
ASSERT(param.data.size() == 1); ASSERT(param.data.size() == 1);
const std::vector<uint8_t> &data = param.data[0]; const std::vector<uint8_t> &data = param.data[0];
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "common/PackedEnums.h" #include "common/PackedEnums.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/entry_points_utils.h"
#include "libANGLE/frame_capture_utils_autogen.h" #include "libANGLE/frame_capture_utils_autogen.h"
#include <tuple> #include <tuple>
...@@ -67,13 +68,17 @@ class ParamBuffer final : angle::NonCopyable ...@@ -67,13 +68,17 @@ class ParamBuffer final : angle::NonCopyable
struct CallCapture struct CallCapture
{ {
CallCapture(const char *nameIn, ParamBuffer &&paramsIn); CallCapture(gl::EntryPoint entryPointIn, ParamBuffer &&paramsIn);
CallCapture(const std::string &customFunctionNameIn, ParamBuffer &&paramsIn);
~CallCapture(); ~CallCapture();
CallCapture(CallCapture &&other); CallCapture(CallCapture &&other);
CallCapture &operator=(CallCapture &&other); CallCapture &operator=(CallCapture &&other);
std::string name; const char *name() const;
gl::EntryPoint entryPoint;
std::string customFunctionName;
ParamBuffer params; ParamBuffer params;
}; };
...@@ -89,7 +94,7 @@ class FrameCapture final : angle::NonCopyable ...@@ -89,7 +94,7 @@ class FrameCapture final : angle::NonCopyable
private: private:
// <CallName, ParamName> // <CallName, ParamName>
using Counter = std::tuple<std::string, std::string>; using Counter = std::tuple<gl::EntryPoint, std::string>;
void captureClientArraySnapshot(const gl::Context *context, void captureClientArraySnapshot(const gl::Context *context,
size_t vertexCount, size_t vertexCount,
...@@ -100,7 +105,7 @@ class FrameCapture final : angle::NonCopyable ...@@ -100,7 +105,7 @@ class FrameCapture final : angle::NonCopyable
std::ostream &header, std::ostream &header,
std::vector<uint8_t> *binaryData); std::vector<uint8_t> *binaryData);
void reset(); void reset();
int getAndIncrementCounter(const std::string &callName, const std::string &paramName); int getAndIncrementCounter(gl::EntryPoint entryPoint, const std::string &paramName);
bool anyClientArray() const; bool anyClientArray() const;
void saveCapturedFrameAsCpp(); void saveCapturedFrameAsCpp();
...@@ -113,8 +118,7 @@ class FrameCapture final : angle::NonCopyable ...@@ -113,8 +118,7 @@ class FrameCapture final : angle::NonCopyable
}; };
template <typename CaptureFuncT, typename... ArgsT> template <typename CaptureFuncT, typename... ArgsT>
void CaptureCallToFrameCapture(const char *entryPointName, void CaptureCallToFrameCapture(CaptureFuncT captureFunc,
CaptureFuncT captureFunc,
bool isCallValid, bool isCallValid,
gl::Context *context, gl::Context *context,
ArgsT... captureParams) ArgsT... captureParams)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1362,5 +1362,7 @@ enum class EntryPoint ...@@ -1362,5 +1362,7 @@ enum class EntryPoint
WindowPos3s, WindowPos3s,
WindowPos3sv WindowPos3sv
}; };
const char *GetEntryPointName(EntryPoint ep);
} // namespace gl } // namespace gl
#endif // LIBANGLE_ENTRY_POINTS_ENUM_AUTOGEN_H_ #endif // LIBANGLE_ENTRY_POINTS_ENUM_AUTOGEN_H_
...@@ -83,8 +83,7 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue() ...@@ -83,8 +83,7 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
} }
#if ANGLE_CAPTURE_ENABLED #if ANGLE_CAPTURE_ENABLED
# define ANGLE_CAPTURE(Func, ...) \ # define ANGLE_CAPTURE(Func, ...) CaptureCallToFrameCapture(Capture##Func, __VA_ARGS__)
CaptureCallToFrameCapture("gl" ANGLE_STRINGIFY(Func), Capture##Func, __VA_ARGS__)
#else #else
# define ANGLE_CAPTURE(...) # define ANGLE_CAPTURE(...)
#endif // ANGLE_CAPTURE_ENABLED #endif // ANGLE_CAPTURE_ENABLED
......
...@@ -294,6 +294,9 @@ libangle_sources = [ ...@@ -294,6 +294,9 @@ libangle_sources = [
"src/libANGLE/angletypes.cpp", "src/libANGLE/angletypes.cpp",
"src/libANGLE/angletypes.h", "src/libANGLE/angletypes.h",
"src/libANGLE/angletypes.inc", "src/libANGLE/angletypes.inc",
"src/libANGLE/entry_points_enum_autogen.cpp",
"src/libANGLE/entry_points_enum_autogen.h",
"src/libANGLE/entry_points_utils.h",
"src/libANGLE/es3_copy_conversion_table_autogen.cpp", "src/libANGLE/es3_copy_conversion_table_autogen.cpp",
"src/libANGLE/features.h", "src/libANGLE/features.h",
"src/libANGLE/format_map_autogen.cpp", "src/libANGLE/format_map_autogen.cpp",
...@@ -1010,8 +1013,6 @@ libangle_null_sources = [ ...@@ -1010,8 +1013,6 @@ libangle_null_sources = [
libgl_sources = [ libgl_sources = [
"src/common/angleutils.h", "src/common/angleutils.h",
"src/common/debug.h", "src/common/debug.h",
"src/libANGLE/entry_points_enum_autogen.h",
"src/libANGLE/entry_points_utils.h",
"src/libGLESv2/global_state.cpp", "src/libGLESv2/global_state.cpp",
"src/libGLESv2/global_state.h", "src/libGLESv2/global_state.h",
"src/libGL/entry_points_gl_1_0_autogen.cpp", "src/libGL/entry_points_gl_1_0_autogen.cpp",
......
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