Skip to content

Commit 4cfae6d

Browse files
SwapChainD3D: fixed full-screen mode toggling (#648)
1 parent d1abdfc commit 4cfae6d

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,30 +202,26 @@ class SwapChainD3DBase : public SwapChainBase<BaseInterface>
202202
// DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT enables querying a waitable object that can be
203203
// used to synchronize presentation with CPU timeline.
204204
// The flag is not supported in D3D11 fullscreen mode.
205-
if (!m_FSDesc.Fullscreen)
205+
if (!(m_FSDesc.Fullscreen && m_pRenderDevice->GetDeviceInfo().Type == RENDER_DEVICE_TYPE_D3D11))
206206
{
207-
if (m_pRenderDevice->GetDeviceInfo().Type == RENDER_DEVICE_TYPE_D3D11)
207+
// We do not need pDXGIFactory3 itself, however DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT flag
208+
// is only supported starting with Windows 8.1, and so is IDXGIFactory3 interface. We query this
209+
// interface to check Windows 8.1.
210+
// Note that we can't use IsWindows8Point1OrGreater because unlike IsWindows8OrGreater, it returns
211+
// false if an application is not manifested for Windows 8.1 or Windows 10, even if the current
212+
// operating system version is Windows 8.1 or Windows 10.
213+
CComPtr<IDXGIFactory3> pDXGIFactory3;
214+
if (SUCCEEDED(pDXGIFactory.QueryInterface(&pDXGIFactory3)))
208215
{
209-
// We do not need pDXGIFactory3 itself, however DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT flag
210-
// is only supported starting with Windows 8.1, and so is IDXGIFactory3 interface. We query this
211-
// interface to check Windows 8.1.
212-
// Note that we can't use IsWindows8Point1OrGreater because unlike IsWindows8OrGreater, it returns
213-
// false if an application is not manifested for Windows 8.1 or Windows 10, even if the current
214-
// operating system version is Windows 8.1 or Windows 10.
215-
CComPtr<IDXGIFactory3> pDXGIFactory3;
216-
if (SUCCEEDED(pDXGIFactory.QueryInterface(&pDXGIFactory3)))
217-
{
218-
swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
219-
}
220-
}
221-
222-
if (CheckDXGITearingSupport(pDXGIFactory))
223-
{
224-
m_TearingSupported = true;
225-
swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
216+
swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
226217
}
227218
}
228219

220+
if (CheckDXGITearingSupport(pDXGIFactory))
221+
{
222+
m_TearingSupported = true;
223+
swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
224+
}
229225

230226
CComPtr<IDXGISwapChain1> pSwapChain1;
231227

@@ -382,7 +378,7 @@ class SwapChainD3DBase : public SwapChainBase<BaseInterface>
382378

383379
UINT Flags = 0;
384380
// DXGI_PRESENT_ALLOW_TEARING can only be used with sync interval 0
385-
if (SyncInterval == 0 && m_TearingSupported)
381+
if (SyncInterval == 0 && !m_FSDesc.Fullscreen && m_TearingSupported)
386382
Flags |= DXGI_PRESENT_ALLOW_TEARING;
387383

388384
return m_pSwapChain->Present(SyncInterval, Flags);

0 commit comments

Comments
 (0)