Commit 3bd10b19 by Jamie Madill Committed by Commit Bot

Capture/Replay: Return CallCapture from capture funcs.

This moves more shared code into a simple templated helper function. It will also allow us to call the parameter capture methods more easily for mid-execution capture. Refactoring change only. Bug: angleproject:3611 Change-Id: I8d95a6230922dfa0403ba5c328df78735c765519 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1688508 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 3fd0b2db
......@@ -214,11 +214,7 @@ template_capture_header = """// GENERATED FILE - DO NOT EDIT.
#define LIBANGLE_CAPTURE_GLES_{annotation}_AUTOGEN_H_
#include "common/PackedEnums.h"
namespace angle
{{
struct ParamCapture;
}} // namespace angle
#include "libANGLE/FrameCapture.h"
namespace gl
{{
......@@ -255,17 +251,13 @@ namespace gl
"""
template_capture_method = """
void Capture{short_name}({params_with_type})
CallCapture Capture{short_name}({params_with_type})
{{
FrameCapture *frameCapture = context->getFrameCapture();
if (!frameCapture->enabled())
return;
bool isCallValid = Validate{short_name}({params_just_name});
ParamBuffer paramBuffer;
{parameter_captures}
frameCapture->captureCall(context, "{full_name}", std::move(paramBuffer), isCallValid);
return CallCapture("gl{short_name}", std::move(paramBuffer));
}}
"""
......@@ -274,7 +266,7 @@ template_parameter_capture_value = """paramBuffer.addValueParam("{name}", ParamT
template_parameter_capture_pointer = """
ParamCapture {name}Param("{name}", ParamType::T{type});
InitParamValue(ParamType::T{type}, {name}, &{name}Param.value);
{capture_name}({params}, isCallValid, &{name}Param);
{capture_name}({params}, &{name}Param);
paramBuffer.addParam(std::move({name}Param));
"""
......@@ -368,7 +360,7 @@ template_event_comment = """// Don't run an EVENT() macro on the EXT_debug_marke
// It can interfere with the debug events being set by the caller.
// """
template_capture_proto = "void Capture%s(%s);"
template_capture_proto = "angle::CallCapture Capture%s(%s);"
template_validation_proto = "bool Validate%s(%s);"
......@@ -658,9 +650,11 @@ def format_capture_method(cmd_name, params, all_param_types, capture_pointer_fun
packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
params_with_type = get_internal_params(cmd_name, ["Context *context"] + params)
params_with_type = get_internal_params(cmd_name,
["const Context *context", "bool isCallValid"] + params)
params_just_name = ", ".join(
["context"] + [just_the_name_packed(param, packed_gl_enums) for param in params])
["context", "isCallValid"] +
[just_the_name_packed(param, packed_gl_enums) for param in params])
parameter_captures = []
for param in params:
......@@ -691,8 +685,7 @@ def format_capture_method(cmd_name, params, all_param_types, capture_pointer_fun
name=param_name, type=param_type, capture_name=capture_name, params=params)
capture_pointer_func = template_parameter_capture_pointer_func.format(
name=capture_name,
params=params_with_type + ", bool isCallValid, angle::ParamCapture *paramCapture")
name=capture_name, params=params_with_type + ", angle::ParamCapture *paramCapture")
capture_pointer_funcs += [capture_pointer_func]
else:
capture = template_parameter_capture_value.format(name=param_name, type=param_type)
......@@ -752,7 +745,8 @@ def format_validation_proto(cmd_name, params):
def format_capture_proto(cmd_name, params):
internal_params = get_internal_params(cmd_name, ["Context *context"] + params)
internal_params = get_internal_params(cmd_name,
["const Context *context", "bool isCallValid"] + params)
return template_capture_proto % (cmd_name[2:], internal_params)
......
......@@ -94,7 +94,7 @@
"GL/EGL entry points:scripts/entry_point_packed_gl_enums.json":
"08665ca9ebf22fa759c1ce0e965a200d",
"GL/EGL entry points:scripts/generate_entry_points.py":
"0abfd6fee44a1544e84009f95be055c1",
"e95e7253633f4f95eef28e9b07eaf458",
"GL/EGL entry points:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"GL/EGL entry points:scripts/gl_angle_ext.xml":
......@@ -134,25 +134,25 @@
"GL/EGL entry points:src/libANGLE/Context_gles_ext_autogen.h":
"a4159480e94e629b7ad5820464eab6ff",
"GL/EGL entry points:src/libANGLE/capture_gles_1_0_autogen.cpp":
"3336b58e58205e1e7451c1ade26583a2",
"4eed3706b615e2778f6d7840af8b9a15",
"GL/EGL entry points:src/libANGLE/capture_gles_1_0_autogen.h":
"7674cdeb5b841475cce5b1bb9682f2d6",
"06471d4526e8d0b824f5afc8bc8766fa",
"GL/EGL entry points:src/libANGLE/capture_gles_2_0_autogen.cpp":
"6338dd75f0a93981a6e31cf5f6f1231b",
"6cb02a611b7528f2184a44d1d5c75838",
"GL/EGL entry points:src/libANGLE/capture_gles_2_0_autogen.h":
"5a85f0995ed7f4e047fbe2327cbba88a",
"1ea9fbd64218b6e256e10723eb81e0c6",
"GL/EGL entry points:src/libANGLE/capture_gles_3_0_autogen.cpp":
"c7a886ac7236032b7ef99646cc1786cd",
"c97230a331a8d47499ba16a8daaa4caf",
"GL/EGL entry points:src/libANGLE/capture_gles_3_0_autogen.h":
"803899fe6b16225760b137ce207ba249",
"ffe4ed9b7e642258b9deb1452875f23b",
"GL/EGL entry points:src/libANGLE/capture_gles_3_1_autogen.cpp":
"abf5a08db8db0e6014405ad1827a074c",
"913f953f661b4e4701ed27c5c89f8f23",
"GL/EGL entry points:src/libANGLE/capture_gles_3_1_autogen.h":
"3a64c9682c3642fc281dc7a9680d4bcc",
"1be96fed22157c3f591ab362d717de0b",
"GL/EGL entry points:src/libANGLE/capture_gles_ext_autogen.cpp":
"455bc4147c1ef7defd93385fe9433f7e",
"26d5ccfe479071119b6ae1fc1382faa0",
"GL/EGL entry points:src/libANGLE/capture_gles_ext_autogen.h":
"ff0d811bf4a8a78521077126538cb9c4",
"2c282627320d2ca594e176ff0d84c8f1",
"GL/EGL entry points:src/libANGLE/entry_points_enum_autogen.h":
"0679308533029fdbc9f9844a5760586b",
"GL/EGL entry points:src/libANGLE/frame_capture_utils_autogen.cpp":
......
......@@ -7363,7 +7363,7 @@ void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat,
UNIMPLEMENTED();
}
bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams)
bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) const
{
// Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation
// is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due
......@@ -8106,7 +8106,9 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
return false;
}
bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams)
bool Context::getIndexedQueryParameterInfo(GLenum target,
GLenum *type,
unsigned int *numParams) const
{
if (getClientVersion() < Version(3, 0))
{
......
......@@ -473,8 +473,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
bool isGLES1() const;
// Specific methods needed for validation.
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) const;
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) const;
ANGLE_INLINE Program *getProgramResolveLink(GLuint handle) const
{
......
......@@ -141,17 +141,14 @@ FrameCapture::FrameCapture() : mFrameIndex(0), mReadBufferSize(0)
FrameCapture::~FrameCapture() = default;
void FrameCapture::captureCall(const gl::Context *context,
const char *callName,
ParamBuffer &&paramBuffer,
bool isCallValid)
void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
{
if (strcmp(callName, "glVertexAttribPointer") == 0)
if (call.name == "glVertexAttribPointer")
{
// Get array location
GLuint index = paramBuffer.getParam("index", ParamType::TGLuint, 0).value.GLuintVal;
GLuint index = call.params.getParam("index", ParamType::TGLuint, 0).value.GLuintVal;
if (paramBuffer.hasClientArrayData())
if (call.params.hasClientArrayData())
{
mClientVertexArrayMap[index] = mCalls.size();
}
......@@ -160,26 +157,26 @@ void FrameCapture::captureCall(const gl::Context *context,
mClientVertexArrayMap[index] = -1;
}
}
else if (strcmp(callName, "glDrawArrays") == 0)
else if (call.name == "glDrawArrays")
{
if (context->getStateCache().hasAnyActiveClientAttrib())
{
// Get counts from paramBuffer.
GLint startVertex = paramBuffer.getParam("start", ParamType::TGLint, 1).value.GLintVal;
GLint startVertex = call.params.getParam("start", ParamType::TGLint, 1).value.GLintVal;
GLsizei drawCount =
paramBuffer.getParam("count", ParamType::TGLsizei, 2).value.GLsizeiVal;
call.params.getParam("count", ParamType::TGLsizei, 2).value.GLsizeiVal;
captureClientArraySnapshot(context, startVertex + drawCount, 1);
}
}
else if (strcmp(callName, "glDrawElements") == 0)
else if (call.name == "glDrawElements")
{
if (context->getStateCache().hasAnyActiveClientAttrib())
{
GLsizei count = paramBuffer.getParam("count", ParamType::TGLsizei, 1).value.GLsizeiVal;
GLsizei count = call.params.getParam("count", ParamType::TGLsizei, 1).value.GLsizeiVal;
gl::DrawElementsType drawElementsType =
paramBuffer.getParam("typePacked", ParamType::TDrawElementsType, 2)
call.params.getParam("typePacked", ParamType::TDrawElementsType, 2)
.value.DrawElementsTypeVal;
const void *indices = paramBuffer.getParam("indices", ParamType::TvoidConstPointer, 3)
const void *indices = call.params.getParam("indices", ParamType::TvoidConstPointer, 3)
.value.voidConstPointerVal;
gl::IndexRange indexRange;
......@@ -203,8 +200,8 @@ void FrameCapture::captureCall(const gl::Context *context,
}
}
mReadBufferSize = std::max(mReadBufferSize, paramBuffer.getReadBufferSize());
mCalls.emplace_back(callName, std::move(paramBuffer));
mReadBufferSize = std::max(mReadBufferSize, call.params.getReadBufferSize());
mCalls.emplace_back(std::move(call));
}
void FrameCapture::captureClientArraySnapshot(const gl::Context *context,
......
......@@ -11,16 +11,12 @@
#define LIBANGLE_FRAME_CAPTURE_H_
#include "common/PackedEnums.h"
#include "libANGLE/Context.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/frame_capture_utils_autogen.h"
#include <tuple>
namespace gl
{
class Context;
} // namespace gl
namespace angle
{
struct ParamCapture : angle::NonCopyable
......@@ -85,11 +81,7 @@ class FrameCapture final : angle::NonCopyable
FrameCapture();
~FrameCapture();
void captureCall(const gl::Context *context,
const char *callName,
ParamBuffer &&paramBuffer,
bool isCallValid);
void captureCall(const gl::Context *context, CallCapture &&call);
void onEndFrame();
bool enabled() const;
......@@ -118,6 +110,22 @@ class FrameCapture final : angle::NonCopyable
size_t mReadBufferSize;
};
template <typename CaptureFuncT, typename ValidationFuncT, typename... ArgsT>
void CaptureCallToFrameCapture(const char *entryPointName,
CaptureFuncT captureFunc,
ValidationFuncT validationFunc,
gl::Context *context,
ArgsT... captureParams)
{
FrameCapture *frameCapture = context->getFrameCapture();
if (!frameCapture->enabled())
return;
bool isCallValid = validationFunc(context, captureParams...);
CallCapture call = captureFunc(context, isCallValid, captureParams...);
frameCapture->captureCall(context, std::move(call));
}
template <typename T>
void ParamBuffer::addValueParam(const char *paramName, ParamType paramType, T paramValue)
{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -83,7 +83,9 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
}
#if ANGLE_CAPTURE_ENABLED
# define ANGLE_CAPTURE(Func, ...) Capture##Func(__VA_ARGS__)
# define ANGLE_CAPTURE(Func, ...) \
CaptureCallToFrameCapture("gl" ANGLE_STRINGIFY(Func), Capture##Func, Validate##Func, \
__VA_ARGS__)
#else
# define ANGLE_CAPTURE(...)
#endif // ANGLE_CAPTURE_ENABLED
......
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