diff options
Diffstat (limited to 'xbmc/rendering/dx/DeviceResources.cpp')
-rw-r--r-- | xbmc/rendering/dx/DeviceResources.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/xbmc/rendering/dx/DeviceResources.cpp b/xbmc/rendering/dx/DeviceResources.cpp index 669c5e7682..bdb2fafc9c 100644 --- a/xbmc/rendering/dx/DeviceResources.cpp +++ b/xbmc/rendering/dx/DeviceResources.cpp @@ -195,13 +195,14 @@ bool DX::DeviceResources::SetFullScreen(bool fullscreen, RESOLUTION_INFO& res) critical_section::scoped_lock lock(m_criticalSection); - CLog::LogF(LOGDEBUG, "switching to/from fullscreen (%f x %f)", m_outputSize.Width, - m_outputSize.Height); - BOOL bFullScreen; - bool recreate = m_stereoEnabled != (CServiceBroker::GetWinSystem()->GetGfxContext().GetStereoMode() == RENDER_STEREO_MODE_HARDWAREBASED); - m_swapChain->GetFullscreenState(&bFullScreen, nullptr); + + CLog::LogF(LOGDEBUG, "switching from %s(%.0f x %.0f) to %s(%d x %d)", + bFullScreen ? "fullscreen " : "", m_outputSize.Width, m_outputSize.Height, + fullscreen ? "fullscreen " : "", res.iWidth, res.iHeight); + + bool recreate = m_stereoEnabled != (CServiceBroker::GetWinSystem()->GetGfxContext().GetStereoMode() == RENDER_STEREO_MODE_HARDWAREBASED); if (!!bFullScreen && !fullscreen) { CLog::LogF(LOGDEBUG, "switching to windowed"); @@ -257,7 +258,15 @@ bool DX::DeviceResources::SetFullScreen(bool fullscreen, RESOLUTION_INFO& res) recreate |= SUCCEEDED(m_swapChain->SetFullscreenState(true, pOutput.Get())); m_swapChain->GetFullscreenState(&bFullScreen, nullptr); } - recreate |= SUCCEEDED(m_swapChain->ResizeTarget(¤tMode)); + bool resized = SUCCEEDED(m_swapChain->ResizeTarget(¤tMode)); + if (resized) + { + // some system doesn't inform windowing about desktop size changes + // so we have to change output size before resizing buffers + m_outputSize.Width = static_cast<float>(currentMode.Width); + m_outputSize.Height = static_cast<float>(currentMode.Height); + } + recreate |= resized; } } if (!bFullScreen) @@ -276,7 +285,7 @@ bool DX::DeviceResources::SetFullScreen(bool fullscreen, RESOLUTION_INFO& res) CLog::LogF(LOGDEBUG, "switching done."); - return true; + return recreate; } // Configures resources that don't depend on the Direct3D device. @@ -516,16 +525,20 @@ void DX::DeviceResources::ResizeBuffers() DXGI_SWAP_CHAIN_DESC1 scDesc = { 0 }; if (m_swapChain) { + BOOL bFullcreen = 0; + m_swapChain->GetFullscreenState(&bFullcreen, nullptr); + if (!!bFullcreen) + { + windowed = false; + } + // check if swapchain needs to be recreated m_swapChain->GetDesc1(&scDesc); if ((scDesc.Stereo == TRUE) != bHWStereoEnabled) { // check fullscreen state and go to windowing if necessary - BOOL bFullcreen; - m_swapChain->GetFullscreenState(&bFullcreen, nullptr); if (!!bFullcreen) { - windowed = false; // will create fullscreen swapchain m_swapChain->SetFullscreenState(false, nullptr); // mandatory before releasing swapchain } @@ -544,7 +557,7 @@ void DX::DeviceResources::ResizeBuffers() lround(m_outputSize.Width), lround(m_outputSize.Height), scDesc.Format, - 0 + windowed ? 0 : DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ); if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) @@ -569,7 +582,7 @@ void DX::DeviceResources::ResizeBuffers() swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.BufferCount = 3 * (1 + bHWStereoEnabled); swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; - swapChainDesc.Flags = 0; + swapChainDesc.Flags = windowed ? 0 : DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; |