Commit 5a9827d2 by Cody Northrop Committed by Commit Bot

FrameCapture: Move shader and program source to shared cache

These are local copies of source seen earlier in the trace. Centralize them so they can be tracked across contexts. Test: PUBG MEC Bug: b/165824228 Bug: angleproject:4048 Change-Id: If414826b0280c61507812c2fd92706b7f095cc4b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2462162 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 51ff0d05
...@@ -2280,8 +2280,6 @@ void CaptureBufferResetCalls(const gl::State &replayState, ...@@ -2280,8 +2280,6 @@ void CaptureBufferResetCalls(const gl::State &replayState,
void CaptureMidExecutionSetup(const gl::Context *context, void CaptureMidExecutionSetup(const gl::Context *context,
std::vector<CallCapture> *setupCalls, std::vector<CallCapture> *setupCalls,
ResourceTracker *resourceTracker, ResourceTracker *resourceTracker,
const ShaderSourceMap &cachedShaderSources,
const ProgramSourceMap &cachedProgramSources,
FrameCapture *frameCapture) FrameCapture *frameCapture)
{ {
const gl::State &apiState = context->getState(); const gl::State &apiState = context->getState();
...@@ -2811,9 +2809,8 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -2811,9 +2809,8 @@ void CaptureMidExecutionSetup(const gl::Context *context,
const gl::Program *program = programIter.second; const gl::Program *program = programIter.second;
// Get last compiled shader source. // Get last compiled shader source.
const auto &foundSources = cachedProgramSources.find(id); const ProgramSources &linkedSources =
ASSERT(foundSources != cachedProgramSources.end()); context->getShareGroup()->getFrameCaptureShared()->getProgramSources(id);
const ProgramSources &linkedSources = foundSources->second;
// Unlinked programs don't have an executable. Thus they don't need to be linked. // Unlinked programs don't have an executable. Thus they don't need to be linked.
if (!program->isLinked()) if (!program->isLinked())
...@@ -2904,10 +2901,8 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -2904,10 +2901,8 @@ void CaptureMidExecutionSetup(const gl::Context *context,
// TODO(jmadill): Handle trickier program uses. http://anglebug.com/3662 // TODO(jmadill): Handle trickier program uses. http://anglebug.com/3662
if (shader->isCompiled()) if (shader->isCompiled())
{ {
const auto &foundSources = cachedShaderSources.find(id); const std::string &capturedSource =
ASSERT(foundSources != cachedShaderSources.end()); context->getShareGroup()->getFrameCaptureShared()->getShaderSource(id);
const std::string &capturedSource = foundSources->second;
if (capturedSource != shaderSource) if (capturedSource != shaderSource)
{ {
ASSERT(!capturedSource.empty()); ASSERT(!capturedSource.empty());
...@@ -4011,8 +4006,9 @@ void FrameCapture::maybeCapturePreCallUpdates(const gl::Context *context, CallCa ...@@ -4011,8 +4006,9 @@ void FrameCapture::maybeCapturePreCallUpdates(const gl::Context *context, CallCa
gl::ShaderProgramID shaderID = gl::ShaderProgramID shaderID =
call.params.getParam("shaderPacked", ParamType::TShaderProgramID, 0) call.params.getParam("shaderPacked", ParamType::TShaderProgramID, 0)
.value.ShaderProgramIDVal; .value.ShaderProgramIDVal;
const gl::Shader *shader = context->getShader(shaderID); const gl::Shader *shader = context->getShader(shaderID);
mCachedShaderSources[shaderID] = shader->getSourceString(); context->getShareGroup()->getFrameCaptureShared()->setShaderSource(
shaderID, shader->getSourceString());
break; break;
} }
...@@ -4022,8 +4018,9 @@ void FrameCapture::maybeCapturePreCallUpdates(const gl::Context *context, CallCa ...@@ -4022,8 +4018,9 @@ void FrameCapture::maybeCapturePreCallUpdates(const gl::Context *context, CallCa
gl::ShaderProgramID programID = gl::ShaderProgramID programID =
call.params.getParam("programPacked", ParamType::TShaderProgramID, 0) call.params.getParam("programPacked", ParamType::TShaderProgramID, 0)
.value.ShaderProgramIDVal; .value.ShaderProgramIDVal;
const gl::Program *program = context->getProgramResolveLink(programID); const gl::Program *program = context->getProgramResolveLink(programID);
mCachedProgramSources[programID] = GetAttachedProgramSources(program); context->getShareGroup()->getFrameCaptureShared()->setProgramSources(
programID, GetAttachedProgramSources(program));
break; break;
} }
...@@ -4404,8 +4401,7 @@ void FrameCapture::onEndFrame(const gl::Context *context) ...@@ -4404,8 +4401,7 @@ void FrameCapture::onEndFrame(const gl::Context *context)
if (enabled() && mFrameIndex == mFrameStart) if (enabled() && mFrameIndex == mFrameStart)
{ {
mSetupCalls.clear(); mSetupCalls.clear();
CaptureMidExecutionSetup(context, &mSetupCalls, &mResourceTracker, mCachedShaderSources, CaptureMidExecutionSetup(context, &mSetupCalls, &mResourceTracker, this);
mCachedProgramSources, this);
} }
} }
...@@ -4607,6 +4603,30 @@ void FrameCapture::reset() ...@@ -4607,6 +4603,30 @@ void FrameCapture::reset()
FrameCaptureShared::FrameCaptureShared() = default; FrameCaptureShared::FrameCaptureShared() = default;
FrameCaptureShared::~FrameCaptureShared() = default; FrameCaptureShared::~FrameCaptureShared() = default;
const std::string &FrameCaptureShared::getShaderSource(gl::ShaderProgramID id) const
{
const auto &foundSources = mCachedShaderSource.find(id);
ASSERT(foundSources != mCachedShaderSource.end());
return foundSources->second;
}
void FrameCaptureShared::setShaderSource(gl::ShaderProgramID id, std::string source)
{
mCachedShaderSource[id] = source;
}
const ProgramSources &FrameCaptureShared::getProgramSources(gl::ShaderProgramID id) const
{
const auto &foundSources = mCachedProgramSources.find(id);
ASSERT(foundSources != mCachedProgramSources.end());
return foundSources->second;
}
void FrameCaptureShared::setProgramSources(gl::ShaderProgramID id, ProgramSources sources)
{
mCachedProgramSources[id] = sources;
}
const std::vector<uint8_t> &FrameCaptureShared::retrieveCachedTextureLevel(gl::TextureID id, const std::vector<uint8_t> &FrameCaptureShared::retrieveCachedTextureLevel(gl::TextureID id,
GLint level) GLint level)
{ {
......
...@@ -369,10 +369,6 @@ class FrameCapture final : angle::NonCopyable ...@@ -369,10 +369,6 @@ class FrameCapture final : angle::NonCopyable
ResourceTracker mResourceTracker; ResourceTracker mResourceTracker;
// Cache most recently compiled and linked sources.
ShaderSourceMap mCachedShaderSources;
ProgramSourceMap mCachedProgramSources;
// If you don't know which frame you want to start capturing at, use the capture trigger. // If you don't know which frame you want to start capturing at, use the capture trigger.
// Initialize it to the number of frames you want to capture, and then clear the value to 0 when // Initialize it to the number of frames you want to capture, and then clear the value to 0 when
// you reach the content you want to capture. Currently only available on Android. // you reach the content you want to capture. Currently only available on Android.
...@@ -386,6 +382,12 @@ class FrameCaptureShared final : angle::NonCopyable ...@@ -386,6 +382,12 @@ class FrameCaptureShared final : angle::NonCopyable
FrameCaptureShared(); FrameCaptureShared();
~FrameCaptureShared(); ~FrameCaptureShared();
const std::string &getShaderSource(gl::ShaderProgramID id) const;
void setShaderSource(gl::ShaderProgramID id, std::string sources);
const ProgramSources &getProgramSources(gl::ShaderProgramID id) const;
void setProgramSources(gl::ShaderProgramID id, ProgramSources sources);
// Load data from a previously stored texture level // Load data from a previously stored texture level
const std::vector<uint8_t> &retrieveCachedTextureLevel(gl::TextureID id, GLint level); const std::vector<uint8_t> &retrieveCachedTextureLevel(gl::TextureID id, GLint level);
...@@ -398,6 +400,10 @@ class FrameCaptureShared final : angle::NonCopyable ...@@ -398,6 +400,10 @@ class FrameCaptureShared final : angle::NonCopyable
void deleteCachedTextureLevelData(gl::TextureID id); void deleteCachedTextureLevelData(gl::TextureID id);
private: private:
// Cache most recently compiled and linked sources.
ShaderSourceMap mCachedShaderSource;
ProgramSourceMap mCachedProgramSources;
// Cache a shadow copy of texture level data // Cache a shadow copy of texture level data
TextureLevels mCachedTextureLevels; TextureLevels mCachedTextureLevels;
TextureLevelDataMap mCachedTextureLevelData; TextureLevelDataMap mCachedTextureLevelData;
......
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