| 361 | } |
| 362 | |
| 363 | bool waitForAftermathDumps(int timeout) |
| 364 | { |
| 365 | if (!sInitialized) |
| 366 | return true; |
| 367 | |
| 368 | // DXGI_ERROR error notification is asynchronous to the NVIDIA display |
| 369 | // driver's GPU crash handling. Give the Nsight Aftermath GPU crash dump |
| 370 | // thread some time to do its work before terminating the process. |
| 371 | auto tdrTerminationTimeout = std::chrono::seconds(timeout); |
| 372 | auto tStart = std::chrono::steady_clock::now(); |
| 373 | auto tElapsed = std::chrono::milliseconds::zero(); |
| 374 | |
| 375 | GFSDK_Aftermath_CrashDump_Status status = GFSDK_Aftermath_CrashDump_Status_Unknown; |
| 376 | AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetCrashDumpStatus(&status)); |
| 377 | |
| 378 | while (status != GFSDK_Aftermath_CrashDump_Status_CollectingDataFailed && status != GFSDK_Aftermath_CrashDump_Status_Finished && |
| 379 | tElapsed < tdrTerminationTimeout) |
| 380 | { |
| 381 | // Sleep 50ms and poll the status again until timeout or Aftermath finished processing the crash dump. |
| 382 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); |
| 383 | AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetCrashDumpStatus(&status)); |
| 384 | |
| 385 | auto tEnd = std::chrono::steady_clock::now(); |
| 386 | tElapsed = std::chrono::duration_cast<std::chrono::milliseconds>(tEnd - tStart); |
| 387 | } |
| 388 | |
| 389 | return status == GFSDK_Aftermath_CrashDump_Status_Finished; |
| 390 | } |
| 391 | |
| 392 | AftermathContext::AftermathContext(Device* pDevice) : mpDevice(pDevice) {} |
| 393 | |