| 294 | bool TRACK_PRESENTMON, |
| 295 | bool TRACK_PCL> |
| 296 | void CALLBACK EventRecordCallback(EVENT_RECORD* pEventRecord) |
| 297 | { |
| 298 | auto session = (PMTraceSession*) pEventRecord->UserContext; |
| 299 | const auto& hdr = pEventRecord->EventHeader; |
| 300 | |
| 301 | PMTraceConsumer::EventProcessingScope processingScope(*session->mPMConsumer); |
| 302 | if (!processingScope) { |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | if constexpr (IS_REALTIME_SESSION) { |
| 307 | session->ProcessEtwEventLatencyStats(hdr.TimeStamp.QuadPart); |
| 308 | } |
| 309 | |
| 310 | if constexpr (!IS_REALTIME_SESSION) { |
| 311 | if (session->mStartTimestamp.QuadPart == 0) { |
| 312 | session->mStartTimestamp = hdr.TimeStamp; |
| 313 | // one-time capture of timing info needed to calibrate ETL replay event pacing |
| 314 | if (session->mPMConsumer->mPaceEvents || session->mPMConsumer->mRetimeEvents) { |
| 315 | session->mPacingActualLogStartTimestamp = hdr.TimeStamp.QuadPart; |
| 316 | session->mPacingRealtimeStartTimestamp = pmon::util::GetCurrentTimestamp(); |
| 317 | session->mPacingQpcPeriod = pmon::util::GetTimestampPeriodSeconds(); |
| 318 | session->mPacingQpcOffset = session->mPacingRealtimeStartTimestamp - hdr.TimeStamp.QuadPart; |
| 319 | // override the processing start timestamp with the adjusted value |
| 320 | session->mStartTimestamp.QuadPart = session->mPacingRealtimeStartTimestamp; |
| 321 | if (session->mPMConsumer->mRetimeEvents) { |
| 322 | // perform the first adjustment of the event header (no wait or calculation necessary) |
| 323 | pEventRecord->EventHeader.TimeStamp.QuadPart = session->mPacingRealtimeStartTimestamp; |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | else if (session->mPMConsumer->mPaceEvents || session->mPMConsumer->mRetimeEvents) { |
| 328 | const auto currentQpc = pmon::util::GetCurrentTimestamp(); |
| 329 | const auto adjustedTimestamp = hdr.TimeStamp.QuadPart + session->mPacingQpcOffset; |
| 330 | const auto delta = pmon::util::TimestampDeltaToSeconds(currentQpc, adjustedTimestamp, session->mPacingQpcPeriod); |
| 331 | if (session->mPMConsumer->mPaceEvents && delta > 0.001) { |
| 332 | session->mPacingWaiter.Wait(delta); |
| 333 | } |
| 334 | if (session->mPMConsumer->mRetimeEvents) { |
| 335 | pEventRecord->EventHeader.TimeStamp.QuadPart = adjustedTimestamp; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | VerboseTraceEvent(session->mPMConsumer, pEventRecord, &session->mPMConsumer->mMetadata); |
| 341 | |
| 342 | if (hdr.ProviderId == Microsoft_Windows_DxgKrnl::GUID) { |
| 343 | session->mPMConsumer->HandleDXGKEvent(pEventRecord); |
| 344 | return; |
| 345 | } |
| 346 | if (hdr.ProviderId == Microsoft_Windows_DXGI::GUID) { |
| 347 | session->mPMConsumer->HandleDXGIEvent(pEventRecord); |
| 348 | return; |
| 349 | } |
| 350 | if constexpr (TRACK_DISPLAY || TRACK_INPUT) { |
| 351 | if (hdr.ProviderId == Microsoft_Windows_Win32k::GUID) { |
| 352 | session->mPMConsumer->HandleWin32kEvent(pEventRecord); |
| 353 | return; |
nothing calls this directly
no test coverage detected