From c6a08259e93f63fbbac8517f8ecf7dc5536e29e3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 31 Mar 2018 16:20:15 -0700 Subject: Some minor updates to d3d swap chain --- Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp index 7b0f99b5..ca5faf08 100644 --- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp @@ -157,6 +157,15 @@ void SwapChainD3D11Impl::UpdateSwapChain(bool CreateNew) if(CreateNew) { m_pSwapChain.Release(); + + // Only one flip presentation model swap chain can be associated with an HWND. + // We must make sure that the swap chain is actually released by D3D11 before creating a new one. + // To force the destruction, we need to ensure no views are bound to pipeline state, and then call Flush + // on the immediate context. Dstruction must be forced before calling IDXGIFactory2::CreateSwapChainForHwnd(), or + // IDXGIFactory2::CreateSwapChainForCoreWindow() again to create a new swap chain. + // https://msdn.microsoft.com/en-us/library/windows/desktop/ff476425(v=vs.85).aspx#Defer_Issues_with_Flip + pImmediateCtxD3D11->Flush(); + auto *pd3d11Device = ValidatedCast(m_pRenderDevice.RawPtr())->GetD3D11Device(); CreateDXGISwapChain(pd3d11Device); } -- cgit v1.2.3