Commit 3ea90d60 by Jiacheng Lu Committed by Commit Bot

Fix compile error on capture with client array

1. The current implementation misused the offset in gBinaryData as the memcpy size. This CL fixed it by adding the byte size into the UpdateClientArrayPointer call. 2. Trying passing a pointer to a C-style array parameter which causes compiling error. This CL fixed by simply use const void * to do memcpy. 3. Able to run frame capture successfully for the first 100 frames of glmark2. Bug: angleproject:3611 Change-Id: Ibaef224c2a2d124b681757d9ecd187a5f9b7079b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1721207 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 9d737966
...@@ -278,6 +278,8 @@ void FrameCapture::captureClientArraySnapshot(const gl::Context *context, ...@@ -278,6 +278,8 @@ void FrameCapture::captureClientArraySnapshot(const gl::Context *context,
CaptureMemory(param.value.voidConstPointerVal, bytesToCapture, &updateMemory); CaptureMemory(param.value.voidConstPointerVal, bytesToCapture, &updateMemory);
updateParamBuffer.addParam(std::move(updateMemory)); updateParamBuffer.addParam(std::move(updateMemory));
updateParamBuffer.addValueParam<GLuint64>("size", ParamType::TGLuint64, bytesToCapture);
mCalls.emplace_back("UpdateClientArrayPointer", std::move(updateParamBuffer)); mCalls.emplace_back("UpdateClientArrayPointer", std::move(updateParamBuffer));
mClientArraySizes[attribIndex] = mClientArraySizes[attribIndex] =
...@@ -319,6 +321,7 @@ void FrameCapture::saveCapturedFrameAsCpp() ...@@ -319,6 +321,7 @@ void FrameCapture::saveCapturedFrameAsCpp()
header << "#include \"util/gles_loader_autogen.h\"\n"; header << "#include \"util/gles_loader_autogen.h\"\n";
header << "\n"; header << "\n";
header << "#include <cstdio>\n"; header << "#include <cstdio>\n";
header << "#include <cstring>\n";
header << "#include <vector>\n"; header << "#include <vector>\n";
header << "\n"; header << "\n";
header << "namespace\n"; header << "namespace\n";
...@@ -330,10 +333,10 @@ void FrameCapture::saveCapturedFrameAsCpp() ...@@ -330,10 +333,10 @@ void FrameCapture::saveCapturedFrameAsCpp()
if (useClientArrays) if (useClientArrays)
{ {
header << "std::vector<uint8_t> gClientArrays[" << gl::MAX_VERTEX_ATTRIBS << "];\n"; header << "std::vector<uint8_t> gClientArrays[" << gl::MAX_VERTEX_ATTRIBS << "];\n";
header << "template <size_t N>\n"; header << "void UpdateClientArrayPointer(int arrayIndex, const void *data, GLuint64 size)"
header << "void UpdateClientArrayPointer(int arrayIndex, const uint8_t (&data)[N])\n"; << "\n";
header << "{\n"; header << "{\n";
header << " memcpy(gClientArrays[arrayIndex].data(), data, N);\n"; header << " memcpy(gClientArrays[arrayIndex].data(), data, size);\n";
header << "}\n"; header << "}\n";
} }
...@@ -482,8 +485,16 @@ void FrameCapture::writeCallReplay(const CallCapture &call, ...@@ -482,8 +485,16 @@ void FrameCapture::writeCallReplay(const CallCapture &call,
size_t offset = binaryData->size(); size_t offset = binaryData->size();
binaryData->resize(offset + data.size()); binaryData->resize(offset + data.size());
memcpy(binaryData->data() + offset, data.data(), data.size()); memcpy(binaryData->data() + offset, data.data(), data.size());
out << "reinterpret_cast<" << ParamTypeToString(param.type) << ">(&gBinaryData[" if (param.type == ParamType::TvoidConstPointer ||
<< offset << "])"; param.type == ParamType::TvoidPointer)
{
out << "&gBinaryData[" << offset << "]";
}
else
{
out << "reinterpret_cast<" << ParamTypeToString(param.type)
<< ">(&gBinaryData[" << offset << "])";
}
} }
else else
{ {
......
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