From ffc2c75534345f0bc099004e847e96b3b8b23e9b Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 5 Apr 2016 09:59:12 -0700 Subject: [PATCH 1/3] Don't release the Oculus plugin when disabling the plugin --- plugins/oculus/src/OculusHelpers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/oculus/src/OculusHelpers.cpp b/plugins/oculus/src/OculusHelpers.cpp index c9e702ecd0..9d3f95a979 100644 --- a/plugins/oculus/src/OculusHelpers.cpp +++ b/plugins/oculus/src/OculusHelpers.cpp @@ -90,12 +90,14 @@ ovrSession acquireOculusSession() { void releaseOculusSession() { Q_ASSERT(refCount > 0 && session); +#if 0 if (!--refCount) { qCDebug(oculus) << "oculus: zero refcount, shutdown SDK and session"; ovr_Destroy(session); ovr_Shutdown(); session = nullptr; } +#endif } From 71e6f9bdd67f2f97f9c6e49452fd420a8c9a1c76 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 5 Apr 2016 13:03:14 -0700 Subject: [PATCH 2/3] Display a blank frame before switching away from oculus --- plugins/oculus/src/OculusDisplayPlugin.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/oculus/src/OculusDisplayPlugin.cpp b/plugins/oculus/src/OculusDisplayPlugin.cpp index a53643ba21..78a38d2b6a 100644 --- a/plugins/oculus/src/OculusDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusDisplayPlugin.cpp @@ -52,6 +52,16 @@ void OculusDisplayPlugin::customizeContext() { } void OculusDisplayPlugin::uncustomizeContext() { + using namespace oglplus; + + // Present a final black frame to the HMD + _compositeFramebuffer->Bound(FramebufferTarget::Draw, [] { + Context::ClearColor(0, 0, 0, 1); + Context::Clear().ColorBuffer(); + }); + + hmdPresent(); + #if (OVR_MAJOR_VERSION >= 6) _sceneFbo.reset(); #endif From fd4a374e088decbaca7780b692519d449032eef0 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 5 Apr 2016 13:04:17 -0700 Subject: [PATCH 3/3] Add comment --- plugins/oculus/src/OculusHelpers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/oculus/src/OculusHelpers.cpp b/plugins/oculus/src/OculusHelpers.cpp index 9d3f95a979..71342f6e1b 100644 --- a/plugins/oculus/src/OculusHelpers.cpp +++ b/plugins/oculus/src/OculusHelpers.cpp @@ -90,6 +90,8 @@ ovrSession acquireOculusSession() { void releaseOculusSession() { Q_ASSERT(refCount > 0 && session); + // HACK the Oculus runtime doesn't seem to play well with repeated shutdown / restart. + // So for now we'll just hold on to the session #if 0 if (!--refCount) { qCDebug(oculus) << "oculus: zero refcount, shutdown SDK and session";