Merge pull request #71450 from BastiaanOlij/fix_openxr_init_failure

Fixes issue where failed start of OpenXR causes issues
This commit is contained in:
Rémi Verschelde 2023-01-19 10:08:50 +01:00
commit bcb57b42f6
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 15 additions and 0 deletions

View file

@ -560,6 +560,12 @@ void OpenXRAPI::destroy_instance() {
instance = XR_NULL_HANDLE;
}
enabled_extensions.clear();
if (graphics_extension != nullptr) {
unregister_extension_wrapper(graphics_extension);
memdelete(graphics_extension);
graphics_extension = nullptr;
}
}
bool OpenXRAPI::create_session() {
@ -1347,6 +1353,10 @@ void OpenXRAPI::register_extension_wrapper(OpenXRExtensionWrapper *p_extension_w
registered_extension_wrappers.push_back(p_extension_wrapper);
}
void OpenXRAPI::unregister_extension_wrapper(OpenXRExtensionWrapper *p_extension_wrapper) {
registered_extension_wrappers.erase(p_extension_wrapper);
}
void OpenXRAPI::register_extension_metadata() {
for (OpenXRExtensionWrapper *extension_wrapper : registered_extension_wrappers) {
extension_wrapper->on_register_metadata();

View file

@ -312,6 +312,7 @@ public:
void set_xr_interface(OpenXRInterface *p_xr_interface);
static void register_extension_wrapper(OpenXRExtensionWrapper *p_extension_wrapper);
static void unregister_extension_wrapper(OpenXRExtensionWrapper *p_extension_wrapper);
static void register_extension_metadata();
static void cleanup_extension_wrappers();

View file

@ -111,6 +111,10 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) {
ERR_FAIL_NULL(openxr_api);
if (!openxr_api->initialize(Main::get_rendering_driver_name())) {
OS::get_singleton()->alert("OpenXR was requested but failed to start.\n"
"Please check if your HMD is connected.\n"
"When using Windows MR please note that WMR only has DirectX support, make sure SteamVR is your default OpenXR runtime.\n"
"Godot will start in normal mode.\n");
memdelete(openxr_api);
openxr_api = nullptr;
return;