4
votes

I've written an application that can switch between OpenGL, DirectX 9 and DirectX 11 for rendering without restarting or recreating the window. Switching between OpenGL and DirectX 9 as well as to DirectX 11 mode works well, however, after using DirectX 11 no other rendering mode works any longer.

After releasing all DirectX 11 interfaces, the window still shows the last rendered frame, it is even properly updated when resizing the window. A DirectX 9 device can be created and the Present calls succeed, however, all I see is the last frame drawn by DirectX 11.

I’ve used IDXGIDebug::ReportLiveObjects to make sure all DirectX 11 interfaces have actually been released. I’ve also tried IDXGIFactory::MakeWindowAssociation, but it didn’t fix the issue.

Why is the last frame repainted, who repaints it? How do I get rid of it and restore the original behavior of the window.

By the way, creating a new window would be a workaround, but I would like to use the same window for DirectX 9/11 and OpenGL.

1
The last frame is owned by the Desktop Window Manager. Are you sure you have unbound everything? Also, have you tried reporting live D3D objects (not just DXGI)? The correct process for window disassociation should be: unbind swap chain render target view from pipeline (set all to NULL), release swap chain render target view, release swap chain, flush context, release context, release device. - MooseBoys
Thanks for the hints. I'll check and let you know the results. - Peter Wimmer
ID3D11Debug::ReportLiveDeviceObjects returns the same interfaces as IDXGIDebug::ReportLiveObjects. IDXGIDebug is queried from the device, so it increments the devices refcount. When not using ID3D11Debug, ReportLiveObjects doesn't list any objects, so I believe I've released all objects. Nevertheless, the original problem is still there. - Peter Wimmer
Ok, I found out that the problem only occurs with DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL. I've modified a simple Microsoft DX11 sample application and it had the very same issue when using DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL: Even after calling the cleanup method, it still showed the last rendered frame. - Peter Wimmer

1 Answers

2
votes

The reason for the problem is DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL. http://msdn.microsoft.com/en-us/library/windows/desktop/hh706346(v=vs.85).aspx says

When you use the flip model, only Direct3D content in flip model swap chains that the runtime passes to DWM are visible. The runtime ignores all other bitblt model Direct3D or GDI content updates.

That explains why I don't get any output using DirectX 9 after using DirectX 11 in flip sequential mode.