diff options
author | Anton Fedchin <afedchin@users.noreply.github.com> | 2015-10-14 10:43:26 +0400 |
---|---|---|
committer | Anton Fedchin <afedchin@users.noreply.github.com> | 2015-10-14 10:43:26 +0400 |
commit | b843768d92019a241c21bbbefb470a524dfdcdd5 (patch) | |
tree | 384976a9b6807cb811560a3717b34d0754d6536f | |
parent | 8cb3f365e93ce4bb9783288a16a721681a853821 (diff) | |
parent | ed15f47122e8bfb894a361d3baeb008159751788 (diff) |
Merge pull request #8215 from afedchin/fix_track_16311
[d3d11] Fixed segfault if device was lost. Also this adds trying to r…
-rw-r--r-- | xbmc/guilib/GUIFontTTFDX.cpp | 2 | ||||
-rw-r--r-- | xbmc/rendering/dx/RenderSystemDX.cpp | 40 |
2 files changed, 25 insertions, 17 deletions
diff --git a/xbmc/guilib/GUIFontTTFDX.cpp b/xbmc/guilib/GUIFontTTFDX.cpp index af370e8be1..144c2dced9 100644 --- a/xbmc/guilib/GUIFontTTFDX.cpp +++ b/xbmc/guilib/GUIFontTTFDX.cpp @@ -263,7 +263,7 @@ bool CGUIFontTTFDX::CopyCharToTexture(FT_BitmapGlyph bitGlyph, unsigned int x1, FT_Bitmap bitmap = bitGlyph->bitmap; ID3D11DeviceContext* pContext = g_Windowing.GetImmediateContext(); - if (m_speedupTexture) + if (m_speedupTexture && pContext) { CD3D11_BOX dstBox(x1, y1, 0, x2, y2, 1); pContext->UpdateSubresource(m_speedupTexture->Get(), 0, &dstBox, bitmap.buffer, bitmap.pitch, 0); diff --git a/xbmc/rendering/dx/RenderSystemDX.cpp b/xbmc/rendering/dx/RenderSystemDX.cpp index 298a4cc18a..e3795e2af6 100644 --- a/xbmc/rendering/dx/RenderSystemDX.cpp +++ b/xbmc/rendering/dx/RenderSystemDX.cpp @@ -414,13 +414,6 @@ bool CRenderSystemDX::DestroyRenderSystem() SAFE_RELEASE(m_pOutput); SAFE_RELEASE(m_adapter); SAFE_RELEASE(m_dxgiFactory); -#ifdef _DEBUG - if (m_d3dDebug) - { - m_d3dDebug->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY | D3D11_RLDO_DETAIL); - m_d3dDebug->Release(); - } -#endif return true; } @@ -435,6 +428,9 @@ void CRenderSystemDX::DeleteDevice() for (std::vector<ID3DResource *>::iterator i = m_resources.begin(); i != m_resources.end(); ++i) (*i)->OnDestroyDevice(); + if (m_pSwapChain) + m_pSwapChain->SetFullscreenState(false, NULL); + SAFE_DELETE(m_pGUIShader); SAFE_RELEASE(m_pTextureRight); SAFE_RELEASE(m_pRenderTargetViewRight); @@ -446,16 +442,8 @@ void CRenderSystemDX::DeleteDevice() SAFE_RELEASE(m_depthStencilState); SAFE_RELEASE(m_depthStencilView); SAFE_RELEASE(m_pRenderTargetView); - if (m_pSwapChain) - { - m_pSwapChain->SetFullscreenState(false, NULL); - SAFE_RELEASE(m_pSwapChain); - } - SAFE_RELEASE(m_pSwapChain1); - SAFE_RELEASE(m_pD3DDev); if (m_pContext && m_pContext != m_pImdContext) { - FinishCommandList(false); m_pContext->ClearState(); m_pContext->Flush(); SAFE_RELEASE(m_pContext); @@ -466,6 +454,16 @@ void CRenderSystemDX::DeleteDevice() m_pImdContext->Flush(); SAFE_RELEASE(m_pImdContext); } + SAFE_RELEASE(m_pSwapChain); + SAFE_RELEASE(m_pSwapChain1); + SAFE_RELEASE(m_pD3DDev); +#ifdef _DEBUG + if (m_d3dDebug) + { + m_d3dDebug->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY | D3D11_RLDO_DETAIL); + SAFE_RELEASE(m_d3dDebug); + } +#endif m_bResizeRequred = false; m_bHWStereoEnabled = false; m_bRenderCreated = false; @@ -1210,6 +1208,7 @@ bool CRenderSystemDX::BeginRender() if (DXGI_ERROR_DEVICE_REMOVED == m_nDeviceStatus) { OnDeviceLost(); + OnDeviceReset(); } return false; } @@ -1362,6 +1361,9 @@ void CRenderSystemDX::SetCameraPosition(const CPoint &camera, int screenWidth, i void CRenderSystemDX::Project(float &x, float &y, float &z) { + if (!m_bRenderCreated) + return; + m_pGUIShader->Project(x, y, z); } @@ -1482,7 +1484,10 @@ void CRenderSystemDX::RestoreViewPort() bool CRenderSystemDX::ScissorsCanEffectClipping() { - return m_pGUIShader != NULL && m_pGUIShader->HardwareClipIsPossible(); + if (!m_bRenderCreated) + return false; + + return m_pGUIShader != NULL && m_pGUIShader->HardwareClipIsPossible(); } CRect CRenderSystemDX::ClipRectToScissorRect(const CRect &rect) @@ -1637,6 +1642,9 @@ bool CRenderSystemDX::SupportsStereo(RENDER_STEREO_MODE mode) const void CRenderSystemDX::FlushGPU() { + if (!m_bRenderCreated) + return; + FinishCommandList(); m_pImdContext->Flush(); } |