From 03966947156d65b31ca8c73b0bf78831eaf5dba4 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 4 Aug 2016 13:44:16 -0700 Subject: [PATCH] Fix initial state of view correction, plus overkill --- .../src/display-plugins/OpenGLDisplayPlugin.cpp | 8 ++++++++ .../src/display-plugins/hmd/HmdDisplayPlugin.cpp | 1 - libraries/gpu-gl/src/gpu/gl/GLBackend.h | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index fad929ffba..ab1a48606e 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -105,6 +105,12 @@ public: virtual void run() override { + // FIXME determine the best priority balance between this and the main thread... + // It may be dependent on the display plugin being used, since VR plugins should + // have higher priority on rendering (although we could say that the Oculus plugin + // doesn't need that since it has async timewarp). + // A higher priority here + setPriority(QThread::HighPriority); OpenGLDisplayPlugin* currentPlugin{ nullptr }; Q_ASSERT(_context); while (!_shutdown) { @@ -302,6 +308,8 @@ void OpenGLDisplayPlugin::customizeContext() { Q_ASSERT(thread() == presentThread->thread()); enableVsync(); + getGLBackend()->setCameraCorrection(mat4()); + for (auto& cursorValue : _cursorsData) { auto& cursorData = cursorValue.second; if (!cursorData.texture) { diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 6396d0d368..ebaf2a2532 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -118,7 +118,6 @@ void HmdDisplayPlugin::customizeContext() { void HmdDisplayPlugin::uncustomizeContext() { _overlayRenderer = OverlayRenderer(); - getGLBackend()->setCameraCorrection(mat4()); Parent::uncustomizeContext(); } diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.h b/libraries/gpu-gl/src/gpu/gl/GLBackend.h index 59dbfb0cbd..f130db0ade 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.h @@ -338,6 +338,11 @@ protected: GLState* _state { nullptr }; bool _invalidState { false }; + + PipelineStageState() { + _cameraCorrectionBuffer.edit() = CameraCorrection(); + _cameraCorrectionBuffer._buffer->flush(); + } } _pipeline; // Synchronize the state cache of this Backend with the actual real state of the GL Context