mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Merge pull request #4443 from Armada651/exclusive-ui
D3D: Move exclusive mode switching to UI thread.
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
#include "VideoBackends/D3D/D3DTexture.h"
|
||||
@ -315,7 +316,8 @@ 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_Config.bFullscreen;
|
||||
swap_chain_desc.Windowed =
|
||||
!SConfig::GetInstance().bFullscreen || g_ActiveConfig.bBorderlessFullscreen;
|
||||
|
||||
DXGI_OUTPUT_DESC out_desc = {};
|
||||
output->GetDesc(&out_desc);
|
||||
@ -610,17 +612,11 @@ HRESULT SetFullscreenState(bool enable_fullscreen)
|
||||
return swapchain->SetFullscreenState(enable_fullscreen, nullptr);
|
||||
}
|
||||
|
||||
HRESULT GetFullscreenState(bool* fullscreen_state)
|
||||
bool GetFullscreenState()
|
||||
{
|
||||
if (fullscreen_state == nullptr)
|
||||
{
|
||||
return E_POINTER;
|
||||
}
|
||||
|
||||
BOOL state;
|
||||
HRESULT hr = swapchain->GetFullscreenState(&state, nullptr);
|
||||
*fullscreen_state = !!state;
|
||||
return hr;
|
||||
BOOL state = FALSE;
|
||||
swapchain->GetFullscreenState(&state, nullptr);
|
||||
return !!state;
|
||||
}
|
||||
|
||||
} // namespace D3D
|
||||
|
@ -75,7 +75,7 @@ bool BGRATexturesSupported();
|
||||
unsigned int GetMaxTextureSize();
|
||||
|
||||
HRESULT SetFullscreenState(bool enable_fullscreen);
|
||||
HRESULT GetFullscreenState(bool* fullscreen_state);
|
||||
bool GetFullscreenState();
|
||||
|
||||
// This function will assign a name to the given resource.
|
||||
// The DirectX debug layer will make it easier to identify resources that way,
|
||||
|
@ -851,8 +851,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||
SetWindowSize(fbStride, fbHeight);
|
||||
|
||||
const bool windowResized = CheckForResize();
|
||||
const bool fullscreen = g_ActiveConfig.bFullscreen && !g_ActiveConfig.bBorderlessFullscreen &&
|
||||
!SConfig::GetInstance().bRenderToMain;
|
||||
|
||||
bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
|
||||
|
||||
@ -869,33 +867,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||
// 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)
|
||||
{
|
||||
if (g_Config.bExclusiveMode)
|
||||
OSD::AddMessage("Lost exclusive fullscreen.");
|
||||
|
||||
// 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();
|
||||
|
||||
g_Config.bExclusiveMode = false;
|
||||
}
|
||||
else if (!fullscreen && exclusive_mode)
|
||||
{
|
||||
// Exclusive fullscreen is disabled, but we're still in exclusive mode.
|
||||
fullscreen_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Resize the back buffers NOW to avoid flickering
|
||||
if (CalculateTargetSize(s_backbuffer_width, s_backbuffer_height) || xfbchanged || windowResized ||
|
||||
fullscreen_changed || s_last_efb_scale != g_ActiveConfig.iEFBScale ||
|
||||
s_last_efb_scale != g_ActiveConfig.iEFBScale ||
|
||||
s_last_multisamples != g_ActiveConfig.iMultisamples ||
|
||||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
||||
{
|
||||
@ -903,23 +877,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||
s_last_multisamples = g_ActiveConfig.iMultisamples;
|
||||
PixelShaderCache::InvalidateMSAAShaders();
|
||||
|
||||
if (windowResized || fullscreen_changed)
|
||||
if (windowResized)
|
||||
{
|
||||
// Apply fullscreen state
|
||||
if (fullscreen_changed)
|
||||
{
|
||||
g_Config.bExclusiveMode = fullscreen;
|
||||
|
||||
if (fullscreen)
|
||||
OSD::AddMessage("Entered exclusive fullscreen.");
|
||||
|
||||
D3D::SetFullscreenState(fullscreen);
|
||||
|
||||
// If fullscreen is disabled we can safely notify the UI to exit fullscreen.
|
||||
if (!g_ActiveConfig.bFullscreen)
|
||||
Host_RequestFullscreen(false);
|
||||
}
|
||||
|
||||
// TODO: Aren't we still holding a reference to the back buffer right now?
|
||||
D3D::Reset();
|
||||
SAFE_RELEASE(s_screenshot_texture);
|
||||
@ -1291,4 +1250,14 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::SetFullscreen(bool enable_fullscreen)
|
||||
{
|
||||
D3D::SetFullscreenState(enable_fullscreen);
|
||||
}
|
||||
|
||||
bool Renderer::IsFullscreen() const
|
||||
{
|
||||
return D3D::GetFullscreenState();
|
||||
}
|
||||
|
||||
} // namespace DX11
|
||||
|
@ -25,6 +25,8 @@ public:
|
||||
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
||||
void SetInterlacingMode() override;
|
||||
void SetViewport() override;
|
||||
void SetFullscreen(bool enable_fullscreen) override;
|
||||
bool IsFullscreen() const override;
|
||||
|
||||
// TODO: Fix confusing names (see ResetAPIState and RestoreAPIState)
|
||||
void ApplyState(bool bUseDstAlpha) override;
|
||||
|
@ -871,12 +871,11 @@ HRESULT SetFullscreenState(bool enable_fullscreen)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GetFullscreenState(bool* fullscreen_state)
|
||||
bool GetFullscreenState()
|
||||
{
|
||||
// Fullscreen exclusive intentionally not supported in DX12 backend. No performance
|
||||
// difference between it and windowed full-screen due to usage of a FLIP swap chain.
|
||||
*fullscreen_state = false;
|
||||
return S_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace D3D
|
||||
|
@ -124,7 +124,7 @@ const std::string VertexShaderVersionString();
|
||||
unsigned int GetMaxTextureSize();
|
||||
|
||||
HRESULT SetFullscreenState(bool enable_fullscreen);
|
||||
HRESULT GetFullscreenState(bool* fullscreen_state);
|
||||
bool GetFullscreenState();
|
||||
|
||||
// This function will assign a name to the given resource.
|
||||
// The DirectX debug layer will make it easier to identify resources that way,
|
||||
|
@ -803,8 +803,6 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||
SetWindowSize(fb_stride, fb_height);
|
||||
|
||||
const bool window_resized = CheckForResize();
|
||||
const bool fullscreen = g_ActiveConfig.bFullscreen && !g_ActiveConfig.bBorderlessFullscreen &&
|
||||
!SConfig::GetInstance().bRenderToMain;
|
||||
|
||||
bool xfb_changed = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
|
||||
|
||||
|
Reference in New Issue
Block a user