Skip to content

Commit ab4a3c6

Browse files
authored
Merge pull request #522 from GameTechDev/bug/complete-lost-present
Lost Present Update
2 parents 26beab6 + d2c32fa commit ab4a3c6

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

PresentData/PresentMonTraceConsumer.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,34 @@ void PMTraceConsumer::RemoveLostPresent(std::shared_ptr<PresentEvent> p)
20262026
{
20272027
VerboseTraceBeforeModifyingPresent(p.get());
20282028
p->IsLost = true;
2029-
CompletePresent(p);
2029+
2030+
if (p->IsCompleted) {
2031+
// Present is already completed but lost - simulate what Present_Stop would do
2032+
if (p->WaitingForPresentStop) {
2033+
VerboseTraceBeforeModifyingPresent(p.get());
2034+
p->WaitingForPresentStop = false;
2035+
2036+
// Remove from thread tracking since Present_Stop won't come
2037+
auto ii = mPresentByThreadId.find(p->ThreadId);
2038+
if (ii != mPresentByThreadId.end() && ii->second == p) {
2039+
mPresentByThreadId.erase(ii);
2040+
}
2041+
if (p->DriverThreadId != 0) {
2042+
auto jj = mPresentByThreadId.find(p->DriverThreadId);
2043+
if (jj != mPresentByThreadId.end() && jj->second == p) {
2044+
mPresentByThreadId.erase(jj);
2045+
}
2046+
}
2047+
2048+
// Make ready for dequeue
2049+
UpdateReadyCount(true);
2050+
}
2051+
// If not waiting for Present_Stop, it should already be cleaned up properly
2052+
}
2053+
else {
2054+
// Present is not completed yet - complete it normally
2055+
CompletePresent(p);
2056+
}
20302057
}
20312058

20322059
void PMTraceConsumer::CompletePresent(std::shared_ptr<PresentEvent> const& p)

PresentMon/OutputThread.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,15 @@ static void ProcessEvents(
986986
// Handle any process events that occurred before this present
987987
if (checkProcessTime) {
988988
while ((*processEvents)[processEventIndex].QpcTime < presentTime) {
989+
auto& processEvent = (*processEvents)[processEventIndex];
990+
991+
// If this is a termination event for the same process as the current present,
992+
// skip processing this termination to avoid removing the process info we need
993+
if (!processEvent.IsStartEvent && processEvent.ProcessId == presentEvent->ProcessId) {
994+
// Don't process this termination yet - we have a present from this process to handle first
995+
break;
996+
}
997+
989998
ProcessProcessEvent((*processEvents)[processEventIndex]);
990999
processEventIndex += 1;
9911000
if (processEventIndex == processEventCount) {

0 commit comments

Comments
 (0)