diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2014-07-26 13:22:11 +0200 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2014-07-26 13:22:11 +0200 |
| commit | 8e865f38489f204ea2fabf2cee3acad1a215deff (patch) | |
| tree | 892e604be56a09cd0ce2abe75cd960f1a5821b7b /Source/Core/VideoBackends/D3D/Render.cpp | |
| parent | 906b05cb1c1a88c2af3d83c2cd422822abe143fe (diff) | |
| parent | 06b13f12d3c7ef9946dfba6d8aa91e9f6b1ed7d6 (diff) | |
Merge pull request #506 from Armada651/d3dfullscreen
D3D: Add exclusive fullscreen support.
Diffstat (limited to 'Source/Core/VideoBackends/D3D/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/D3D/Render.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 2699b56a46..e712bed4db 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -42,6 +42,8 @@ static u32 s_LastAA = 0; static Television s_television; +static bool s_last_fullscreen_mode = false; + ID3D11Buffer* access_efb_cbuf = nullptr; ID3D11BlendState* clearblendstates[4] = {nullptr}; ID3D11DepthStencilState* cleardepthstates[3] = {nullptr}; @@ -936,6 +938,22 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl SetWindowSize(fbWidth, fbHeight); const bool windowResized = CheckForResize(); + const bool fullscreen = g_ActiveConfig.ExclusiveFullscreenEnabled() && + !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 = false; @@ -951,17 +969,31 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl // Flip/present backbuffer to frontbuffer here D3D::Present(); - // resize the back buffers NOW to avoid flickering + // Resize the back buffers NOW to avoid flickering if (xfbchanged || windowResized || + fullscreen_changed || s_LastEFBScale != g_ActiveConfig.iEFBScale || s_LastAA != g_ActiveConfig.iMultisampleMode) { s_LastAA = g_ActiveConfig.iMultisampleMode; PixelShaderCache::InvalidateMSAAShaders(); - if (windowResized) + if (windowResized || fullscreen_changed) { + // Apply fullscreen state + if (fullscreen_changed) + { + s_last_fullscreen_mode = fullscreen; + D3D::SetFullscreenState(fullscreen); + + // Notify the host that it is safe to exit fullscreen + if (!fullscreen) + { + Host_RequestFullscreen(false); + } + } + // TODO: Aren't we still holding a reference to the back buffer right now? D3D::Reset(); SAFE_RELEASE(s_screenshot_texture); |
