Sharing a texture resource from DX11 to DX9 to WPF, need to wait for DeviceContext.Flush() to finish

Posted by Rei Miyasaka on Game Development See other posts from Game Development or by Rei Miyasaka
Published on 2012-08-04T12:18:37Z Indexed on 2012/09/17 21:54 UTC
Read the original article Hit count: 1270

Filed under:
|
|

I'm following these instructions on TheCodeProject for rendering from DirectX to WPF using D3DImage.

The trouble is that now that I have no swap chain to call Present() on -- which according to the article shouldn't be a problem, but it definitely wasn't copying my back buffer.

An additional step that I have to take before I can copy the texture to WPF is to share it with a second D3D9Ex device, since D3DImage only works with DX9 (which is understandable, as WPF is built on DX9). To that end, I've modified some SlimDX code to work with DirectX 11.

I tried calling DeviceContext.Flush() (the Immediate one) at the end of each render cycle, which kind of works -- most of the time it'll show my renderings, but maybe for maybe 3 or 4 out of 60 frames each second, it'll draw my clear color instead. This makes sense -- Flush() is non-blocking; it doesn't wait for the GPU to do its thing the way SwapChain.Present does.

Any idea what the proper solution is?

I have a feeling it has something to do with my texture parameters for the back buffer, but I don't know.

© Game Development or respective owner

Related posts about directx

Related posts about slimdx