Resetting window after using DirectX 11
Asked Answered
A

1

6

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.

Antonio answered 18/12, 2013 at 0:18 Comment(5)
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.Spellbinder
Thanks for the hints. I'll check and let you know the results.Antonio
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.Antonio
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.Antonio
Just a quick note - this is even worse for D3D12, since it does not support non-flip models anymore. You basically have to re-create the window apparently. I have not found any way to reset it. I guess, one alternative would be to interop the swap chain, to force presents through DXGI. This is not trivial and I am not sure if it works for OpenGL.Aliciaalick
A
4

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.

Antonio answered 20/1, 2014 at 15:30 Comment(2)
This is the exact problem that occurred to me today. Have you found any solution to still use DXGO_SWAP_EFFECT_FLIP_SEQUENTIAL and still manage to switch to OpenGL? Or can you still revert back the HWND to use GDI instead of the one managed by DWM?Bluebell
I simply create a child window and get rid of it after using DirectX 11.Antonio

© 2022 - 2024 — McMap. All rights reserved.