Skip to content

Commit

Permalink
Merge branch 'public' into installer_update
Browse files Browse the repository at this point in the history
  • Loading branch information
markgalvan-intel committed Oct 11, 2023
2 parents f6443de + f177a71 commit df9d690
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion IntelPresentMon/AppCef/source/util/async/BrowseReadSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<wchar_t>{ file },
Expand Down
2 changes: 1 addition & 1 deletion IntelPresentMon/AppCef/source/util/async/BrowseStoreSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion IntelPresentMon/Core/source/infra/util/FolderResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PresentMon/LateStageReprojectionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void UpdateConsole(std::unordered_map<uint32_t, ProcessInfo> 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,
Expand Down
29 changes: 12 additions & 17 deletions PresentMon/OutputThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -233,7 +228,7 @@ static void HandleTerminatedProcess(uint32_t processId)
}
}

gProcesses.erase(iter);
gProcesses.erase(std::move(iter));
}

static void UpdateProcesses(std::vector<ProcessEvent> const& processEvents, std::vector<std::pair<uint32_t, uint64_t>>* terminatedProcesses)
Expand Down
24 changes: 15 additions & 9 deletions Tests/PresentMon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
16 changes: 9 additions & 7 deletions Tests/PresentMonTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit df9d690

Please sign in to comment.