diff --git a/IntelPresentMon/AppCef/source/util/async/BrowseReadSpec.h b/IntelPresentMon/AppCef/source/util/async/BrowseReadSpec.h index 4a2eeb12..afb84e4d 100644 --- a/IntelPresentMon/AppCef/source/util/async/BrowseReadSpec.h +++ b/IntelPresentMon/AppCef/source/util/async/BrowseReadSpec.h @@ -40,7 +40,7 @@ namespace p2c::client::util::async }; std::wstring payload; - if (GetOpenFileNameW(&ofn) && wcsnlen_s(pathBuffer, sizeof(pathBuffer)) > 0) { + if (GetOpenFileNameW(&ofn) && wcsnlen_s(pathBuffer, std::size(pathBuffer)) > 0) { std::wifstream file{ pathBuffer }; payload = std::wstring( std::istreambuf_iterator{ file }, diff --git a/IntelPresentMon/AppCef/source/util/async/BrowseStoreSpec.h b/IntelPresentMon/AppCef/source/util/async/BrowseStoreSpec.h index 333ee314..2653d736 100644 --- a/IntelPresentMon/AppCef/source/util/async/BrowseStoreSpec.h +++ b/IntelPresentMon/AppCef/source/util/async/BrowseStoreSpec.h @@ -43,7 +43,7 @@ namespace p2c::client::util::async bool failed = false; // try to write the file to disk - if (confirmed && wcsnlen_s(pathBuffer, sizeof(pathBuffer)) > 0) { + if (confirmed && wcsnlen_s(pathBuffer, std::size(pathBuffer)) > 0) { std::wofstream file{ pathBuffer }; file << pArgObj->GetDictionary()->GetString("payload").ToWString(); failed = !file.good(); diff --git a/IntelPresentMon/Core/source/infra/util/FolderResolver.cpp b/IntelPresentMon/Core/source/infra/util/FolderResolver.cpp index 4faf2917..c1b59ecb 100644 --- a/IntelPresentMon/Core/source/infra/util/FolderResolver.cpp +++ b/IntelPresentMon/Core/source/infra/util/FolderResolver.cpp @@ -70,7 +70,7 @@ namespace p2c::infra::util } else { - appPath = std::filesystem::current_path().wstring(); + docPath = std::filesystem::current_path().wstring(); } // TODO: this really doesn't belong here, but here it stays until time for something saner diff --git a/PresentMon/LateStageReprojectionData.cpp b/PresentMon/LateStageReprojectionData.cpp index 6847007b..761d2168 100644 --- a/PresentMon/LateStageReprojectionData.cpp +++ b/PresentMon/LateStageReprojectionData.cpp @@ -330,7 +330,7 @@ void UpdateConsole(std::unordered_map const& activeProces ConsolePrint(" %.2lf ms/frame (%.1lf fps", 1000.0 / fps, fps); } - ConsolePrintLn(", %.1lf%% of Compositor frame rate)", double(historySize - runtimeStats.mAppMissedFrames) / (historySize) * 100.0f); + ConsolePrintLn(", %.1lf%% of Compositor frame rate)", historySize == 0 ? 0.0 : double(historySize - runtimeStats.mAppMissedFrames) / (historySize) * 100.0); ConsolePrintLn(" Missed Present: %Iu total in last %.1lf seconds (%Iu total observed)", runtimeStats.mAppMissedFrames, diff --git a/PresentMon/OutputThread.cpp b/PresentMon/OutputThread.cpp index c439f632..66fce329 100644 --- a/PresentMon/OutputThread.cpp +++ b/PresentMon/OutputThread.cpp @@ -32,26 +32,21 @@ void SetOutputRecordingState(bool record) { auto const& args = GetCommandLineArgs(); - if (gIsRecording == record) { - return; - } + EnterCriticalSection(&gRecordingToggleCS); - // When capturing from an ETL file, just use the current recording state. - // It's not clear how best to map realtime to ETL QPC time, and there - // aren't any realtime cues in this case. - if (args.mEtlFileName != nullptr) { - EnterCriticalSection(&gRecordingToggleCS); + if (gIsRecording != record) { gIsRecording = record; - LeaveCriticalSection(&gRecordingToggleCS); - return; - } - uint64_t qpc = 0; - QueryPerformanceCounter((LARGE_INTEGER*) &qpc); + // When capturing from an ETL file, just use the current recording state. + // It's not clear how best to map realtime to ETL QPC time, and there + // aren't any realtime cues in this case. + if (args.mEtlFileName == nullptr) { + uint64_t qpc = 0; + QueryPerformanceCounter((LARGE_INTEGER*) &qpc); + gRecordingToggleHistory.emplace_back(qpc); + } + } - EnterCriticalSection(&gRecordingToggleCS); - gRecordingToggleHistory.emplace_back(qpc); - gIsRecording = record; LeaveCriticalSection(&gRecordingToggleCS); } @@ -233,7 +228,7 @@ static void HandleTerminatedProcess(uint32_t processId) } } - gProcesses.erase(iter); + gProcesses.erase(std::move(iter)); } static void UpdateProcesses(std::vector const& processEvents, std::vector>* terminatedProcesses) diff --git a/Tests/PresentMon.cpp b/Tests/PresentMon.cpp index a9924c54..387d1302 100644 --- a/Tests/PresentMon.cpp +++ b/Tests/PresentMon.cpp @@ -132,18 +132,24 @@ bool PresentMonCsv::Open(char const* file, int line, std::wstring const& path) for (size_t i = 0, n = cols_.size(); i < n; ++i) { auto h = FindHeader(cols_[i]); - if (h == UnknownHeader) { + switch (h) { + case KnownHeaderCount: + case UnknownHeader: AddTestFailure(Convert(path_).c_str(), (int) line_, "Unrecognised column: %s", cols_[i]); - } else if (headerColumnIndex_[(size_t) h] != SIZE_MAX) { - AddTestFailure(Convert(path_).c_str(), (int) line_, "Duplicate column: %s", cols_[i]); - } else { - headerColumnIndex_[(size_t) h] = i; - - for (auto& hg : headerGroups) { - if (hg.Check(h)) { - break; + break; + default: + if (headerColumnIndex_[(size_t) h] != SIZE_MAX) { + AddTestFailure(Convert(path_).c_str(), (int) line_, "Duplicate column: %s", cols_[i]); + } else { + headerColumnIndex_[(size_t) h] = i; + + for (auto& hg : headerGroups) { + if (hg.Check(h)) { + break; + } } } + break; } } diff --git a/Tests/PresentMonTests.cpp b/Tests/PresentMonTests.cpp index 362fcb94..a6b49f85 100644 --- a/Tests/PresentMonTests.cpp +++ b/Tests/PresentMonTests.cpp @@ -8,20 +8,22 @@ bool EnsureDirectoryCreated(std::wstring path) { - auto dir = path.c_str(); for (auto i = path.find(L'\\');; i = path.find(L'\\', i + 1)) { - if (i != std::wstring::npos) { - path[i] = L'\0'; + std::wstring dir; + if (i == std::wstring::npos) { + dir = path; + } else { + dir = path.substr(0, i); } - auto attr = GetFileAttributes(dir); + auto attr = GetFileAttributes(dir.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { - if (!CreateDirectory(dir, NULL)) { - fprintf(stderr, "error: failed to create directory: %ls\n", dir); + if (!CreateDirectory(dir.c_str(), NULL)) { + fprintf(stderr, "error: failed to create directory: %ls\n", dir.c_str()); return false; } } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) { - fprintf(stderr, "error: existing path is not a directory: %ls\n", dir); + fprintf(stderr, "error: existing path is not a directory: %ls\n", dir.c_str()); return false; }