Skip to content

Commit 4c15e86

Browse files
Merge pull request #529 from GameTechDev/bug/updated-prune-logic
Prevent pruning of DWM.exe swap chains with address 0x0
2 parents c7e2a9a + b77a76e commit 4c15e86

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

PresentMon/OutputThread.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
#include "PresentMon.hpp"
66
#include "../IntelPresentMon/CommonUtilities/Math.h"
7+
#include "../IntelPresentMon/CommonUtilities/str/String.h"
78

89
#include <algorithm>
910
#include <shlwapi.h>
1011
#include <thread>
1112

13+
using namespace pmon;
14+
1215
static std::thread gThread;
1316
static bool gQuit = false;
1417

@@ -838,11 +841,22 @@ static void PruneOldSwapChainData(
838841

839842
for (auto& pair : gProcesses) {
840843
auto processInfo = &pair.second;
844+
845+
// Check if this is DWM process
846+
const bool isDwmProcess =
847+
util::str::ToLower(processInfo->mModuleName).contains(L"dwm.exe");
848+
841849
for (auto ii = processInfo->mSwapChain.begin(), ie = processInfo->mSwapChain.end(); ii != ie; ) {
850+
auto swapChainAddress = ii->first;
842851
auto chain = &ii->second;
843-
if (chain->mLastPresent && chain->mLastPresent->PresentStartTime < minTimestamp) {
852+
853+
// Don't prune DWM swap chains with address 0x0
854+
bool shouldSkipPruning = isDwmProcess && swapChainAddress == 0x0;
855+
856+
if (!shouldSkipPruning && chain->mLastPresent && chain->mLastPresent->PresentStartTime < minTimestamp) {
844857
ii = processInfo->mSwapChain.erase(ii);
845-
} else {
858+
}
859+
else {
846860
++ii;
847861
}
848862
}

0 commit comments

Comments
 (0)