Skip to content

Commit

Permalink
Release Oculus swapChains in onDestroy instead of in each leaveVR (#3083
Browse files Browse the repository at this point in the history
)
  • Loading branch information
MortimerGoro committed Apr 1, 2020
1 parent 44406be commit ee26bb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/main/cpp/native-lib.cpp
Expand Up @@ -238,6 +238,7 @@ android_main(android_app *aAppState) {
if (aAppState->destroyRequested != 0) {
sAppContext->mEgl->MakeCurrent();
sAppContext->mQueue->ProcessRunnables();
sAppContext->mDevice->OnDestroy();
BrowserWorld::Instance().ShutdownGL();
BrowserWorld::Instance().ShutdownJava();
BrowserWorld::Destroy();
Expand Down
17 changes: 10 additions & 7 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Expand Up @@ -1236,6 +1236,16 @@ DeviceDelegateOculusVR::EnterVR(const crow::BrowserEGLContext& aEGLContext) {

void
DeviceDelegateOculusVR::LeaveVR() {
if (m.ovr) {
vrapi_LeaveVrMode(m.ovr);
m.ovr = nullptr;
}
m.currentFBO = nullptr;
m.previousFBO = nullptr;
}

void
DeviceDelegateOculusVR::OnDestroy() {
for (OculusLayerPtr& layer: m.uiLayers) {
layer->Destroy();
}
Expand All @@ -1253,13 +1263,6 @@ DeviceDelegateOculusVR::LeaveVR() {
vrapi_DestroyTextureSwapChain(m.clearColorSwapChain);
m.clearColorSwapChain = nullptr;
}
m.currentFBO = nullptr;
m.previousFBO = nullptr;

if (m.ovr) {
vrapi_LeaveVrMode(m.ovr);
m.ovr = nullptr;
}
}

bool
Expand Down
1 change: 1 addition & 0 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.h
Expand Up @@ -57,6 +57,7 @@ class DeviceDelegateOculusVR : public DeviceDelegate {
// Custom methods for NativeActivity render loop based devices.
void EnterVR(const crow::BrowserEGLContext& aEGLContext);
void LeaveVR();
void OnDestroy();
bool IsInVRMode() const;
bool ExitApp();
protected:
Expand Down

0 comments on commit ee26bb6

Please sign in to comment.