I thought this would be relatively easy, but the more I read (here in the forums, elsewhere in the web) the more it looks like what I need to do is not possible.
tl;dr:
Is there any way for an OVR-based library loaded at run-time within an existing app to share OpenGL resources with the app in direct mode?
Long version:
I develop plugins for Max/MSP/Jitter, which is a widely-used visual creative coding platform in media art. (The same issue will apply to other platforms too). It is cross-platform and OpenGL-based. Plugins are loaded as dynamic libraries. I developed a plugin to support the oculus (
http://github.com/grrrwaaa/max_oculus) which works great in extended mode/client-based rendering on a powerful enough rig. I'm sure performance would be better in direct mode, so I'd like to use this app to render GL content into a texture, and send that texture to the plugin to forward to the (direct mode) rift, for SDK rendering.
But the more I read, the more it seems like this won't be possible because of weird stuff that the SDK does to the OpenGL driver in ovr_Initialize(). Because it is a plugin, the exe has already loaded and started doing things like wglext stuff and creating windows/contexts before the library can call ovr_Initialize(). I can't force the app to link to libovr. Is what I want to do even possible? Is there e.g. a way using shared contexts to bridge between app-rendered texture and libovr SDK rendering?
It seems pretty drastic not to be able to use the SDK from a loaded library...
Comments
viewtopic.php?f=20&t=19937
Ive been trying to make a plugin interface for OVR for a number of weeks and have not been very successful. And i even create a specific context just for the plugin. Its news to me that you are bringing in a D3D texture in to the mix... Why would you need to remap the color buffer? Why dont you draw to your own buffer and leave the application alone? Could you please explain In greater detail what the driver is up to?
A proxy executable isn't feasible -- this is an app used by a large community, and used for many different purposes; a proxy exe just feels wrong. Is there any plan to find an OpenGL implementation in the SDK that does not require the shim?
"But I'm not sure this will make things any faster." -- do you mean OpenGL direct mode/SDK rendering is no faster than extended desktop/client rendering?
"the shims may interfere with other contexts in the host app" -- what exactly can the possible interferences be? This could be a deal-breaker.
We are investigating better ways of interfacing with OpenGL (and D3D) that would support use cases such as yours. It shouldn't be too long before we have more information about that.
SDK rendering is likely to be faster than client rendering, but direct mode is not necessarily faster than extended mode, especially with OpenGL.
No shimming occurs in extended mode. In direct mode, we do things like disable MSAA and sRGB. It could break the app's assumptions or result in an invalid OpenGL state. I would not recommend using direct mode with apps that maintain non-VR contexts and viewports.
In the meantime I'll see what I can do with SDK rendering (and multi-threading...)
Thanks!