SDK-side distortion, OpenGL & glFinish()/glFlush()
I've been brushing up on my GL skills, and I was wondering about the flow through the GL distortion pipeline in the SDK. I'm fundamentally unhappy with the idea of glFlush()/glFinish() being used for synchronization of any kind and even more so with the busy-wait mechanisms designed to block the client from beginning a new frame until the SDK decides the time is right.
It seems like one of the fundamental problems you're trying to solve is to ensure that when the next frame starts you have a decent idea of when it's going to be rendered, and thus can provide the most accurate head pose information. Right now this is done by flushing and busy-waiting in endFrame(), but this demonstrably causes dropped frames and a lower overall framerate on my desktop machine. I'm thinking there's a better way.
In the distortion rendering, you could instantiate a fence sync object after doing the draw, or performing the buffer swap, and use a queue of unsignaled sync objects as a count of pending frames, using that to determine prediction amount required for future rendering calls. You could expose the number of pending frames to the client, giving them the opportunity to perform other work if there were more than 1, meaning that they're too far ahead of the rendering pipeline.
Just a thought.
It seems like one of the fundamental problems you're trying to solve is to ensure that when the next frame starts you have a decent idea of when it's going to be rendered, and thus can provide the most accurate head pose information. Right now this is done by flushing and busy-waiting in endFrame(), but this demonstrably causes dropped frames and a lower overall framerate on my desktop machine. I'm thinking there's a better way.
In the distortion rendering, you could instantiate a fence sync object after doing the draw, or performing the buffer swap, and use a queue of unsignaled sync objects as a count of pending frames, using that to determine prediction amount required for future rendering calls. You could expose the number of pending frames to the client, giving them the opportunity to perform other work if there were more than 1, meaning that they're too far ahead of the rendering pipeline.
Just a thought.
