Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Workaround for Oculus Layers halo artifact (#3105)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored Apr 3, 2020
1 parent f1b2f07 commit b539410
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 4 additions & 5 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion app/src/oculusvr/cpp/OculusVRLayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ static ovrMatrix4f ovrMatrixFrom(const vrb::Matrix &aMatrix) {
return m;
}

bool OculusLayer::sForceClip = false;

// OculusLayerQuad

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}


Expand Down
1 change: 1 addition & 0 deletions app/src/oculusvr/cpp/OculusVRLayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef std::weak_ptr<SurfaceChangedTarget> 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;
Expand Down

0 comments on commit b539410

Please sign in to comment.