microsoft/WPFDXInterop

Do we really need Synchronization Helper inside D3D11Image ?

nikobarli opened this issue · 3 comments

Looking at the source code, I think you have implemented the synchronization helper as described here: https://msdn.microsoft.com/en-us/library/windows/desktop/ee913554(v=vs.85).aspx#interoperability_between_direct3d_9ex_and_dxgi_based_apis

You created one Dx9 device (Producer on A side, Consumer on B side) and one Dx10 device (Producer on B side, Consumer on A side) inside the helper class. However these two devices do not do any rendering, and are not exposed to the external world. Thus synchronizing between the two seems not necessary to me.

I think we only need to create a shareable Dx10/Dx11 surface, set it as backbuffer to the base class D3DImage, then expose the surface to user. Then user needs to flush/sync their device after rendering to the surface, before adding DirtRect to the D3DImage.

FYI, In my use case, I need to render 4~10 D3DImages in one refresh. The mentioned synchronization helper code consumed a lot of UI thread's time and reduced my frame rate.

I finally wrote my own interop class, taking example from http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/437/Direct3D-10-11-Direct2D-in-WPF.aspx and http://marcangers.com/category/direct3d/ to meet my performance requirements. Still, it is slow when used from remote desktop due to the fallback to software rendering. I wish WPF will support DirectX >= 11 natively in the future.

When in remote desktop, you should drop your framerate to around 30-fps, and turn off any extraneous animations you can.

Thanks for the tip. My app has a mode to show movie-like playback @ 50 fps. When not using RDP I can easily achieve that and my UI thread occupancy shows approx 70%. When using RDP on local LAN, the fps drops to approx 40 fps, and my UI thread occupancy shows ~100%. So I suspect the increase in my UI thread occupancy (and the decrease in fps) is due to the fallback to software rendering in WPF.

Notes: the fps is what reported by the app (and by WPF Perforator), not by measuring the exact fps through RDP. Do you know any tool to measure the real fps of RDP ?