Commit 01dfe404 by Jamie Madill Committed by Commit Bot

Capture/Replay: Use resource ID maps in cpp replay.

Introduces a new enum for resource ID types. This is used in auto- generated code to convert ParamType to resource ID map types. Also implements a lot of new parameter captures for gen/delete calls. Bug: angleproject:3611 Change-Id: I26cca1df88d1783d9830c89438c99f7593a70ea9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1784059 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent db7a36f4
......@@ -6,7 +6,7 @@
"scripts/entry_point_packed_gl_enums.json":
"5550f249db54a698036d5d9aa65e043b",
"scripts/generate_entry_points.py":
"00dc8410ad87e122314ac58579445188",
"29fd14951357959ad8e562867c0b12f6",
"scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"scripts/gl_angle_ext.xml":
......@@ -90,9 +90,9 @@
"src/libANGLE/frame_capture_replay_autogen.cpp":
"1e4e55ea044ff8fc3764622a2f1cf240",
"src/libANGLE/frame_capture_utils_autogen.cpp":
"7465f826ea0196541bddd95540b0f599",
"f0a704d60de3f1f175a7799b49c45408",
"src/libANGLE/frame_capture_utils_autogen.h":
"4d16f676a1f5f70a882161fcb585db5b",
"cc6e5b6c49d51da1cebea6ea48422511",
"src/libANGLE/validationES1_autogen.h":
"8d3131d2bf2e6f521f46b44e64a6bff9",
"src/libANGLE/validationES2_autogen.h":
......
......@@ -522,6 +522,8 @@ enum class ParamType
{param_types}
}};
constexpr uint32_t kParamTypeCount = {param_type_count};
union ParamValue
{{
{param_union_values}
......@@ -532,7 +534,6 @@ T GetParamVal(const ParamValue &value);
{get_param_val_specializations}
template <ParamType PType, typename T>
T GetParamVal(const ParamValue &value)
{{
......@@ -571,6 +572,14 @@ void InitParamValue(ParamType paramType, T valueIn, ParamValue *valueOut)
void WriteParamTypeToStream(std::ostream &os, ParamType paramType, const ParamValue& paramValue);
const char *ParamTypeToString(ParamType paramType);
enum class ResourceIDType
{{
{resource_id_types}
}};
ResourceIDType GetResourceIDTypeFromParamType(ParamType paramType);
const char *GetResourceIDTypeName(ResourceIDType resourceIDType);
}} // namespace angle
#endif // LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_H_
......@@ -613,6 +622,27 @@ const char *ParamTypeToString(ParamType paramType)
return "unknown";
}}
}}
ResourceIDType GetResourceIDTypeFromParamType(ParamType paramType)
{{
switch (paramType)
{{
{param_type_resource_id_cases}
default:
return ResourceIDType::InvalidEnum;
}}
}}
const char *GetResourceIDTypeName(ResourceIDType resourceIDType)
{{
switch (resourceIDType)
{{
{resource_id_type_name_cases}
default:
UNREACHABLE();
return "GetResourceIDTypeName error";
}}
}}
}} // namespace angle
"""
......@@ -642,6 +672,12 @@ template_write_param_type_to_stream_case = """ case ParamType::T{enum}:
template_param_type_to_string_case = """ case ParamType::T{enum}:
return "{type}";"""
template_param_type_to_resource_id_type_case = """ case ParamType::T{enum}:
return ResourceIDType::{resource_id_type};"""
template_resource_id_type_name_case = """ case ResourceIDType::{resource_id_type}:
return "{resource_id_type}";"""
def script_relative(path):
return os.path.join(os.path.dirname(sys.argv[0]), path)
......@@ -1314,6 +1350,17 @@ def format_write_param_type_to_stream_case(param_type):
enum=param_type, union_name=get_param_type_union_name(param_type))
def get_resource_id_types(all_param_types):
return [t[:-2] for t in filter(lambda t: t.endswith("ID"), all_param_types)]
def format_resource_id_types(all_param_types):
resource_id_types = get_resource_id_types(all_param_types)
resource_id_types += ["EnumCount", "InvalidEnum = EnumCount"]
resource_id_types = ",\n ".join(resource_id_types)
return resource_id_types
def write_capture_helper_header(all_param_types):
param_types = "\n ".join(["T%s," % t for t in all_param_types])
......@@ -1325,17 +1372,20 @@ def write_capture_helper_header(all_param_types):
set_param_val_specializations = "\n\n".join(
[format_set_param_val_specialization(t) for t in all_param_types])
init_param_value_cases = "\n".join([format_init_param_value_case(t) for t in all_param_types])
resource_id_types = format_resource_id_types(all_param_types)
content = template_frame_capture_utils_header.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
year=date.today().year,
param_types=param_types,
param_type_count=len(all_param_types),
param_union_values=param_union_values,
get_param_val_specializations=get_param_val_specializations,
access_param_value_cases=access_param_value_cases,
set_param_val_specializations=set_param_val_specializations,
init_param_value_cases=init_param_value_cases)
init_param_value_cases=init_param_value_cases,
resource_id_types=resource_id_types)
path = path_to("libANGLE", "frame_capture_utils_autogen.h")
......@@ -1349,6 +1399,30 @@ def format_param_type_to_string_case(param_type):
enum=param_type, type=get_gl_param_type_type(param_type))
def get_resource_id_type_from_param_type(param_type):
if param_type.endswith("ConstPointer"):
return param_type.replace("ConstPointer", "")[:-2]
if param_type.endswith("Pointer"):
return param_type.replace("Pointer", "")[:-2]
return param_type[:-2]
def format_param_type_to_resource_id_type_case(param_type):
return template_param_type_to_resource_id_type_case.format(
enum=param_type, resource_id_type=get_resource_id_type_from_param_type(param_type))
def format_param_type_resource_id_cases(all_param_types):
id_types = filter(
lambda t: t.endswith("ID") or t.endswith("IDConstPointer") or t.endswith("IDPointer"),
all_param_types)
return "\n".join([format_param_type_to_resource_id_type_case(t) for t in id_types])
def format_resource_id_type_name_case(resource_id_type):
return template_resource_id_type_name_case.format(resource_id_type=resource_id_type)
def write_capture_helper_source(all_param_types):
write_param_type_to_stream_cases = "\n".join(
......@@ -1356,12 +1430,20 @@ def write_capture_helper_source(all_param_types):
param_type_to_string_cases = "\n".join(
[format_param_type_to_string_case(t) for t in all_param_types])
param_type_resource_id_cases = format_param_type_resource_id_cases(all_param_types)
resource_id_types = get_resource_id_types(all_param_types)
resource_id_type_name_cases = "\n".join(
[format_resource_id_type_name_case(t) for t in resource_id_types])
content = template_frame_capture_utils_source.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
year=date.today().year,
write_param_type_to_stream_cases=write_param_type_to_stream_cases,
param_type_to_string_cases=param_type_to_string_cases)
param_type_to_string_cases=param_type_to_string_cases,
param_type_resource_id_cases=param_type_resource_id_cases,
resource_id_type_name_cases=resource_id_type_name_cases)
path = path_to("libANGLE", "frame_capture_utils_autogen.cpp")
......
......@@ -107,7 +107,7 @@ class PackedEnumMap
// No explicit construct/copy/destroy for aggregate type
void fill(const T &u) { mPrivateData.fill(u); }
void swap(PackedEnumMap<E, T> &a) noexcept { mPrivateData.swap(a.mPrivateData); }
void swap(PackedEnumMap<E, T, MaxSize> &a) noexcept { mPrivateData.swap(a.mPrivateData); }
// iterators:
iterator begin() noexcept { return mPrivateData.begin(); }
......
......@@ -174,9 +174,6 @@ class FrameCapture final : angle::NonCopyable
void replay(gl::Context *context);
private:
// <CallName, ParamName>
using Counter = std::tuple<gl::EntryPoint, std::string>;
void captureClientArraySnapshot(const gl::Context *context,
size_t vertexCount,
size_t instanceCount);
......@@ -192,10 +189,16 @@ class FrameCapture final : angle::NonCopyable
void maybeCaptureClientData(const gl::Context *context, const CallCapture &call);
void maybeUpdateResourceIDs(const gl::Context *context, const CallCapture &call);
template <typename IDType>
void captureUpdateResourceIDs(const gl::Context *context,
const CallCapture &call,
const ParamCapture &param);
std::vector<CallCapture> mCalls;
gl::AttribArray<int> mClientVertexArrayMap;
size_t mFrameIndex;
gl::AttribArray<size_t> mClientArraySizes;
angle::PackedEnumMap<ResourceIDType, uint32_t, angle::kParamTypeCount> mResourceIDCounts;
size_t mReadBufferSize;
static void ReplayCall(gl::Context *context,
......@@ -242,6 +245,13 @@ std::ostream &operator<<(std::ostream &os, const ParamCapture &capture);
// Pointer capture helpers.
void CaptureMemory(const void *source, size_t size, ParamCapture *paramCapture);
void CaptureString(const GLchar *str, ParamCapture *paramCapture);
void CaptureGenHandlesImpl(GLsizei n, GLuint *handles, ParamCapture *paramCapture);
template <typename T>
void CaptureGenHandles(GLsizei n, T *handles, ParamCapture *paramCapture)
{
CaptureGenHandlesImpl(n, reinterpret_cast<GLuint *>(handles), paramCapture);
}
template <ParamType ParamT, typename T>
void WriteParamValueToStream(std::ostream &os, T value);
......
......@@ -100,7 +100,7 @@ void CaptureDeleteBuffers_buffersPacked(const Context *context,
const BufferID *buffers,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(buffers, sizeof(BufferID) * n, paramCapture);
}
void CaptureDeleteFramebuffers_framebuffersPacked(const Context *context,
......@@ -109,7 +109,7 @@ void CaptureDeleteFramebuffers_framebuffersPacked(const Context *context,
const FramebufferID *framebuffers,
ParamCapture *paramCapture)
{
CaptureMemory(framebuffers, sizeof(GLuint) * n, paramCapture);
CaptureMemory(framebuffers, sizeof(FramebufferID) * n, paramCapture);
}
void CaptureDeleteRenderbuffers_renderbuffersPacked(const Context *context,
......@@ -127,7 +127,7 @@ void CaptureDeleteTextures_texturesPacked(const Context *context,
const TextureID *textures,
ParamCapture *paramCapture)
{
CaptureMemory(textures, sizeof(GLuint) * n, paramCapture);
CaptureMemory(textures, sizeof(TextureID) * n, paramCapture);
}
void CaptureDrawElements_indices(const Context *context,
......@@ -156,7 +156,7 @@ void CaptureGenBuffers_buffersPacked(const Context *context,
BufferID *buffers,
ParamCapture *paramCapture)
{
paramCapture->readBufferSizeBytes = sizeof(GLuint) * n;
CaptureGenHandles(n, buffers, paramCapture);
}
void CaptureGenFramebuffers_framebuffersPacked(const Context *context,
......@@ -165,7 +165,7 @@ void CaptureGenFramebuffers_framebuffersPacked(const Context *context,
FramebufferID *framebuffers,
ParamCapture *paramCapture)
{
paramCapture->readBufferSizeBytes = sizeof(GLuint) * n;
CaptureGenHandles(n, framebuffers, paramCapture);
}
void CaptureGenRenderbuffers_renderbuffersPacked(const Context *context,
......@@ -174,8 +174,7 @@ void CaptureGenRenderbuffers_renderbuffersPacked(const Context *context,
RenderbufferID *renderbuffers,
ParamCapture *paramCapture)
{
paramCapture->readBufferSizeBytes = sizeof(RenderbufferID) * n;
CaptureMemory(renderbuffers, paramCapture->readBufferSizeBytes, paramCapture);
CaptureGenHandles(n, renderbuffers, paramCapture);
}
void CaptureGenTextures_texturesPacked(const Context *context,
......@@ -184,7 +183,7 @@ void CaptureGenTextures_texturesPacked(const Context *context,
TextureID *textures,
ParamCapture *paramCapture)
{
paramCapture->readBufferSizeBytes = sizeof(GLuint) * n;
CaptureGenHandles(n, textures, paramCapture);
}
void CaptureGetActiveAttrib_length(const Context *context,
......
......@@ -82,7 +82,7 @@ void CaptureDeleteQueries_idsPacked(const Context *context,
const QueryID *ids,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(ids, sizeof(QueryID) * n, paramCapture);
}
void CaptureDeleteSamplers_samplersPacked(const Context *context,
......@@ -91,7 +91,7 @@ void CaptureDeleteSamplers_samplersPacked(const Context *context,
const SamplerID *samplers,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(samplers, sizeof(SamplerID) * count, paramCapture);
}
void CaptureDeleteTransformFeedbacks_idsPacked(const Context *context,
......@@ -100,7 +100,7 @@ void CaptureDeleteTransformFeedbacks_idsPacked(const Context *context,
const TransformFeedbackID *ids,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(ids, sizeof(TransformFeedbackID) * n, paramCapture);
}
void CaptureDeleteVertexArrays_arraysPacked(const Context *context,
......@@ -109,7 +109,7 @@ void CaptureDeleteVertexArrays_arraysPacked(const Context *context,
const VertexArrayID *arrays,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(arrays, sizeof(VertexArrayID) * n, paramCapture);
}
void CaptureDrawBuffers_bufs(const Context *context,
......@@ -152,7 +152,7 @@ void CaptureGenQueries_idsPacked(const Context *context,
QueryID *ids,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGenHandles(n, ids, paramCapture);
}
void CaptureGenSamplers_samplersPacked(const Context *context,
......@@ -161,7 +161,7 @@ void CaptureGenSamplers_samplersPacked(const Context *context,
SamplerID *samplers,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGenHandles(count, samplers, paramCapture);
}
void CaptureGenTransformFeedbacks_idsPacked(const Context *context,
......@@ -170,7 +170,7 @@ void CaptureGenTransformFeedbacks_idsPacked(const Context *context,
TransformFeedbackID *ids,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGenHandles(n, ids, paramCapture);
}
void CaptureGenVertexArrays_arraysPacked(const Context *context,
......@@ -179,7 +179,7 @@ void CaptureGenVertexArrays_arraysPacked(const Context *context,
VertexArrayID *arrays,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGenHandles(n, arrays, paramCapture);
}
void CaptureGetActiveUniformBlockName_length(const Context *context,
......
......@@ -29,7 +29,7 @@ void CaptureDeleteProgramPipelines_pipelinesPacked(const Context *context,
const ProgramPipelineID *pipelines,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(pipelines, sizeof(ProgramPipelineID) * n, paramCapture);
}
void CaptureDrawArraysIndirect_indirect(const Context *context,
......@@ -57,7 +57,7 @@ void CaptureGenProgramPipelines_pipelinesPacked(const Context *context,
ProgramPipelineID *pipelines,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGenHandles(n, pipelines, paramCapture);
}
void CaptureGetBooleani_v_data(const Context *context,
......
......@@ -2177,7 +2177,7 @@ void CaptureDeleteQueriesEXT_idsPacked(const Context *context,
const QueryID *ids,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(ids, sizeof(QueryID) * n, paramCapture);
}
void CaptureGenQueriesEXT_idsPacked(const Context *context,
......@@ -2186,7 +2186,7 @@ void CaptureGenQueriesEXT_idsPacked(const Context *context,
QueryID *ids,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGenHandles(n, ids, paramCapture);
}
void CaptureGetQueryObjecti64vEXT_params(const Context *context,
......
......@@ -691,4 +691,131 @@ const char *ParamTypeToString(ParamType paramType)
return "unknown";
}
}
ResourceIDType GetResourceIDTypeFromParamType(ParamType paramType)
{
switch (paramType)
{
case ParamType::TBufferID:
return ResourceIDType::Buffer;
case ParamType::TBufferIDConstPointer:
return ResourceIDType::Buffer;
case ParamType::TBufferIDPointer:
return ResourceIDType::Buffer;
case ParamType::TFenceNVID:
return ResourceIDType::FenceNV;
case ParamType::TFenceNVIDConstPointer:
return ResourceIDType::FenceNV;
case ParamType::TFenceNVIDPointer:
return ResourceIDType::FenceNV;
case ParamType::TFramebufferID:
return ResourceIDType::Framebuffer;
case ParamType::TFramebufferIDConstPointer:
return ResourceIDType::Framebuffer;
case ParamType::TFramebufferIDPointer:
return ResourceIDType::Framebuffer;
case ParamType::TMemoryObjectID:
return ResourceIDType::MemoryObject;
case ParamType::TMemoryObjectIDConstPointer:
return ResourceIDType::MemoryObject;
case ParamType::TMemoryObjectIDPointer:
return ResourceIDType::MemoryObject;
case ParamType::TPathID:
return ResourceIDType::Path;
case ParamType::TProgramPipelineID:
return ResourceIDType::ProgramPipeline;
case ParamType::TProgramPipelineIDConstPointer:
return ResourceIDType::ProgramPipeline;
case ParamType::TProgramPipelineIDPointer:
return ResourceIDType::ProgramPipeline;
case ParamType::TQueryID:
return ResourceIDType::Query;
case ParamType::TQueryIDConstPointer:
return ResourceIDType::Query;
case ParamType::TQueryIDPointer:
return ResourceIDType::Query;
case ParamType::TRenderbufferID:
return ResourceIDType::Renderbuffer;
case ParamType::TRenderbufferIDConstPointer:
return ResourceIDType::Renderbuffer;
case ParamType::TRenderbufferIDPointer:
return ResourceIDType::Renderbuffer;
case ParamType::TSamplerID:
return ResourceIDType::Sampler;
case ParamType::TSamplerIDConstPointer:
return ResourceIDType::Sampler;
case ParamType::TSamplerIDPointer:
return ResourceIDType::Sampler;
case ParamType::TSemaphoreID:
return ResourceIDType::Semaphore;
case ParamType::TSemaphoreIDConstPointer:
return ResourceIDType::Semaphore;
case ParamType::TSemaphoreIDPointer:
return ResourceIDType::Semaphore;
case ParamType::TShaderProgramID:
return ResourceIDType::ShaderProgram;
case ParamType::TShaderProgramIDConstPointer:
return ResourceIDType::ShaderProgram;
case ParamType::TShaderProgramIDPointer:
return ResourceIDType::ShaderProgram;
case ParamType::TTextureID:
return ResourceIDType::Texture;
case ParamType::TTextureIDConstPointer:
return ResourceIDType::Texture;
case ParamType::TTextureIDPointer:
return ResourceIDType::Texture;
case ParamType::TTransformFeedbackID:
return ResourceIDType::TransformFeedback;
case ParamType::TTransformFeedbackIDConstPointer:
return ResourceIDType::TransformFeedback;
case ParamType::TTransformFeedbackIDPointer:
return ResourceIDType::TransformFeedback;
case ParamType::TVertexArrayID:
return ResourceIDType::VertexArray;
case ParamType::TVertexArrayIDConstPointer:
return ResourceIDType::VertexArray;
case ParamType::TVertexArrayIDPointer:
return ResourceIDType::VertexArray;
default:
return ResourceIDType::InvalidEnum;
}
}
const char *GetResourceIDTypeName(ResourceIDType resourceIDType)
{
switch (resourceIDType)
{
case ResourceIDType::Buffer:
return "Buffer";
case ResourceIDType::FenceNV:
return "FenceNV";
case ResourceIDType::Framebuffer:
return "Framebuffer";
case ResourceIDType::MemoryObject:
return "MemoryObject";
case ResourceIDType::Path:
return "Path";
case ResourceIDType::ProgramPipeline:
return "ProgramPipeline";
case ResourceIDType::Query:
return "Query";
case ResourceIDType::Renderbuffer:
return "Renderbuffer";
case ResourceIDType::Sampler:
return "Sampler";
case ResourceIDType::Semaphore:
return "Semaphore";
case ResourceIDType::ShaderProgram:
return "ShaderProgram";
case ResourceIDType::Texture:
return "Texture";
case ResourceIDType::TransformFeedback:
return "TransformFeedback";
case ResourceIDType::VertexArray:
return "VertexArray";
default:
UNREACHABLE();
return "GetResourceIDTypeName error";
}
}
} // namespace angle
......@@ -139,6 +139,8 @@ enum class ParamType
TvoidPointerPointer,
};
constexpr uint32_t kParamTypeCount = 120;
union ParamValue
{
gl::AlphaTestFunc AlphaTestFuncVal;
......@@ -2470,6 +2472,29 @@ void InitParamValue(ParamType paramType, T valueIn, ParamValue *valueOut)
void WriteParamTypeToStream(std::ostream &os, ParamType paramType, const ParamValue &paramValue);
const char *ParamTypeToString(ParamType paramType);
enum class ResourceIDType
{
Buffer,
FenceNV,
Framebuffer,
MemoryObject,
Path,
ProgramPipeline,
Query,
Renderbuffer,
Sampler,
Semaphore,
ShaderProgram,
Texture,
TransformFeedback,
VertexArray,
EnumCount,
InvalidEnum = EnumCount
};
ResourceIDType GetResourceIDTypeFromParamType(ParamType paramType);
const char *GetResourceIDTypeName(ResourceIDType resourceIDType);
} // namespace angle
#endif // LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_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