FrameCapture: Track surface width/height per context

Test: Capture PUBG Mobile
Bug: b/159238311
Bug: b/165824228
Change-Id: I7bbc7a80ade4df6b191cbe62e9badac1066ab246
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2503474
Commit-Queue: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Cody Northrop 2020-10-27 11:30:27 -06:00 коммит произвёл Commit Bot
Родитель 77defeb046
Коммит 97a45a9f1d
4 изменённых файлов: 24 добавлений и 22 удалений

Просмотреть файл

@ -673,7 +673,7 @@ egl::Error Context::makeCurrent(egl::Display *display,
mHasBeenCurrent = true; mHasBeenCurrent = true;
} }
mFrameCapture->onMakeCurrent(drawSurface); mFrameCapture->onMakeCurrent(this, drawSurface);
// TODO(jmadill): Rework this when we support ContextImpl // TODO(jmadill): Rework this when we support ContextImpl
mState.setAllDirtyBits(); mState.setAllDirtyBits();

Просмотреть файл

@ -1185,8 +1185,7 @@ void WriteCppReplayIndexFiles(bool compression,
const gl::ContextID contextId, const gl::ContextID contextId,
const std::string &captureLabel, const std::string &captureLabel,
uint32_t frameCount, uint32_t frameCount,
EGLint drawSurfaceWidth, const SurfaceDimensions &drawSurfaceDimensions,
EGLint drawSurfaceHeight,
size_t readBufferSize, size_t readBufferSize,
const gl::AttribArray<size_t> &clientArraySizes, const gl::AttribArray<size_t> &clientArraySizes,
const HasResourceTypeMap &hasResourceType, const HasResourceTypeMap &hasResourceType,
@ -1230,8 +1229,10 @@ void WriteCppReplayIndexFiles(bool compression,
header << " " << ANGLE_REVISION << "\n"; header << " " << ANGLE_REVISION << "\n";
header << "constexpr uint32_t kReplayFrameStart = 1;\n"; header << "constexpr uint32_t kReplayFrameStart = 1;\n";
header << "constexpr uint32_t kReplayFrameEnd = " << frameCount << ";\n"; header << "constexpr uint32_t kReplayFrameEnd = " << frameCount << ";\n";
header << "constexpr EGLint kReplayDrawSurfaceWidth = " << drawSurfaceWidth << ";\n"; header << "constexpr EGLint kReplayDrawSurfaceWidth = "
header << "constexpr EGLint kReplayDrawSurfaceHeight = " << drawSurfaceHeight << ";\n"; << drawSurfaceDimensions.at(contextId).width << ";\n";
header << "constexpr EGLint kReplayDrawSurfaceHeight = "
<< drawSurfaceDimensions.at(contextId).height << ";\n";
header << "constexpr EGLint kDefaultFramebufferRedBits = " header << "constexpr EGLint kDefaultFramebufferRedBits = "
<< (config ? std::to_string(config->redSize) : "EGL_DONT_CARE") << ";\n"; << (config ? std::to_string(config->redSize) : "EGL_DONT_CARE") << ";\n";
header << "constexpr EGLint kDefaultFramebufferGreenBits = " header << "constexpr EGLint kDefaultFramebufferGreenBits = "
@ -4379,10 +4380,10 @@ void FrameCapture::onEndFrame(const gl::Context *context)
if (mFrameIndex == mCaptureEndFrame) if (mFrameIndex == mCaptureEndFrame)
{ {
// Save the index files after the last frame. // Save the index files after the last frame.
WriteCppReplayIndexFiles( WriteCppReplayIndexFiles(mCompression, mOutDirectory, context->id(), mCaptureLabel,
mCompression, mOutDirectory, context->id(), mCaptureLabel, getFrameCount(), getFrameCount(), mDrawSurfaceDimensions, mReadBufferSize,
mDrawSurfaceWidth, mDrawSurfaceHeight, mReadBufferSize, mClientArraySizes, mClientArraySizes, mHasResourceType, mSerializeStateEnabled,
mHasResourceType, mSerializeStateEnabled, false, context->getConfig(), mBinaryData); false, context->getConfig(), mBinaryData);
if (!mBinaryData.empty()) if (!mBinaryData.empty())
{ {
SaveBinaryData(mCompression, mOutDirectory, context->id(), mCaptureLabel, SaveBinaryData(mCompression, mOutDirectory, context->id(), mCaptureLabel,
@ -4431,9 +4432,9 @@ void FrameCapture::onDestroyContext(const gl::Context *context)
mFrameIndex -= 1; mFrameIndex -= 1;
mCaptureEndFrame = mFrameIndex; mCaptureEndFrame = mFrameIndex;
WriteCppReplayIndexFiles(mCompression, mOutDirectory, context->id(), mCaptureLabel, WriteCppReplayIndexFiles(mCompression, mOutDirectory, context->id(), mCaptureLabel,
getFrameCount(), mDrawSurfaceWidth, mDrawSurfaceHeight, getFrameCount(), mDrawSurfaceDimensions, mReadBufferSize,
mReadBufferSize, mClientArraySizes, mHasResourceType, mClientArraySizes, mHasResourceType, mSerializeStateEnabled, true,
mSerializeStateEnabled, true, context->getConfig(), mBinaryData); context->getConfig(), mBinaryData);
if (!mBinaryData.empty()) if (!mBinaryData.empty())
{ {
SaveBinaryData(mCompression, mOutDirectory, context->id(), mCaptureLabel, mBinaryData); SaveBinaryData(mCompression, mOutDirectory, context->id(), mCaptureLabel, mBinaryData);
@ -4443,15 +4444,14 @@ void FrameCapture::onDestroyContext(const gl::Context *context)
} }
} }
void FrameCapture::onMakeCurrent(const egl::Surface *drawSurface) void FrameCapture::onMakeCurrent(const gl::Context *context, const egl::Surface *drawSurface)
{ {
if (!drawSurface) if (!drawSurface)
return; return;
// Track the width and height of the draw surface as provided to makeCurrent // Track the width and height of the draw surface as provided to makeCurrent
// TODO (b/159238311): Track this per context. Right now last one wins. mDrawSurfaceDimensions[context->id()] =
mDrawSurfaceWidth = drawSurface->getWidth(); gl::Extents(drawSurface->getWidth(), drawSurface->getHeight(), 1);
mDrawSurfaceHeight = drawSurface->getHeight();
} }
DataCounters::DataCounters() = default; DataCounters::DataCounters() = default;

Просмотреть файл

@ -301,6 +301,9 @@ using ProgramSourceMap = std::map<gl::ShaderProgramID, ProgramSources>;
using TextureLevels = std::map<GLint, std::vector<uint8_t>>; using TextureLevels = std::map<GLint, std::vector<uint8_t>>;
using TextureLevelDataMap = std::map<gl::TextureID, TextureLevels>; using TextureLevelDataMap = std::map<gl::TextureID, TextureLevels>;
// Map from ContextID to surface dimensions
using SurfaceDimensions = std::map<gl::ContextID, gl::Extents>;
class FrameCapture final : angle::NonCopyable class FrameCapture final : angle::NonCopyable
{ {
public: public:
@ -311,7 +314,7 @@ class FrameCapture final : angle::NonCopyable
void checkForCaptureTrigger(); void checkForCaptureTrigger();
void onEndFrame(const gl::Context *context); void onEndFrame(const gl::Context *context);
void onDestroyContext(const gl::Context *context); void onDestroyContext(const gl::Context *context);
void onMakeCurrent(const egl::Surface *drawSurface); void onMakeCurrent(const gl::Context *context, const egl::Surface *drawSurface);
bool enabled() const { return mEnabled; } bool enabled() const { return mEnabled; }
bool isCapturing() const; bool isCapturing() const;
@ -362,10 +365,9 @@ class FrameCapture final : angle::NonCopyable
uint32_t mFrameIndex; uint32_t mFrameIndex;
uint32_t mCaptureStartFrame; uint32_t mCaptureStartFrame;
uint32_t mCaptureEndFrame; uint32_t mCaptureEndFrame;
bool mIsFirstFrame = true; bool mIsFirstFrame = true;
bool mWroteIndexFile = false; bool mWroteIndexFile = false;
EGLint mDrawSurfaceWidth = 0; SurfaceDimensions mDrawSurfaceDimensions;
EGLint mDrawSurfaceHeight = 0;
gl::AttribArray<size_t> mClientArraySizes; gl::AttribArray<size_t> mClientArraySizes;
size_t mReadBufferSize; size_t mReadBufferSize;
HasResourceTypeMap mHasResourceType; HasResourceTypeMap mHasResourceType;

Просмотреть файл

@ -24,7 +24,7 @@ ResourceTracker::~ResourceTracker() {}
FrameCapture::FrameCapture() {} FrameCapture::FrameCapture() {}
FrameCapture::~FrameCapture() {} FrameCapture::~FrameCapture() {}
void FrameCapture::onEndFrame(const gl::Context *context) {} void FrameCapture::onEndFrame(const gl::Context *context) {}
void FrameCapture::onMakeCurrent(const egl::Surface *drawSurface) {} void FrameCapture::onMakeCurrent(const gl::Context *context, const egl::Surface *drawSurface) {}
void FrameCapture::onDestroyContext(const gl::Context *context) {} void FrameCapture::onDestroyContext(const gl::Context *context) {}
void FrameCapture::replay(gl::Context *context) {} void FrameCapture::replay(gl::Context *context) {}