From b53941070a7c50a2dfbf80d29ee7b8eca8998a6e Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Fri, 3 Apr 2020 21:42:57 +0200 Subject: [PATCH] Workaround for Oculus Layers halo artifact (#3105) --- app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp | 9 ++++----- app/src/oculusvr/cpp/OculusVRLayers.cpp | 7 ++++++- app/src/oculusvr/cpp/OculusVRLayers.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp index 8bdf55d77..abd499d4b 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp @@ -148,12 +148,11 @@ struct DeviceDelegateOculusVR::State { initialized = true; std::string version = vrapi_GetVersionString(); if (version.find("1.1.32.0") != std::string::npos) { - VRB_ERROR("Disable layers due to driver bug. VRAPI Runtime Version: %s", vrapi_GetVersionString()); - layersEnabled = false; - VRBrowser::DisableLayers(); - } else { - layersEnabled = VRBrowser::AreLayersEnabled(); + VRB_ERROR("Force layer clip due to driver bug. VRAPI Runtime Version: %s",vrapi_GetVersionString()); + OculusLayer::sForceClip = true; } + + layersEnabled = VRBrowser::AreLayersEnabled(); SetRenderSize(device::RenderMode::StandAlone); for (int i = 0; i < VRAPI_EYE_COUNT; ++i) { diff --git a/app/src/oculusvr/cpp/OculusVRLayers.cpp b/app/src/oculusvr/cpp/OculusVRLayers.cpp index a751ab09a..28f766183 100644 --- a/app/src/oculusvr/cpp/OculusVRLayers.cpp +++ b/app/src/oculusvr/cpp/OculusVRLayers.cpp @@ -12,6 +12,7 @@ static ovrMatrix4f ovrMatrixFrom(const vrb::Matrix &aMatrix) { return m; } +bool OculusLayer::sForceClip = false; // OculusLayerQuad @@ -40,7 +41,7 @@ OculusLayerQuad::Update(const ovrTracking2& aTracking, ovrTextureSwapChain* aCle vrb::Matrix scale = vrb::Matrix::Identity(); scale.ScaleInPlace(vrb::Vector(w * 0.5f, h * 0.5f, 1.0f)); - bool clip = false; + bool clip = sForceClip; for (int i = 0; i < VRAPI_FRAME_LAYER_EYE_MAX; ++i) { device::Eye eye = i == 0 ? device::Eye::Left : device::Eye::Right; @@ -108,6 +109,10 @@ OculusLayerCylinder::Update(const ovrTracking2& aTracking, ovrTextureSwapChain* ovrLayer.Textures[i].TextureRect.width = 1.0f; ovrLayer.Textures[i].TextureRect.height = 1.0f; } + + if (sForceClip) { + SetClipEnabled(true); + } } diff --git a/app/src/oculusvr/cpp/OculusVRLayers.h b/app/src/oculusvr/cpp/OculusVRLayers.h index 59495b7c3..c9440c646 100644 --- a/app/src/oculusvr/cpp/OculusVRLayers.h +++ b/app/src/oculusvr/cpp/OculusVRLayers.h @@ -30,6 +30,7 @@ typedef std::weak_ptr SurfaceChangedTargetWeakPtr; class OculusLayer { public: + static bool sForceClip; virtual void Init(JNIEnv *aEnv, vrb::RenderContextPtr &aContext) = 0; virtual void Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) = 0; virtual ovrTextureSwapChain *GetSwapChain() const = 0;