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
mCachedIntegerVertexAttribTypesValidation;
};
using QueryMap = ResourceMap<Query, QueryID>;
class Context final : public egl::LabeledObject, angle::NonCopyable, public angle::ObserverInterface
{
public:
......@@ -587,6 +589,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
angle::FrameCapture *getFrameCapture() { return mFrameCapture.get(); }
const QueryMap &getQueriesForCapture() const { return mQueryMap; }
void onPostSwap() const;
private:
......@@ -672,7 +676,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
ResourceMap<FenceNV, FenceNVID> mFenceNVMap;
HandleAllocator mFenceNVHandleAllocator;
ResourceMap<Query, QueryID> mQueryMap;
QueryMap mQueryMap;
HandleAllocator mQueryHandleAllocator;
ResourceMap<VertexArray, VertexArrayID> mVertexArrayMap;
......
......@@ -19,6 +19,8 @@
#include "common/system_utils.h"
#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Query.h"
#include "libANGLE/ResourceMap.h"
#include "libANGLE/Shader.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/capture_gles_2_0_autogen.h"
......@@ -1210,6 +1212,21 @@ bool IsDefaultCurrentValue(const gl::VertexAttribCurrentValueData &currentValue)
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)
{
setupCalls->emplace_back(std::move(call));
......@@ -1801,6 +1818,31 @@ void CaptureMidExecutionSetup(const gl::Context *context,
// 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.
// TODO(http://anglebug.com/3662): Complete state capture.
auto capCap = [cap, &replayState](GLenum capEnum, bool capValue) {
......
......@@ -16,6 +16,7 @@
#include "libANGLE/Path.h"
#include "libANGLE/Program.h"
#include "libANGLE/ProgramPipeline.h"
#include "libANGLE/Query.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Sampler.h"
#include "libANGLE/Semaphore.h"
......@@ -590,5 +591,4 @@ Semaphore *SemaphoreManager::getSemaphore(SemaphoreID handle) const
{
return mSemaphores.query(handle);
}
} // namespace gl
......@@ -365,7 +365,6 @@ class SemaphoreManager : public ResourceManagerBase<HandleAllocator>
ResourceMap<Semaphore, SemaphoreID> mSemaphores;
};
} // namespace gl
#endif // LIBANGLE_RESOURCEMANAGER_H_
......@@ -61,6 +61,7 @@ using BufferBindingMap = angle::PackedEnumMap<BufferBinding, T>;
using BoundBufferMap = BufferBindingMap<BindingPointer<Buffer>>;
using TextureBindingVector = std::vector<BindingPointer<Texture>>;
using TextureBindingMap = angle::PackedEnumMap<TextureType, TextureBindingVector>;
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
class State : angle::NonCopyable
{
......@@ -715,6 +716,8 @@ class State : angle::NonCopyable
return *mShaderProgramManager;
}
const ActiveQueryMap &getActiveQueriesForCapture() const { return mActiveQueries; }
private:
friend class Context;
......@@ -875,7 +878,6 @@ class State : angle::NonCopyable
// It would be nice to merge the image and observer binding. Same for textures.
std::vector<ImageUnit> mImageUnits;
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
ActiveQueryMap mActiveQueries;
// 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