Skip to content

Fix frames that are marked as discarded incorrectly #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion PresentData/PresentMonTraceConsumer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (C) 2017-2024 Intel Corporation
// Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved
// SPDX-License-Identifier: MIT

#include "PresentMonTraceConsumer.hpp"
Expand Down Expand Up @@ -1568,7 +1569,16 @@ void PMTraceConsumer::HandleWin32kEvent(EVENT_RECORD* pEventRecord)
// collisions during lookup for events that don't reference
// a context.
VerboseTraceBeforeModifyingPresent(prevPresent.get());
prevPresent->FinalState = PresentResult::Discarded;

// In certain cases like when there are short bursts of presents,
// we get multiple back to back flips and token tracking thread
// ends up marking the second frame in the burst as dropped.
// To fix this issue, we mark the frame as discarded only if
// the frame already doesn’t have valid ScreenTime.
if (!HasScreenTime(hWndIter->second)) {
prevPresent->FinalState = PresentResult::Discarded;
}

RemovePresentFromSubmitSequenceIdTracking(prevPresent);
}
}
Expand Down