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(); }
......
......@@ -148,8 +148,9 @@ void WriteResourceIDPointerParamReplay(DataCounters *counters,
WriteParamStaticVarName(call, param, counter, header);
header << "[] = { ";
// TODO(jmadill): Other resource types. http://anglebug.com/3611
const char *name = "Renderbuffer";
const ResourceIDType resourceIDType = GetResourceIDTypeFromParamType(param.type);
ASSERT(resourceIDType != ResourceIDType::InvalidEnum);
const char *name = GetResourceIDTypeName(resourceIDType);
GLsizei n = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal;
ASSERT(param.data.size() == 1);
......@@ -371,7 +372,7 @@ ReplayContext::ReplayContext(size_t readBufferSizebytes,
}
ReplayContext::~ReplayContext() {}
FrameCapture::FrameCapture() : mFrameIndex(0), mReadBufferSize(0)
FrameCapture::FrameCapture() : mFrameIndex(0), mResourceIDCounts{}, mReadBufferSize(0)
{
reset();
}
......@@ -465,29 +466,141 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
maybeUpdateResourceIDs(context, mCalls.back());
}
template <typename IDType>
void FrameCapture::captureUpdateResourceIDs(const gl::Context *context,
const CallCapture &call,
const ParamCapture &param)
{
GLsizei n = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal;
ASSERT(param.data.size() == 1);
const IDType *returnedIDs = reinterpret_cast<const IDType *>(param.data[0].data());
ResourceIDType resourceIDType = GetResourceIDTypeFromParamType(param.type);
ASSERT(resourceIDType != ResourceIDType::InvalidEnum);
const char *resourceName = GetResourceIDTypeName(resourceIDType);
std::stringstream updateFuncNameStr;
updateFuncNameStr << "Update" << resourceName << "ID";
std::string updateFuncName = updateFuncNameStr.str();
for (GLsizei idIndex = 0; idIndex < n; ++idIndex)
{
IDType id = returnedIDs[idIndex];
GLsizei readBufferOffset = idIndex * sizeof(gl::RenderbufferID);
ParamBuffer params;
params.addValueParam("id", ParamType::TGLuint, id.value);
params.addValueParam("readBufferOffset", ParamType::TGLsizei, readBufferOffset);
mCalls.emplace_back(updateFuncName, std::move(params));
}
}
void FrameCapture::maybeUpdateResourceIDs(const gl::Context *context, const CallCapture &call)
{
for (const ParamCapture &param : call.params.getParamCaptures())
{
ResourceIDType idType = GetResourceIDTypeFromParamType(param.type);
if (idType != ResourceIDType::InvalidEnum)
{
mResourceIDCounts[idType]++;
}
}
switch (call.entryPoint)
{
case gl::EntryPoint::GenBuffers:
{
const ParamCapture &buffers =
call.params.getParam("buffersPacked", ParamType::TBufferIDPointer, 1);
captureUpdateResourceIDs<gl::BufferID>(context, call, buffers);
break;
}
case gl::EntryPoint::GenFencesNV:
{
const ParamCapture &fences =
call.params.getParam("fencesPacked", ParamType::TFenceNVIDPointer, 1);
captureUpdateResourceIDs<gl::FenceNVID>(context, call, fences);
break;
}
case gl::EntryPoint::GenFramebuffers:
case gl::EntryPoint::GenFramebuffersOES:
{
const ParamCapture &framebuffers =
call.params.getParam("framebuffersPacked", ParamType::TFramebufferIDPointer, 1);
captureUpdateResourceIDs<gl::FramebufferID>(context, call, framebuffers);
break;
}
case gl::EntryPoint::GenPathsCHROMIUM:
{
// TODO(jmadill): Handle path IDs. http://anglebug.com/3611
break;
}
case gl::EntryPoint::GenProgramPipelines:
{
const ParamCapture &pipelines =
call.params.getParam("pipelinesPacked", ParamType::TProgramPipelineIDPointer, 1);
captureUpdateResourceIDs<gl::ProgramPipelineID>(context, call, pipelines);
break;
}
case gl::EntryPoint::GenQueries:
case gl::EntryPoint::GenQueriesEXT:
{
const ParamCapture &queries =
call.params.getParam("idsPacked", ParamType::TQueryIDPointer, 1);
captureUpdateResourceIDs<gl::QueryID>(context, call, queries);
break;
}
case gl::EntryPoint::GenRenderbuffers:
case gl::EntryPoint::GenRenderbuffersOES:
{
GLsizei n = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal;
const ParamCapture &renderbuffers =
call.params.getParam("renderbuffersPacked", ParamType::TRenderbufferIDPointer, 1);
ASSERT(renderbuffers.data.size() == 1);
const gl::RenderbufferID *returnedIDs =
reinterpret_cast<const gl::RenderbufferID *>(renderbuffers.data[0].data());
captureUpdateResourceIDs<gl::RenderbufferID>(context, call, renderbuffers);
break;
}
for (GLsizei idIndex = 0; idIndex < n; ++idIndex)
{
gl::RenderbufferID id = returnedIDs[idIndex];
GLsizei readBufferOffset = idIndex * sizeof(gl::RenderbufferID);
ParamBuffer params;
params.addValueParam("id", ParamType::TGLuint, id.value);
params.addValueParam("readBufferOffset", ParamType::TGLsizei, readBufferOffset);
mCalls.emplace_back("UpdateRenderbufferID", std::move(params));
}
case gl::EntryPoint::GenSamplers:
{
const ParamCapture &samplers =
call.params.getParam("samplersPacked", ParamType::TSamplerIDPointer, 1);
captureUpdateResourceIDs<gl::SamplerID>(context, call, samplers);
break;
}
case gl::EntryPoint::GenSemaphoresEXT:
{
const ParamCapture &semaphores =
call.params.getParam("semaphoresPacked", ParamType::TSemaphoreIDPointer, 1);
captureUpdateResourceIDs<gl::SemaphoreID>(context, call, semaphores);
break;
}
case gl::EntryPoint::GenTextures:
{
const ParamCapture &textures =
call.params.getParam("texturesPacked", ParamType::TTextureIDPointer, 1);
captureUpdateResourceIDs<gl::TextureID>(context, call, textures);
break;
}
case gl::EntryPoint::GenTransformFeedbacks:
{
const ParamCapture &xfbs =
call.params.getParam("idsPacked", ParamType::TTransformFeedbackIDPointer, 1);
captureUpdateResourceIDs<gl::TransformFeedbackID>(context, call, xfbs);
break;
}
case gl::EntryPoint::GenVertexArrays:
case gl::EntryPoint::GenVertexArraysOES:
{
const ParamCapture &vertexArrays =
call.params.getParam("vetexArraysPacked", ParamType::TVertexArrayIDPointer, 1);
captureUpdateResourceIDs<gl::VertexArrayID>(context, call, vertexArrays);
break;
}
......@@ -599,13 +712,29 @@ void FrameCapture::saveCapturedFrameAsCpp(int contextId)
header << "}\n";
}
header << "std::unordered_map<GLuint, GLuint> gRenderbufferMap;\n";
header << "void UpdateRenderbufferID(GLuint id, GLsizei readBufferOffset)\n";
header << "using ResourceMap = std::unordered_map<GLuint, GLuint>;\n";
header << "void UpdateResourceMap(ResourceMap *resourceMap, GLuint id, GLsizei "
"readBufferOffset)\n";
header << "{\n";
header << " GLuint returnedID;\n";
header << " memcpy(&returnedID, &gReadBuffer[readBufferOffset], sizeof(GLuint));\n";
header << " gRenderbufferMap[id] = returnedID;\n";
header << " (*resourceMap)[id] = returnedID;\n";
header << "}\n";
header << "\n";
header << "// Resource Maps\n";
for (ResourceIDType resourceType : AllEnums<ResourceIDType>())
{
if (mResourceIDCounts[resourceType] == 0)
continue;
const char *name = GetResourceIDTypeName(resourceType);
header << "ResourceMap g" << name << "Map;\n";
header << "void Update" << name << "ID(GLuint id, GLsizei readBufferOffset)\n";
header << "{\n";
header << " UpdateResourceMap(&g" << name << "Map, id, readBufferOffset);\n";
header << "}\n";
}
out << "void ReplayFrame" << mFrameIndex << "()\n";
out << "{\n";
......@@ -698,6 +827,13 @@ void FrameCapture::writeCallReplay(const CallCapture &call,
{
std::ostringstream callOut;
if (call.entryPoint == gl::EntryPoint::CreateShader ||
call.entryPoint == gl::EntryPoint::CreateProgram)
{
GLuint id = call.params.getReturnValue().value.GLuintVal;
callOut << "gShaderProgramMap[" << id << "] = ";
}
callOut << call.name() << "(";
bool first = true;
......@@ -742,12 +878,53 @@ void FrameCapture::writeCallReplay(const CallCapture &call,
case ParamType::TGLcharConstPointerPointer:
WriteStringPointerParamReplay(counters, callOut, header, call, param);
break;
case ParamType::TBufferIDConstPointer:
WriteResourceIDPointerParamReplay<gl::BufferID>(counters, callOut, out, call,
param);
break;
case ParamType::TFenceNVIDConstPointer:
WriteResourceIDPointerParamReplay<gl::FenceNVID>(counters, callOut, out, call,
param);
break;
case ParamType::TFramebufferIDConstPointer:
WriteResourceIDPointerParamReplay<gl::FramebufferID>(counters, callOut, out,
call, param);
break;
case ParamType::TMemoryObjectIDConstPointer:
WriteResourceIDPointerParamReplay<gl::MemoryObjectID>(counters, callOut, out,
call, param);
break;
case ParamType::TProgramPipelineIDConstPointer:
WriteResourceIDPointerParamReplay<gl::ProgramPipelineID>(counters, callOut, out,
call, param);
break;
case ParamType::TQueryIDConstPointer:
WriteResourceIDPointerParamReplay<gl::QueryID>(counters, callOut, out, call,
param);
break;
case ParamType::TRenderbufferIDConstPointer:
WriteResourceIDPointerParamReplay<gl::RenderbufferID>(counters, callOut, out,
call, param);
break;
case ParamType::TRenderbufferIDPointer:
UNIMPLEMENTED();
case ParamType::TSamplerIDConstPointer:
WriteResourceIDPointerParamReplay<gl::SamplerID>(counters, callOut, out, call,
param);
break;
case ParamType::TSemaphoreIDConstPointer:
WriteResourceIDPointerParamReplay<gl::SemaphoreID>(counters, callOut, out, call,
param);
break;
case ParamType::TTextureIDConstPointer:
WriteResourceIDPointerParamReplay<gl::TextureID>(counters, callOut, out, call,
param);
break;
case ParamType::TTransformFeedbackIDConstPointer:
WriteResourceIDPointerParamReplay<gl::TransformFeedbackID>(counters, callOut,
out, call, param);
break;
case ParamType::TVertexArrayIDConstPointer:
WriteResourceIDPointerParamReplay<gl::VertexArrayID>(counters, callOut, out,
call, param);
break;
default:
WriteBinaryParamReplay(counters, callOut, header, call, param, binaryData);
......@@ -808,6 +985,7 @@ void FrameCapture::reset()
mCalls.clear();
mClientVertexArrayMap.fill(-1);
mClientArraySizes.fill(0);
mResourceIDCounts.fill(0);
mReadBufferSize = 0;
}
......@@ -830,6 +1008,12 @@ void CaptureString(const GLchar *str, ParamCapture *paramCapture)
CaptureMemory(str, strlen(str) + 1, paramCapture);
}
void CaptureGenHandlesImpl(GLsizei n, GLuint *handles, ParamCapture *paramCapture)
{
paramCapture->readBufferSizeBytes = sizeof(GLuint) * n;
CaptureMemory(handles, paramCapture->readBufferSizeBytes, paramCapture);
}
template <>
void WriteParamValueToStream<ParamType::TGLboolean>(std::ostream &os, GLboolean value)
{
......@@ -868,92 +1052,91 @@ template <>
void WriteParamValueToStream<ParamType::TGLDEBUGPROC>(std::ostream &os, GLDEBUGPROC value)
{}
// TODO(jmadill): Use resource ID map. http://anglebug.com/3611
template <>
void WriteParamValueToStream<ParamType::TBufferID>(std::ostream &os, gl::BufferID value)
{
os << value.value;
os << "gBufferMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TFenceNVID>(std::ostream &os, gl::FenceNVID value)
{
os << value.value;
os << "gFenceMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TFramebufferID>(std::ostream &os, gl::FramebufferID value)
{
os << value.value;
os << "gFramebufferMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TMemoryObjectID>(std::ostream &os, gl::MemoryObjectID value)
{
os << value.value;
os << "gMemoryObjectMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TPathID>(std::ostream &os, gl::PathID value)
{
os << value.value;
os << "gPathMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TProgramPipelineID>(std::ostream &os,
gl::ProgramPipelineID value)
{
os << value.value;
os << "gProgramPipelineMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TQueryID>(std::ostream &os, gl::QueryID value)
{
os << value.value;
os << "gQueryMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TRenderbufferID>(std::ostream &os, gl::RenderbufferID value)
{
os << value.value;
os << "gRenderbufferMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TSamplerID>(std::ostream &os, gl::SamplerID value)
{
os << value.value;
os << "gSamplerMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TSemaphoreID>(std::ostream &os, gl::SemaphoreID value)
{
os << value.value;
os << "gSempahoreMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TShaderProgramID>(std::ostream &os,
gl::ShaderProgramID value)
{
os << value.value;
os << "gShaderProgramMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TTextureID>(std::ostream &os, gl::TextureID value)
{
os << value.value;
os << "gTextureMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TTransformFeedbackID>(std::ostream &os,
gl::TransformFeedbackID value)
{
os << value.value;
os << "gTransformFeedbackMap[" << value.value << "]";
}
template <>
void WriteParamValueToStream<ParamType::TVertexArrayID>(std::ostream &os, gl::VertexArrayID value)
{
os << value.value;
os << "gVertexArrayMap[" << value.value << "]";
}
#endif // ANGLE_CAPTURE_ENABLED
} // namespace angle
......@@ -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