D3D: Only try to apply exclusive mode when the renderer is in focus.

This commit is contained in:
Jules Blok 2015-01-04 16:33:58 +01:00
parent 192c69f595
commit 3b9c070ee0
2 changed files with 17 additions and 21 deletions

View File

@ -265,7 +265,7 @@ HRESULT Create(HWND wnd)
swap_chain_desc.OutputWindow = wnd; swap_chain_desc.OutputWindow = wnd;
swap_chain_desc.SampleDesc.Count = 1; swap_chain_desc.SampleDesc.Count = 1;
swap_chain_desc.SampleDesc.Quality = 0; 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; DXGI_OUTPUT_DESC out_desc;
memset(&out_desc, 0, sizeof(out_desc)); memset(&out_desc, 0, sizeof(out_desc));

View File

@ -41,13 +41,11 @@ namespace DX11
{ {
static u32 s_last_multisample_mode = 0; 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 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; ID3D11Buffer* access_efb_cbuf = nullptr;
ID3D11BlendState* clearblendstates[4] = {nullptr}; ID3D11BlendState* clearblendstates[4] = {nullptr};
ID3D11DepthStencilState* cleardepthstates[3] = {nullptr}; ID3D11DepthStencilState* cleardepthstates[3] = {nullptr};
@ -230,7 +228,6 @@ Renderer::Renderer(void *&window_handle)
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode; s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
s_last_efb_scale = g_ActiveConfig.iEFBScale; s_last_efb_scale = g_ActiveConfig.iEFBScale;
s_last_fullscreen_mode = g_ActiveConfig.bFullscreen;
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0; s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB; s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height); 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 && const bool fullscreen = g_ActiveConfig.bFullscreen &&
!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain; !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; bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight) 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 // Flip/present backbuffer to frontbuffer here
D3D::Present(); 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 // Resize the back buffers NOW to avoid flickering
if (xfbchanged || if (xfbchanged ||
windowResized || windowResized ||
@ -911,7 +908,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
// Apply fullscreen state // Apply fullscreen state
if (fullscreen_changed) if (fullscreen_changed)
{ {
s_last_fullscreen_mode = fullscreen;
D3D::SetFullscreenState(fullscreen); D3D::SetFullscreenState(fullscreen);
// Notify the host that it is safe to exit fullscreen // Notify the host that it is safe to exit fullscreen