Skip to content

Commit

Permalink
OpenXR: Fix "Attempt to reinitialize" not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Aug 25, 2023
1 parent 30ff905 commit 06056b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/mods/vr/runtimes/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ void OpenXR::destroy() {
xrDestroySession(this->session);
}

if (this->instance != nullptr) {
/*if (this->instance != nullptr) {
xrDestroyInstance(this->instance);
this->instance = nullptr;
}
}*/

this->session = nullptr;
this->session_ready = false;
Expand Down
5 changes: 4 additions & 1 deletion src/mods/vr/runtimes/OpenXR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ struct OpenXR final : public VRRuntime {
std::recursive_mutex event_mtx{};
std::recursive_mutex swapchain_mtx{};

XrInstance instance{XR_NULL_HANDLE};
// Making it static because for some reason destroying it doesn't actually completely destroy everything.
// So we must make sure it always exists if we ever re-initialize OpenXR.
static inline XrInstance instance{XR_NULL_HANDLE};

XrSession session{XR_NULL_HANDLE};
XrSpace stage_space{XR_NULL_HANDLE};
XrSpace view_space{XR_NULL_HANDLE}; // for generating view matrices
Expand Down

0 comments on commit 06056b8

Please sign in to comment.