mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Merge pull request #1764 from Armada651/safe-exclusive
D3D: Only try to apply exclusive mode when the renderer is in focus.
This commit is contained in:
@ -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));
|
||||
|
@ -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,35 @@ 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 exclusive_mode, fullscreen_changed = false;
|
||||
if (SUCCEEDED(D3D::GetFullscreenState(&exclusive_mode)))
|
||||
{
|
||||
if (fullscreen && !exclusive_mode)
|
||||
{
|
||||
// Exclusive fullscreen is enabled in the configuration, but we're
|
||||
// not in exclusive mode. Either exclusive fullscreen was turned on
|
||||
// or the render frame lost focus. When the render frame is in focus
|
||||
// we can apply exclusive mode.
|
||||
fullscreen_changed = Host_RendererHasFocus();
|
||||
}
|
||||
else if (!fullscreen)
|
||||
{
|
||||
if (exclusive_mode)
|
||||
{
|
||||
// Exclusive fullscreen is disabled, but we're still in exclusive mode.
|
||||
fullscreen_changed = true;
|
||||
}
|
||||
else if (!g_ActiveConfig.bBorderlessFullscreen && Host_RendererIsFullscreen())
|
||||
{
|
||||
// Exclusive fullscreen is disabled and we are no longer in exclusive
|
||||
// mode. Thus we can now safely notify the UI to exit fullscreen. But
|
||||
// we should only do so if borderless fullscreen mode is disabled.
|
||||
Host_RequestFullscreen(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resize the back buffers NOW to avoid flickering
|
||||
if (xfbchanged ||
|
||||
windowResized ||
|
||||
@ -910,17 +922,8 @@ 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
|
||||
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);
|
||||
|
Reference in New Issue
Block a user