OVRSharp icon indicating copy to clipboard operation
OVRSharp copied to clipboard

Explore ways to improve performance of `GetMirrorImage` DirectX implementation

Open tjhorner opened this issue 4 years ago • 0 comments

DirectXCompositor.GetMirrorImage is really slow right now (~15ms per call on average), mostly because there's lots of copying and manipulation going on. We should explore different ways of improving performance, such as:

  • Minimize copying from GPU to RAM (at least once is necessary, though)
  • See if we can execute this on a different thread and make the method async (would OpenVR be happy with that? If not, we could call the OpenVR API on the main thread, then do the rest of the work on a different thread)
  • Instead of using FlipChannels after the image is copied over, can we do this while copying the memory initially?
  • Can we make the Texture2D -> Bitmap copying more efficient?

I don't work with DirectX much (or graphics APIs in general) so there could be something I'm missing. Any input is appreciated :)

For reference, here's the method:

https://github.com/OVRTools/OVRSharp/blob/f75f35656111f57fcafc227bab3e5a9c719e0939/OVRSharp.Graphics.DirectX/DirectXCompositor.cs#L52-L103

tjhorner avatar Jul 11 '21 20:07 tjhorner