From 3ba06859b6a420a55ff97f66db340a696d3593bd Mon Sep 17 00:00:00 2001 From: nikkumaar Date: Thu, 10 Apr 2025 17:18:13 +0530 Subject: [PATCH] Fix frames marked as discarded incorrectly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The way FrameView/PresentMon marks the completion of frames is to first just mark frames as 'Presented' when it receives MMIO MPO flip call and then once Win32k providers’ (running within DWM process) TokenStateChange(TokenState::Discarded) event is received it is marked as completed. 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. --- PresentData/PresentMonTraceConsumer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PresentData/PresentMonTraceConsumer.cpp b/PresentData/PresentMonTraceConsumer.cpp index edd5f8fa..5921fce8 100644 --- a/PresentData/PresentMonTraceConsumer.cpp +++ b/PresentData/PresentMonTraceConsumer.cpp @@ -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" @@ -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 first 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(prevPresent)) { + prevPresent->FinalState = PresentResult::Discarded; + } + RemovePresentFromSubmitSequenceIdTracking(prevPresent); } }