| 49 | } |
| 50 | |
| 51 | void NotifyDeviceRemoved( HRESULT hr, BlueScriptCallback& onDeviceRemoved ) |
| 52 | { |
| 53 | static uint32_t s_deviceLostCount = 0; |
| 54 | ++s_deviceLostCount; |
| 55 | |
| 56 | Tr2RenderContextEnum::RenderContextStatus status = Tr2RenderContextEnum::CONTEXT_STATUS_INVALID; |
| 57 | std::string marker, markerMessage, offendingShader; |
| 58 | if( SUCCEEDED( Tr2RenderContext_GetMainThreadRenderContext().GetGpuStateMarker( status, marker, offendingShader ) ) ) |
| 59 | { |
| 60 | if( !marker.empty() ) |
| 61 | { |
| 62 | markerMessage = ", GPU marker: " + marker; |
| 63 | } |
| 64 | if( !offendingShader.empty() ) |
| 65 | { |
| 66 | markerMessage = ", shader: " + offendingShader; |
| 67 | } |
| 68 | } |
| 69 | auto reason = GetDeviceRemovedReasonString( hr ); |
| 70 | |
| 71 | if( onDeviceRemoved.IsValid() ) |
| 72 | { |
| 73 | onDeviceRemoved.CallVoid( (uint64_t)(unsigned long)hr, reason, s_deviceLostCount, marker, "", offendingShader ); |
| 74 | } |
| 75 | |
| 76 | CCP_LOGERR( "DX12 device removed, reason: %s%s", reason.c_str(), markerMessage.c_str() ); |
| 77 | |
| 78 | if( BeCrashes ) |
| 79 | { |
| 80 | std::string str; |
| 81 | BeCrashes->SetCrashKeyValue( "gpuRemovedCount", ( str = std::to_string( s_deviceLostCount ) ).c_str() ); |
| 82 | BeCrashes->SetCrashKeyValue( "gpuRemovedFrame", ( str = std::to_string( g_currentFrameCounter ) ).c_str() ); |
| 83 | BeCrashes->SetCrashKeyValue( "gpuRemovedReason", reason.c_str() ); |
| 84 | if( !marker.empty() ) |
| 85 | { |
| 86 | BeCrashes->SetCrashKeyValue( "gpuRemovedMarker", marker.c_str() ); |
| 87 | } |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | } |
| 92 | constexpr char const* DredBreadcrumbOpName( D3D12_AUTO_BREADCRUMB_OP op ) |
no test coverage detected