diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index 21226e442c..33de5d8065 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -31,7 +31,7 @@ namespace D3D ID3D11Device* device = nullptr; ID3D11DeviceContext* context = nullptr; -IDXGISwapChain* swapchain = nullptr; +static IDXGISwapChain* swapchain = nullptr; D3D_FEATURE_LEVEL featlevel; D3DTexture2D* backbuf = nullptr; HWND hWnd; @@ -492,6 +492,24 @@ void Present() swapchain->Present((UINT)g_ActiveConfig.IsVSync(), 0); } +HRESULT SetFullscreenState(bool enable_fullscreen) +{ + return swapchain->SetFullscreenState(enable_fullscreen, nullptr); +} + +HRESULT GetFullscreenState(bool* fullscreen_state) +{ + if (fullscreen_state == nullptr) + { + return E_POINTER; + } + + BOOL state; + HRESULT hr = swapchain->GetFullscreenState(&state, nullptr); + *fullscreen_state = !!state; + return hr; +} + } // namespace D3D } // namespace DX11 diff --git a/Source/Core/VideoBackends/D3D/D3DBase.h b/Source/Core/VideoBackends/D3D/D3DBase.h index 0188c464e3..2f9f15b623 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.h +++ b/Source/Core/VideoBackends/D3D/D3DBase.h @@ -40,7 +40,6 @@ void Close(); extern ID3D11Device* device; extern ID3D11DeviceContext* context; -extern IDXGISwapChain* swapchain; extern HWND hWnd; extern bool bFrameInProgress; @@ -59,6 +58,9 @@ bool BGRATexturesSupported(); unsigned int GetMaxTextureSize(); +HRESULT SetFullscreenState(bool enable_fullscreen); +HRESULT GetFullscreenState(bool* fullscreen_state); + // Ihis function will assign a name to the given resource. // The DirectX debug layer will make it easier to identify resources that way, // e.g. when listing up all resources who have unreleased references. diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 551d40b95c..e712bed4db 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -943,10 +943,10 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl bool fullscreen_changed = s_last_fullscreen_mode != fullscreen; - BOOL fullscreen_state; - if (SUCCEEDED(D3D::swapchain->GetFullscreenState(&fullscreen_state, nullptr))) + bool fullscreen_state; + if (SUCCEEDED(D3D::GetFullscreenState(&fullscreen_state))) { - if (!!fullscreen_state != fullscreen && Host_RendererHasFocus()) + 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 @@ -985,7 +985,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl if (fullscreen_changed) { s_last_fullscreen_mode = fullscreen; - D3D::swapchain->SetFullscreenState(fullscreen, nullptr); + D3D::SetFullscreenState(fullscreen); // Notify the host that it is safe to exit fullscreen if (!fullscreen)