I am developing a directX 11 application. I am using IDXGIFactory2::CreateSwapChainForHwnd to create the swap chain after creating the DX11 device. The DX11 code is in an object that gets destroyed then re-created to render another video stream to the same HWND (window handle).
On the first run of the application IDXGIFactory2::CreateSwapChainForHwnd succeeds no problem. Then the application destroys the object with the DX11 code which destroys the DX11 device and swapchain etc. It goes to re-init the DX11 code again with the same HWND and this time IDXGIFactory2::CreateSwapChainForHwnd FAILS with E_ACCESSDENIED.
I have read the MSDN documentation that says there is a problem with differed destruction when changing swap chains. Here:
I tried to implement the suggested workaround to force the destruction of the objects:
D3D11Context->ClearState();
D3D11Context->Flush();
But IDXGIFactory2::CreateSwapChainForHwnd still returns E_ACCESSDENIED.
Does anyone have any insight as to why this could be happening? Thanks!