From 64bb120712ed8f4691e4337281ae8054202566b5 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 9 Jun 2015 10:25:05 -0700 Subject: [PATCH] Be a little less heavy handed with the GPU sync --- interface/src/devices/OculusManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 1fd84bb921..6c3a3d84a0 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -710,13 +710,21 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const Q_ASSERT(OVR_SUCCESS(res)); _swapFbo->Increment(); #else - glFinish(); - GLuint textureId = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)); + GLsync syncObject = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + _outputWindow->makeCurrent(); + // force the compositing context to wait for the texture + // rendering to complete before it starts the distortion rendering, + // but without triggering a CPU/GPU synchronization + glWaitSync(syncObject, 0, GL_TIMEOUT_IGNORED); + + GLuint textureId = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)); for_each_eye([&](ovrEyeType eye) { ovrGLTexture & glEyeTexture = reinterpret_cast(_eyeTextures[eye]); glEyeTexture.OGL.TexId = textureId; }); + // restore our normal viewport ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures); glCanvas->makeCurrent();