FrameCapture: Create default context reset calls

Add support for emitting default reset calls for some entrypoints
when recording a capture from the beginning.

Test: Lineage 2 Revolution MEC
Bug: angleproject:7741
Change-Id: I8e4e1184f3e3b68527a65283c459a43d135e95b4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3938442
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Cody Northrop <cnorthrop@google.com>
This commit is contained in:
Cody Northrop 2022-10-05 20:09:23 -06:00 коммит произвёл Angle LUCI CQ
Родитель b3b855d26c
Коммит 5bafe449e0
2 изменённых файлов: 51 добавлений и 10 удалений

Просмотреть файл

@ -1491,19 +1491,25 @@ void MaybeResetContextState(ReplayWriter &replayWriter,
std::stringstream &out, std::stringstream &out,
std::stringstream &header, std::stringstream &header,
ResourceTracker *resourceTracker, ResourceTracker *resourceTracker,
const gl::State &replayState, const gl::Context *context,
std::vector<uint8_t> *binaryData, std::vector<uint8_t> *binaryData,
const StateResetHelper &stateResetHelper) StateResetHelper &stateResetHelper)
{ {
// Check dirty states per entrypoint // Check dirty states per entrypoint
for (const EntryPoint &entryPoint : stateResetHelper.getDirtyEntryPoints()) for (const EntryPoint &entryPoint : stateResetHelper.getDirtyEntryPoints())
{ {
// Ensure we have calls to reset this entrypoint const CallResetMap *resetCalls = &stateResetHelper.getResetCalls();
ASSERT(stateResetHelper.getResetCalls().find(entryPoint) !=
stateResetHelper.getResetCalls().end()); // Create the default reset call for this entrypoint
if (resetCalls->find(entryPoint) == resetCalls->end())
{
// If we don't have any reset calls for these entrypoints, that means we started capture
// from the beginning, amd mid-execution capture was not invoked.
stateResetHelper.setDefaultResetCalls(context, entryPoint);
}
// Emit the calls // Emit the calls
for (const auto &call : stateResetHelper.getResetCalls().at(entryPoint)) for (const auto &call : resetCalls->at(entryPoint))
{ {
out << " "; out << " ";
WriteCppReplayForCall(call, replayWriter, out, header, binaryData); WriteCppReplayForCall(call, replayWriter, out, header, binaryData);
@ -7515,6 +7521,40 @@ ResourceTracker::~ResourceTracker() = default;
StateResetHelper::StateResetHelper() = default; StateResetHelper::StateResetHelper() = default;
StateResetHelper::~StateResetHelper() = default; StateResetHelper::~StateResetHelper() = default;
void StateResetHelper::setDefaultResetCalls(const gl::Context *context,
angle::EntryPoint entryPoint)
{
// Populate default reset calls for entrypoints to support looping to beginning
switch (entryPoint)
{
case angle::EntryPoint::GLUseProgram:
{
if (context->getActiveLinkedProgram() &&
context->getActiveLinkedProgram()->id().value != 0)
{
Capture(&mResetCalls[angle::EntryPoint::GLUseProgram],
gl::CaptureUseProgram(context->getState(), true, {0}));
}
break;
}
case angle::EntryPoint::GLBindVertexArray:
{
if (context->getState().getVertexArray()->id().value != 0)
{
VertexArrayCaptureFuncs vertexArrayFuncs(context->isGLES1());
Capture(&mResetCalls[angle::EntryPoint::GLBindVertexArray],
vertexArrayFuncs.bindVertexArray(context->getState(), true, {0}));
}
break;
}
default:
ERR() << "Unhandled entry point in setDefaultResetCalls: "
<< GetEntryPointName(entryPoint);
UNREACHABLE();
break;
}
}
void ResourceTracker::setDeletedFenceSync(GLsync sync) void ResourceTracker::setDeletedFenceSync(GLsync sync)
{ {
ASSERT(sync != nullptr); ASSERT(sync != nullptr);
@ -7919,7 +7959,7 @@ void FrameCaptureShared::writeCppReplayIndexFiles(const gl::Context *context,
void FrameCaptureShared::writeMainContextCppReplay(const gl::Context *context, void FrameCaptureShared::writeMainContextCppReplay(const gl::Context *context,
const std::vector<CallCapture> &setupCalls, const std::vector<CallCapture> &setupCalls,
const StateResetHelper &stateResetHelper) StateResetHelper &stateResetHelper)
{ {
ASSERT(mWindowSurfaceContextID == context->id()); ASSERT(mWindowSurfaceContextID == context->id());
@ -8145,7 +8185,7 @@ void FrameCaptureShared::writeMainContextCppReplay(const gl::Context *context,
// Now that we're back on the main context, reset any additional state // Now that we're back on the main context, reset any additional state
resetBodyStream << "\n // Reset main context state\n"; resetBodyStream << "\n // Reset main context state\n";
MaybeResetContextState(mReplayWriter, resetBodyStream, resetHeaderStream, &mResourceTracker, MaybeResetContextState(mReplayWriter, resetBodyStream, resetHeaderStream, &mResourceTracker,
context->getState(), &mBinaryData, stateResetHelper); context, &mBinaryData, stateResetHelper);
resetBodyStream << "}\n"; resetBodyStream << "}\n";

Просмотреть файл

@ -498,6 +498,8 @@ class StateResetHelper final : angle::NonCopyable
CallResetMap &getResetCalls() { return mResetCalls; } CallResetMap &getResetCalls() { return mResetCalls; }
const CallResetMap &getResetCalls() const { return mResetCalls; } const CallResetMap &getResetCalls() const { return mResetCalls; }
void setDefaultResetCalls(const gl::Context *context, angle::EntryPoint);
private: private:
// Dirty state per entry point // Dirty state per entry point
std::set<angle::EntryPoint> mDirtyEntryPoints; std::set<angle::EntryPoint> mDirtyEntryPoints;
@ -516,7 +518,6 @@ class FrameCapture final : angle::NonCopyable
void clearSetupCalls() { mSetupCalls.clear(); } void clearSetupCalls() { mSetupCalls.clear(); }
StateResetHelper &getStateResetHelper() { return mStateResetHelper; } StateResetHelper &getStateResetHelper() { return mStateResetHelper; }
const StateResetHelper &getStateResetHelper() const { return mStateResetHelper; }
void reset(); void reset();
@ -780,7 +781,7 @@ class FrameCaptureShared final : angle::NonCopyable
void writeCppReplayIndexFiles(const gl::Context *context, bool writeResetContextCall); void writeCppReplayIndexFiles(const gl::Context *context, bool writeResetContextCall);
void writeMainContextCppReplay(const gl::Context *context, void writeMainContextCppReplay(const gl::Context *context,
const std::vector<CallCapture> &setupCalls, const std::vector<CallCapture> &setupCalls,
const StateResetHelper &StateResetHelper); StateResetHelper &StateResetHelper);
void captureClientArraySnapshot(const gl::Context *context, void captureClientArraySnapshot(const gl::Context *context,
size_t vertexCount, size_t vertexCount,