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

Commit

Permalink
Recreate SwapChain before binding if the target FBO is invalid (#3713)
Browse files Browse the repository at this point in the history
Fixes #3712
  • Loading branch information
MortimerGoro authored and bluemarvin committed Jul 22, 2020
1 parent f3bbaef commit 797d8c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,15 @@ DeviceDelegateOculusVR::BindEye(const device::Eye aWhich) {

const auto &swapChain = m.eyeSwapChains[index];
int swapChainIndex = m.frameIndex % swapChain->swapChainLength;
m.currentFBO = swapChain->fbos[swapChainIndex];
m.currentFBO = swapChain->FBO(swapChainIndex);
if (!m.currentFBO || !m.currentFBO->IsValid()) {
// See https://github.com/MozillaReality/FirefoxReality/issues/3712
// There are some crash reports of invalid eye SwapChain FBOs. Try to recreate it.
VRB_LOG("Recreate SwapChain because no valid FBO was found");
auto render = m.context.lock();
swapChain->Init(render, m.renderMode, m.renderWidth, m.renderHeight);
m.currentFBO = swapChain->FBO(swapChainIndex);
}

if (m.currentFBO) {
m.currentFBO->Bind();
Expand Down
7 changes: 7 additions & 0 deletions app/src/oculusvr/cpp/OculusSwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ OculusEyeSwapChain::Destroy() {
swapChainLength = 0;
}

vrb::FBOPtr OculusEyeSwapChain::FBO(const int32_t aIndex) {
if (aIndex >=0 && aIndex < fbos.size()) {
return fbos[aIndex];
}
return nullptr;
}

}
4 changes: 3 additions & 1 deletion app/src/oculusvr/cpp/OculusSwapChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ class OculusEyeSwapChain {
public:
ovrTextureSwapChain *ovrSwapChain = nullptr;
int swapChainLength = 0;
std::vector<vrb::FBOPtr> fbos;

static OculusEyeSwapChainPtr create();
void Init(vrb::RenderContextPtr &aContext, device::RenderMode aMode, uint32_t aWidth, uint32_t aHeight);
void Destroy();
vrb::FBOPtr FBO(const int32_t aIndex);
private:
std::vector<vrb::FBOPtr> fbos;
};

}

0 comments on commit 797d8c1

Please sign in to comment.