Commit 54bd0005 by Cody Northrop Committed by Commit Bot

Capture/Replay: Add Query Object support to mid-execution capture

Test: Manhattan mid-execution capture working Bug: angleproject:3662 Bug: angleproject:4091 Change-Id: I3e0d0fb1692b1fda08fd057d528f70aa5e50ef1c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2070900Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent dfae826d
...@@ -324,6 +324,8 @@ class StateCache final : angle::NonCopyable ...@@ -324,6 +324,8 @@ class StateCache final : angle::NonCopyable
mCachedIntegerVertexAttribTypesValidation; mCachedIntegerVertexAttribTypesValidation;
}; };
using QueryMap = ResourceMap<Query, QueryID>;
class Context final : public egl::LabeledObject, angle::NonCopyable, public angle::ObserverInterface class Context final : public egl::LabeledObject, angle::NonCopyable, public angle::ObserverInterface
{ {
public: public:
...@@ -587,6 +589,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -587,6 +589,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
angle::FrameCapture *getFrameCapture() { return mFrameCapture.get(); } angle::FrameCapture *getFrameCapture() { return mFrameCapture.get(); }
const QueryMap &getQueriesForCapture() const { return mQueryMap; }
void onPostSwap() const; void onPostSwap() const;
private: private:
...@@ -672,7 +676,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -672,7 +676,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
ResourceMap<FenceNV, FenceNVID> mFenceNVMap; ResourceMap<FenceNV, FenceNVID> mFenceNVMap;
HandleAllocator mFenceNVHandleAllocator; HandleAllocator mFenceNVHandleAllocator;
ResourceMap<Query, QueryID> mQueryMap; QueryMap mQueryMap;
HandleAllocator mQueryHandleAllocator; HandleAllocator mQueryHandleAllocator;
ResourceMap<VertexArray, VertexArrayID> mVertexArrayMap; ResourceMap<VertexArray, VertexArrayID> mVertexArrayMap;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "common/system_utils.h" #include "common/system_utils.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/Query.h"
#include "libANGLE/ResourceMap.h"
#include "libANGLE/Shader.h" #include "libANGLE/Shader.h"
#include "libANGLE/VertexArray.h" #include "libANGLE/VertexArray.h"
#include "libANGLE/capture_gles_2_0_autogen.h" #include "libANGLE/capture_gles_2_0_autogen.h"
...@@ -1210,6 +1212,21 @@ bool IsDefaultCurrentValue(const gl::VertexAttribCurrentValueData &currentValue) ...@@ -1210,6 +1212,21 @@ bool IsDefaultCurrentValue(const gl::VertexAttribCurrentValueData &currentValue)
currentValue.Values.FloatValues[2] == 0.0f && currentValue.Values.FloatValues[3] == 1.0f; currentValue.Values.FloatValues[2] == 0.0f && currentValue.Values.FloatValues[3] == 1.0f;
} }
bool IsQueryActive(const gl::State &glState, gl::QueryID &queryID)
{
const gl::ActiveQueryMap &activeQueries = glState.getActiveQueriesForCapture();
for (const auto &activeQueryIter : activeQueries)
{
const gl::Query *activeQuery = activeQueryIter.get();
if (activeQuery && activeQuery->id() == queryID)
{
return true;
}
}
return false;
}
void Capture(std::vector<CallCapture> *setupCalls, CallCapture &&call) void Capture(std::vector<CallCapture> *setupCalls, CallCapture &&call)
{ {
setupCalls->emplace_back(std::move(call)); setupCalls->emplace_back(std::move(call));
...@@ -1801,6 +1818,31 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -1801,6 +1818,31 @@ void CaptureMidExecutionSetup(const gl::Context *context,
// TODO(http://anglebug.com/3662): ES 3.x objects. // TODO(http://anglebug.com/3662): ES 3.x objects.
// Create existing queries
const gl::QueryMap &queryMap = context->getQueriesForCapture();
for (const auto &queryIter : queryMap)
{
ASSERT(queryIter.first);
gl::QueryID queryID = {queryIter.first};
cap(CaptureGenQueries(replayState, true, 1, &queryID));
MaybeCaptureUpdateResourceIDs(setupCalls);
if (queryIter.second)
{
gl::QueryType queryType = queryIter.second->getType();
// Begin the query to generate the object
cap(CaptureBeginQuery(replayState, true, queryType, queryID));
// End the query if it was not active
if (!IsQueryActive(apiState, queryID))
{
cap(CaptureEndQuery(replayState, true, queryType));
}
}
}
// Capture GL Context states. // Capture GL Context states.
// TODO(http://anglebug.com/3662): Complete state capture. // TODO(http://anglebug.com/3662): Complete state capture.
auto capCap = [cap, &replayState](GLenum capEnum, bool capValue) { auto capCap = [cap, &replayState](GLenum capEnum, bool capValue) {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "libANGLE/Path.h" #include "libANGLE/Path.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/ProgramPipeline.h" #include "libANGLE/ProgramPipeline.h"
#include "libANGLE/Query.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/Sampler.h" #include "libANGLE/Sampler.h"
#include "libANGLE/Semaphore.h" #include "libANGLE/Semaphore.h"
...@@ -590,5 +591,4 @@ Semaphore *SemaphoreManager::getSemaphore(SemaphoreID handle) const ...@@ -590,5 +591,4 @@ Semaphore *SemaphoreManager::getSemaphore(SemaphoreID handle) const
{ {
return mSemaphores.query(handle); return mSemaphores.query(handle);
} }
} // namespace gl } // namespace gl
...@@ -365,7 +365,6 @@ class SemaphoreManager : public ResourceManagerBase<HandleAllocator> ...@@ -365,7 +365,6 @@ class SemaphoreManager : public ResourceManagerBase<HandleAllocator>
ResourceMap<Semaphore, SemaphoreID> mSemaphores; ResourceMap<Semaphore, SemaphoreID> mSemaphores;
}; };
} // namespace gl } // namespace gl
#endif // LIBANGLE_RESOURCEMANAGER_H_ #endif // LIBANGLE_RESOURCEMANAGER_H_
...@@ -61,6 +61,7 @@ using BufferBindingMap = angle::PackedEnumMap<BufferBinding, T>; ...@@ -61,6 +61,7 @@ using BufferBindingMap = angle::PackedEnumMap<BufferBinding, T>;
using BoundBufferMap = BufferBindingMap<BindingPointer<Buffer>>; using BoundBufferMap = BufferBindingMap<BindingPointer<Buffer>>;
using TextureBindingVector = std::vector<BindingPointer<Texture>>; using TextureBindingVector = std::vector<BindingPointer<Texture>>;
using TextureBindingMap = angle::PackedEnumMap<TextureType, TextureBindingVector>; using TextureBindingMap = angle::PackedEnumMap<TextureType, TextureBindingVector>;
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
class State : angle::NonCopyable class State : angle::NonCopyable
{ {
...@@ -715,6 +716,8 @@ class State : angle::NonCopyable ...@@ -715,6 +716,8 @@ class State : angle::NonCopyable
return *mShaderProgramManager; return *mShaderProgramManager;
} }
const ActiveQueryMap &getActiveQueriesForCapture() const { return mActiveQueries; }
private: private:
friend class Context; friend class Context;
...@@ -875,7 +878,6 @@ class State : angle::NonCopyable ...@@ -875,7 +878,6 @@ class State : angle::NonCopyable
// It would be nice to merge the image and observer binding. Same for textures. // It would be nice to merge the image and observer binding. Same for textures.
std::vector<ImageUnit> mImageUnits; std::vector<ImageUnit> mImageUnits;
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
ActiveQueryMap mActiveQueries; ActiveQueryMap mActiveQueries;
// Stores the currently bound buffer for each binding point. It has an entry for the element // Stores the currently bound buffer for each binding point. It has an entry for the element
......
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