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;
}
mFrameCapture->onMakeCurrent(drawSurface);
mFrameCapture->onMakeCurrent(this, drawSurface);
// TODO(jmadill): Rework this when we support ContextImpl
mState.setAllDirtyBits();

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

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

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

@ -301,6 +301,9 @@ using ProgramSourceMap = std::map<gl::ShaderProgramID, ProgramSources>;
using TextureLevels = std::map<GLint, std::vector<uint8_t>>;
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
{
public:
@ -311,7 +314,7 @@ class FrameCapture final : angle::NonCopyable
void checkForCaptureTrigger();
void onEndFrame(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 isCapturing() const;
@ -362,10 +365,9 @@ class FrameCapture final : angle::NonCopyable
uint32_t mFrameIndex;
uint32_t mCaptureStartFrame;
uint32_t mCaptureEndFrame;
bool mIsFirstFrame = true;
bool mWroteIndexFile = false;
EGLint mDrawSurfaceWidth = 0;
EGLint mDrawSurfaceHeight = 0;
bool mIsFirstFrame = true;
bool mWroteIndexFile = false;
SurfaceDimensions mDrawSurfaceDimensions;
gl::AttribArray<size_t> mClientArraySizes;
size_t mReadBufferSize;
HasResourceTypeMap mHasResourceType;

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

@ -24,7 +24,7 @@ ResourceTracker::~ResourceTracker() {}
FrameCapture::FrameCapture() {}
FrameCapture::~FrameCapture() {}
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::replay(gl::Context *context) {}