Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
jherico's avatar
jherico
Adventurer
11 years ago

Asynchronous timewarp example

Edit: Video updated

A few days ago I was browsing the comments on an Ars Technica story on the Rift and I saw this exhcange:

"zarakon" wrote:

"sep332" wrote:
Hopefully they'll fix the software by then to handle framerate drops more gracefully.

Have you seen the Time Warp feature? https://www.youtube.com/watch?v=WvtEXMlQQtI Or did you mean something else?


This seems to be a common misconception concerning timewarp: that it's intended to counteract issues with low frame rates. Timewarp can't do this, at least on it's own. Specifically, a rendered frame can't be timewarped to a new location based on the current headset orientation until ovrHmd_EndFrame() is called. If your rendering code is taking too much time to render, it's presumably not pausing in the middle to call ovrHmd_EndFrame() so that the Rift can display a timewarped version of the previous frame.

What's needed is asynchronous distortion in addition to timewarp. With asynchronous rendering you have one thread that does nothing but run the BeginFrame/EndFrame loop, always passing in the most recently rendered per-eye images and the corresponding poses with which they were rendered. On another thread, you run the actual render loop that's producing those images. This way it doesn't matter whether you're in the middle of a bunch of rendering calls when the next vsync comes around... the BeginFrame/EndFrame thread will always update send the most recent valid render to the Rift, with the proper eye pose so that it can be timewarped based on the Rift's current orientation.

Working with OpenGL in multiple threads can be a bit tricky, so I've produced an example of this technique for my book and I wanted to share it with the community.

I've also created a video showing describing the technique and showing the code in action:

30 Replies