Advertisement

SharpDX (DX12) - How to release handle to drawing area?

Started by November 17, 2017 09:01 AM
1 comment, last by SoldierOfLight 7 years, 2 months ago

I'm writing a 3D engine using SharpDX and DX12. It takes a handle to a System.Windows.Forms.Control for drawing onto. This handle is used when creating the swapchain (it's set as the OutputHandle in the SwapChainDescription). 

After rendering I want to give up this control to another renderer (for instance a GDI renderer), so I dispose various objects, among them the swapchain. However, no other renderer seem to be able to draw on this control after my DX12 renderer has used it. I see no exceptions or strange behaviour when debugging the other renderers trying to draw, except that nothing gets drawn to the area. If I then switch back to my DX12 renderer it can still draw to the control, but no other renderers seem to be able to. If I don't use my DX12 renderer, then I am able to switch between other renderers with no problem. My DX12 renderer is clearly messing up something in the control somehow, but what could I be doing wrong with just SharpDX calls? I read a tip about not disposing when in fullscreen mode, but I don't use fullscreen so it can't be that.

Anyway, my question is, how do I properly release this handle to my control so that others can draw to it later? Disposing things doesn't seem to be enough.

All other DX renderers would be capable of targeting that window, using DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL or FLIP_DISCARD, or D3D9's D3DSWAPEFFECT_FLIPEX. The way these present modes get contents on screen is by telling the desktop compositor to use the swapchain contents instead of the window contents; this is different from other swap effects and GDI which use a copy to get contents in the window.

I think the only solution to your problem will be to use an additional window to host the DX12 contents.

This topic is closed to new replies.

Advertisement