Commit 06ce17e0 by Cody Northrop Committed by Commit Bot

Capture/Replay: Reset buffers on replay loop

This CL adds infrastructure for tracking whether resources need to be reset when looping back to the beginning of the frame sequence. A new function is generated on the last frame: ResetContext*Replay(). It will contain calls to gen, delete, and restore contents of resources. This CL only supports Buffer resets. Bug: b/152512564 Bug: angleproject:3662 Bug: angleproject:4599 Change-Id: I46672dd70dcb997967e3cc0897308144f2582e21 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2168121 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c02cdff7
...@@ -27,6 +27,9 @@ std::function<void()> SetupContextReplay = reinterpret_cast<void (*)()>( ...@@ -27,6 +27,9 @@ std::function<void()> SetupContextReplay = reinterpret_cast<void (*)()>(
std::function<void(int)> ReplayContextFrame = reinterpret_cast<void (*)(int)>( std::function<void(int)> ReplayContextFrame = reinterpret_cast<void (*)(int)>(
ANGLE_MACRO_CONCAT(ReplayContext, ANGLE_MACRO_CONCAT(ReplayContext,
ANGLE_MACRO_CONCAT(ANGLE_CAPTURE_REPLAY_SAMPLE_CONTEXT_ID, Frame))); ANGLE_MACRO_CONCAT(ANGLE_CAPTURE_REPLAY_SAMPLE_CONTEXT_ID, Frame)));
std::function<void()> ResetContextReplay = reinterpret_cast<void (*)()>(
ANGLE_MACRO_CONCAT(ResetContext,
ANGLE_MACRO_CONCAT(ANGLE_CAPTURE_REPLAY_SAMPLE_CONTEXT_ID, Replay)));
class CaptureReplaySample : public SampleApplication class CaptureReplaySample : public SampleApplication
{ {
...@@ -59,12 +62,19 @@ class CaptureReplaySample : public SampleApplication ...@@ -59,12 +62,19 @@ class CaptureReplaySample : public SampleApplication
// Compute the current frame, looping from kReplayFrameStart to kReplayFrameEnd. // Compute the current frame, looping from kReplayFrameStart to kReplayFrameEnd.
uint32_t frame = uint32_t frame =
kReplayFrameStart + (mCurrentFrame % (kReplayFrameEnd - kReplayFrameStart)); kReplayFrameStart + (mCurrentFrame % (kReplayFrameEnd - kReplayFrameStart));
if (mPreviousFrame > frame)
{
ResetContextReplay();
}
ReplayContextFrame(frame); ReplayContextFrame(frame);
mPreviousFrame = frame;
mCurrentFrame++; mCurrentFrame++;
} }
private: private:
uint32_t mCurrentFrame = 0; uint32_t mCurrentFrame = 0;
uint32_t mPreviousFrame = 0;
}; };
int main(int argc, char **argv) int main(int argc, char **argv)
......
...@@ -177,6 +177,44 @@ class DataCounters final : angle::NonCopyable ...@@ -177,6 +177,44 @@ class DataCounters final : angle::NonCopyable
std::map<Counter, int> mData; std::map<Counter, int> mData;
}; };
using BufferSet = std::set<gl::BufferID>;
using BufferCalls = std::map<gl::BufferID, std::vector<CallCapture>>;
// Helper to track resource changes during the capture
class ResourceTracker final : angle::NonCopyable
{
public:
ResourceTracker();
~ResourceTracker();
BufferCalls &getBufferRegenCalls() { return mBufferRegenCalls; }
BufferCalls &getBufferRestoreCalls() { return mBufferRestoreCalls; }
BufferSet &getStartingBuffers() { return mStartingBuffers; }
BufferSet &getNewBuffers() { return mNewBuffers; }
BufferSet &getBuffersToRegen() { return mBuffersToRegen; }
BufferSet &getBuffersToRestore() { return mBuffersToRestore; }
void setGennedBuffer(gl::BufferID id);
void setDeletedBuffer(gl::BufferID id);
void setBufferModified(gl::BufferID id);
private:
// Buffer regen calls will delete and gen a buffer
BufferCalls mBufferRegenCalls;
// Buffer restore calls will restore the contents of a buffer
BufferCalls mBufferRestoreCalls;
// Starting buffers include all the buffers created during setup for MEC
BufferSet mStartingBuffers;
// New buffers are those generated while capturing
BufferSet mNewBuffers;
// Buffers to regen are a list of starting buffers that need to be deleted and genned
BufferSet mBuffersToRegen;
// Buffers to restore include any starting buffers with contents modified during the run
BufferSet mBuffersToRestore;
};
// Used by the CPP replay to filter out unnecessary code. // Used by the CPP replay to filter out unnecessary code.
using HasResourceTypeMap = angle::PackedEnumBitSet<ResourceIDType>; using HasResourceTypeMap = angle::PackedEnumBitSet<ResourceIDType>;
...@@ -225,7 +263,6 @@ class FrameCapture final : angle::NonCopyable ...@@ -225,7 +263,6 @@ class FrameCapture final : angle::NonCopyable
std::vector<CallCapture> mSetupCalls; std::vector<CallCapture> mSetupCalls;
std::vector<CallCapture> mFrameCalls; std::vector<CallCapture> mFrameCalls;
std::vector<CallCapture> mTearDownCalls;
// We save one large buffer of binary data for the whole CPP replay. // We save one large buffer of binary data for the whole CPP replay.
// This simplifies a lot of file management. // This simplifies a lot of file management.
...@@ -244,6 +281,8 @@ class FrameCapture final : angle::NonCopyable ...@@ -244,6 +281,8 @@ class FrameCapture final : angle::NonCopyable
HasResourceTypeMap mHasResourceType; HasResourceTypeMap mHasResourceType;
BufferDataMap mBufferDataMap; BufferDataMap mBufferDataMap;
ResourceTracker mResourceTracker;
// Cache most recently compiled and linked sources. // Cache most recently compiled and linked sources.
ShaderSourceMap mCachedShaderSources; ShaderSourceMap mCachedShaderSources;
ProgramSourceMap mCachedProgramSources; ProgramSourceMap mCachedProgramSources;
......
...@@ -18,6 +18,8 @@ namespace angle ...@@ -18,6 +18,8 @@ namespace angle
CallCapture::~CallCapture() {} CallCapture::~CallCapture() {}
ParamBuffer::~ParamBuffer() {} ParamBuffer::~ParamBuffer() {}
ParamCapture::~ParamCapture() {} ParamCapture::~ParamCapture() {}
ResourceTracker::ResourceTracker() {}
ResourceTracker::~ResourceTracker() {}
FrameCapture::FrameCapture() {} FrameCapture::FrameCapture() {}
FrameCapture::~FrameCapture() {} FrameCapture::~FrameCapture() {}
......
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