Commit 22c95964 by Cody Northrop Committed by Commit Bot

Capture/Replay: Support buffer map/unmap state during MEC

Angry Birds 2 is the first app we've targeted that maps buffers across frame boundaries. This exposed some gaps and assumptions we had in the code, and required additional support for MEC. To support this, we track each buffer's starting map/unmap state and how it changes throughout the trace. Then during Reset, we emit calls to return them to the correct state: void ResetContext3Replay() { ... glBindBuffer(GL_ARRAY_BUFFER, gBufferMap[546]); glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, gBufferMap[550]); gMappedBufferData[gBufferMap[550]] = glMapBufferRange(GL_ARRAY_BUFFER, 0, 8192, GL_MAP_WRITE_BIT); ... } Test: MEC of Angry Birds 2 Bug: angleproject:4599 Bug: b/157672184 Change-Id: I5c73ca4d4eba7f1ecea01467ae887bae7f2d27fd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2231803 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5abc0c56
......@@ -180,6 +180,9 @@ class DataCounters final : angle::NonCopyable
using BufferSet = std::set<gl::BufferID>;
using BufferCalls = std::map<gl::BufferID, std::vector<CallCapture>>;
// true means mapped, false means unmapped
using BufferMapStatusMap = std::map<gl::BufferID, bool>;
// Helper to track resource changes during the capture
class ResourceTracker final : angle::NonCopyable
{
......@@ -189,6 +192,8 @@ class ResourceTracker final : angle::NonCopyable
BufferCalls &getBufferRegenCalls() { return mBufferRegenCalls; }
BufferCalls &getBufferRestoreCalls() { return mBufferRestoreCalls; }
BufferCalls &getBufferMapCalls() { return mBufferMapCalls; }
BufferCalls &getBufferUnmapCalls() { return mBufferUnmapCalls; }
BufferSet &getStartingBuffers() { return mStartingBuffers; }
BufferSet &getNewBuffers() { return mNewBuffers; }
......@@ -198,12 +203,35 @@ class ResourceTracker final : angle::NonCopyable
void setGennedBuffer(gl::BufferID id);
void setDeletedBuffer(gl::BufferID id);
void setBufferModified(gl::BufferID id);
void setBufferMapped(gl::BufferID id);
void setBufferUnmapped(gl::BufferID id);
const bool &getStartingBuffersMappedCurrent(gl::BufferID id)
{
return mStartingBuffersMappedCurrent[id];
}
const bool &getStartingBuffersMappedInitial(gl::BufferID id)
{
return mStartingBuffersMappedInitial[id];
}
void setStartingBufferMapped(gl::BufferID id, bool mapped)
{
// Track the current state (which will change throughout the trace)
mStartingBuffersMappedCurrent[id] = mapped;
// And the initial state, to compare during frame loop reset
mStartingBuffersMappedInitial[id] = mapped;
}
private:
// Buffer regen calls will delete and gen a buffer
BufferCalls mBufferRegenCalls;
// Buffer restore calls will restore the contents of a buffer
BufferCalls mBufferRestoreCalls;
// Buffer map calls will map a buffer with correct offset, length, and access flags
BufferCalls mBufferMapCalls;
// Buffer unmap calls will bind and unmap a given buffer
BufferCalls mBufferUnmapCalls;
// Starting buffers include all the buffers created during setup for MEC
BufferSet mStartingBuffers;
......@@ -213,6 +241,11 @@ class ResourceTracker final : angle::NonCopyable
BufferSet mBuffersToRegen;
// Buffers to restore include any starting buffers with contents modified during the run
BufferSet mBuffersToRestore;
// Whether a given buffer was mapped at the start of the trace
BufferMapStatusMap mStartingBuffersMappedInitial;
// The status of buffer mapping throughout the trace, modified with each Map/Unmap call
BufferMapStatusMap mStartingBuffersMappedCurrent;
};
// Used by the CPP replay to filter out unnecessary code.
......@@ -245,6 +278,14 @@ class FrameCapture final : angle::NonCopyable
bool isCapturing() const;
void replay(gl::Context *context);
void trackBufferMapping(CallCapture *call,
gl::BufferID id,
GLintptr offset,
GLsizeiptr length,
GLbitfield accessFlags);
ResourceTracker &getResouceTracker() { return mResourceTracker; }
private:
void captureClientArraySnapshot(const gl::Context *context,
size_t vertexCount,
......
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