MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / PruneOldSwapChainData

Function PruneOldSwapChainData

PresentMon/OutputThread.cpp:247–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247static void PruneOldSwapChainData(
248 PMTraceSession const& pmSession,
249 uint64_t latestTimestamp)
250{
251 // sometimes we arrive here after skipping all frame events in the processing loop,
252 // in which case we don't have a valid timestamp for the latest frame and should not
253 // attempt to do any pruning during this pass
254 if (latestTimestamp == 0) {
255 return;
256 }
257
258 auto minTimestamp = latestTimestamp - pmSession.MilliSecondsDeltaToTimestamp(4000.0);
259
260 for (auto& pair : gProcesses) {
261 auto processInfo = &pair.second;
262
263 // Check if this is DWM process
264 const auto processNameLower = util::str::ToLower(processInfo->mModuleName);
265 const bool isDwmProcess = (processNameLower.find(L"dwm.exe") != std::wstring::npos);
266
267 for (auto ii = processInfo->mSwapChain.begin(), ie = processInfo->mSwapChain.end(); ii != ie; ) {
268 auto swapChainAddress = ii->first;
269 auto chain = &ii->second;
270
271 // Don't prune DWM swap chains with address 0x0
272 bool shouldSkipPruning = isDwmProcess && swapChainAddress == 0x0;
273 bool shouldPrune = false;
274 if (!shouldSkipPruning) {
275 shouldPrune = chain->mUnifiedSwapChain.IsPrunableBefore(minTimestamp);
276 }
277
278 if (shouldPrune) {
279 ii = processInfo->mSwapChain.erase(ii);
280 }
281 else {
282 ++ii;
283 }
284 }
285 }
286}
287
288static void QueryProcessName(uint32_t processId, ProcessInfo* info)
289{

Callers 1

ProcessEventsFunction · 0.85

Calls 5

ToLowerFunction · 0.85
IsPrunableBeforeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected