Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern CORE_API bool GIsGPUCrashed;
- static void TerminateOnDeviceRemoved(HRESULT D3DResult, ID3D11Device* Direct3DDevice)
- {
- if (GDynamicRHI)
- {
- GDynamicRHI->CheckGpuHeartbeat();
- }
- if (D3DResult == DXGI_ERROR_DEVICE_REMOVED)
- {
- #if NV_AFTERMATH
- uint32 Result = 0xffffffff;
- uint32 bDeviceActive = 0;
- if (GDX11NVAfterMathEnabled)
- {
- GFSDK_Aftermath_Device_Status Status;
- auto Res = GFSDK_Aftermath_GetDeviceStatus(&Status);
- Result = uint32(Res);
- if (Res == GFSDK_Aftermath_Result_Success)
- {
- bDeviceActive = Status == GFSDK_Aftermath_Device_Status_Active ? 1 : 0;
- }
- }
- UE_LOG(LogD3D11RHI, Log, TEXT("[Aftermath] GDynamicRHI=%p, GDX11NVAfterMathEnabled=%d, Result=0x%08X, bDeviceActive=%d"), GDynamicRHI, GDX11NVAfterMathEnabled, Result, bDeviceActive);
- #else
- UE_LOG(LogD3D11RHI, Log, TEXT("[Aftermath] NV_AFTERMATH is not set"));
- #endif
- GIsGPUCrashed = true;
- if (Direct3DDevice)
- {
- HRESULT hRes = Direct3DDevice->GetDeviceRemovedReason();
- const TCHAR* Reason = TEXT("?");
- switch (hRes)
- {
- case DXGI_ERROR_DEVICE_HUNG: Reason = TEXT("HUNG"); break;
- case DXGI_ERROR_DEVICE_REMOVED: Reason = TEXT("REMOVED"); break;
- case DXGI_ERROR_DEVICE_RESET: Reason = TEXT("RESET"); break;
- case DXGI_ERROR_DRIVER_INTERNAL_ERROR: Reason = TEXT("INTERNAL_ERROR"); break;
- case DXGI_ERROR_INVALID_CALL: Reason = TEXT("INVALID_CALL"); break;
- case S_OK: Reason = TEXT("S_OK"); break;
- }
- // We currently don't support removed devices because FTexture2DResource can't recreate its RHI resources from scratch.
- // We would also need to recreate the viewport swap chains from scratch.
- UE_LOG(LogD3D11RHI, Fatal, TEXT("Unreal Engine is exiting due to D3D device being lost. (Error: 0x%X - '%s')"), hRes, Reason);
- }
- else
- {
- UE_LOG(LogD3D11RHI, Fatal, TEXT("Unreal Engine is exiting due to D3D device being lost. D3D device was not available to assertain DXGI cause."));
- }
- // Workaround for the fact that in non-monolithic builds the exe gets into a weird state and exception handling fails.
- // @todo investigate why non-monolithic builds fail to capture the exception when graphics driver crashes.
- #if !IS_MONOLITHIC
- FPlatformMisc::RequestExit(true);
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement