From 3b9c070ee0e3cb23c72116b97283529fbcd9b7ee Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 4 Jan 2015 16:33:58 +0100 Subject: [PATCH] D3D: Only try to apply exclusive mode when the renderer is in focus. --- Source/Core/VideoBackends/D3D/D3DBase.cpp | 2 +- Source/Core/VideoBackends/D3D/Render.cpp | 36 ++++++++++------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index f7426da03a..982c5d2e6c 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -265,7 +265,7 @@ HRESULT Create(HWND wnd) swap_chain_desc.OutputWindow = wnd; swap_chain_desc.SampleDesc.Count = 1; swap_chain_desc.SampleDesc.Quality = 0; - swap_chain_desc.Windowed = !g_ActiveConfig.bFullscreen; + swap_chain_desc.Windowed = !g_Config.bFullscreen; DXGI_OUTPUT_DESC out_desc; memset(&out_desc, 0, sizeof(out_desc)); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 5644eae9fb..f24e86a5d2 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -41,13 +41,11 @@ namespace DX11 { static u32 s_last_multisample_mode = 0; +static bool s_last_stereo_mode = false; +static bool s_last_xfb_mode = false; static Television s_television; -static bool s_last_fullscreen_mode = false; -static bool s_last_stereo_mode = 0; -static bool s_last_xfb_mode = false; - ID3D11Buffer* access_efb_cbuf = nullptr; ID3D11BlendState* clearblendstates[4] = {nullptr}; ID3D11DepthStencilState* cleardepthstates[3] = {nullptr}; @@ -230,7 +228,6 @@ Renderer::Renderer(void *&window_handle) s_last_multisample_mode = g_ActiveConfig.iMultisampleMode; s_last_efb_scale = g_ActiveConfig.iEFBScale; - s_last_fullscreen_mode = g_ActiveConfig.bFullscreen; s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; CalculateTargetSize(s_backbuffer_width, s_backbuffer_height); @@ -866,20 +863,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co const bool fullscreen = g_ActiveConfig.bFullscreen && !SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain; - bool fullscreen_changed = s_last_fullscreen_mode != fullscreen; - - bool fullscreen_state; - if (SUCCEEDED(D3D::GetFullscreenState(&fullscreen_state))) - { - if (fullscreen_state != fullscreen && Host_RendererHasFocus()) - { - // The current fullscreen state does not match the configuration, - // this may happen when the renderer frame loses focus. When the - // render frame is in focus again we can re-apply the configuration. - fullscreen_changed = true; - } - } - bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB; if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight) @@ -894,6 +877,20 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co // Flip/present backbuffer to frontbuffer here D3D::Present(); + // Check exclusive fullscreen state + bool fullscreen_state, fullscreen_changed = false; + if (SUCCEEDED(D3D::GetFullscreenState(&fullscreen_state))) + { + if (fullscreen_state != fullscreen) + { + // The current fullscreen state does not match the configuration, + // either we switched fullscreen settings or the render frame + // lost focus. When the render frame is in focus we can apply + // exclusive mode. + fullscreen_changed = Host_RendererHasFocus(); + } + } + // Resize the back buffers NOW to avoid flickering if (xfbchanged || windowResized || @@ -911,7 +908,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co // Apply fullscreen state if (fullscreen_changed) { - s_last_fullscreen_mode = fullscreen; D3D::SetFullscreenState(fullscreen); // Notify the host that it is safe to exit fullscreen