Skip to content

Commit

Permalink
Move hWnd association for GPU-GDI blt model presents to token propaga…
Browse files Browse the repository at this point in the history
…tion instead of creation. This aligns to when DWM receives the token and decides which frame should be composed into a window, and is where similar logic already existed for composition buffer presents. This was causing PresentMon's latencies for this mode to be off by ~1 VSync for some apps.

Also fixed several regressions in ETL file processing introduced by refactoring:
1. ETL file is not mutually exclusive with filename.
2. ETL files can cause the ETW thread to exit without an external signal. This was triggering asserts. When this happens, the app should exit cleanly (at least, that's how it used to behave).
3. The start time for a trace session was uninitialized and caused CSV files to have impossible "time in second" values for each frame.
  • Loading branch information
jenatali authored and jdm3 committed May 11, 2017
1 parent 5734f65 commit ce8686f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ SOFTWARE.
## Command line options

```html
Capture target options (use one of the following):
Capture target options:
-captureall Record all processes (default).
-process_name [exe name] Record specific process specified by name.
-process_id [integer] Record specific process specified by ID.
-etl_file [path] Consume events from an ETL file instead of a running process.

Output options:
-no_csv Do not create any output file.
-output_file [path] Write CSV output to specified path. Otherwise, the default is
PresentMon-PROCESSNAME-TIME.csv.

Control and filtering options:
-etl_file [path] Consume events from an ETL file instead of a running process.
-scroll_toggle Only record events while scroll lock is enabled.
-scroll_indicator Set scroll lock while recording events.
-hotkey [key] Use specified key to start and stop recording, writing to a
Expand Down
9 changes: 4 additions & 5 deletions source/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ void PrintHelp()
fprintf(stderr,
"PresentMon version 1.1.0\n"
"\n"
"Capture target options (use one of the following):\n"
"Capture target options:\n"
" -captureall Record all processes (default).\n"
" -process_name [exe name] Record specific process specified by name.\n"
" -process_id [integer] Record specific process specified by ID.\n"
" -etl_file [path] Consume events from an ETL file instead of a running process.\n"
"\n"
"Output options:\n"
" -no_csv Do not create any output file.\n"
" -output_file [path] Write CSV output to specified path. Otherwise, the default is\n"
" PresentMon-PROCESSNAME-TIME.csv.\n"
"\n"
"Control and filtering options:\n"
" -etl_file [path] Consume events from an ETL file instead of a running process.\n"
" -scroll_toggle Only record events while scroll lock is enabled.\n"
" -scroll_indicator Set scroll lock while recording events.\n"
" -hotkey [key] Use specified key to start and stop recording, writing to a\n"
Expand Down Expand Up @@ -303,9 +303,8 @@ bool ParseCommandLine(int argc, char** argv, CommandLineArgs* args)

// Validate command line arguments
if (((args->mTargetProcessName == nullptr) ? 0 : 1) +
((args->mTargetPid <= 0 ) ? 0 : 1) +
((args->mEtlFileName == nullptr) ? 0 : 1) > 1) {
fprintf(stderr, "error: only specify one of -captureall, -process_name, -process_id, or -etl_file.\n");
((args->mTargetPid <= 0 ) ? 0 : 1) > 1) {
fprintf(stderr, "error: only specify one of -captureall, -process_name, or -process_id.\n");
PrintHelp();
return false;
}
Expand Down
6 changes: 5 additions & 1 deletion source/PresentMon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,11 @@ void EtwConsumingThread(const CommandLineArgs& args)
}

if (doneProcessingEvents) {
assert(EtwThreadsShouldQuit());
assert(EtwThreadsShouldQuit() || args.mEtlFileName);
if (!EtwThreadsShouldQuit()) {
PostStopRecording();
PostQuitProcess();
}
break;
}

Expand Down
12 changes: 6 additions & 6 deletions source/PresentMonTraceConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,6 @@ void PMTraceConsumer::OnDXGKrnlEvent(PEVENT_RECORD pEventRecord)
CompletePresent(eventIter->second);
}

if (eventIter->second->PresentMode == PresentMode::Composed_Copy_GPU_GDI) {
// Manipulate the map here
// When DWM is ready to present, we'll query for the most recent blt targeting this window and take it out of the map
mPresentByWindow[hWnd] = eventIter->second;
}

// For all other events, just remember the hWnd, we might need it later
eventIter->second->Hwnd = hWnd;
eventIter->second->SeenDxgkPresent = true;
Expand Down Expand Up @@ -433,6 +427,12 @@ void PMTraceConsumer::OnDXGKrnlEvent(PEVENT_RECORD pEventRecord)
mPresentsWaitingForDWM.emplace_back(eventIter->second);
}

if (eventIter->second->PresentMode == PresentMode::Composed_Copy_GPU_GDI) {
// Manipulate the map here
// When DWM is ready to present, we'll query for the most recent blt targeting this window and take it out of the map
mPresentByWindow[eventIter->second->Hwnd] = eventIter->second;
}

mDxgKrnlPresentHistoryTokens.erase(eventIter);
break;
}
Expand Down
1 change: 1 addition & 0 deletions source/TraceSession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct TraceSession {
TraceSession()
: sessionHandle_(0)
, traceHandle_(INVALID_PROCESSTRACE_HANDLE)
, startTime_(0)
, pmData_(nullptr)
, pmTraceConsumer_(nullptr)
{
Expand Down

0 comments on commit ce8686f

Please sign in to comment.