The fix resets the Android global vulkan context when running in XR mode to allow the XR module to drive the initialization via vulkan hooks.
This commit is contained in:
Fredia Huya-Kouadio
2026-02-12 14:14:23 -08:00
parent 20d58a38c6
commit 0ad63522d7
2 changed files with 18 additions and 0 deletions
+16
View File
@@ -515,6 +515,22 @@ JNIEXPORT jobjectArray JNICALL Java_org_godotengine_godot_GodotLib_getRendererIn
rendering_driver_chosen = RenderingServer::get_singleton()->get_current_rendering_driver_name();
rendering_method = RenderingServer::get_singleton()->get_current_rendering_method();
}
#ifndef XR_DISABLED
// When running in XR mode, vulkan initialization must be done by the XR module, so we ensure that the vulkan
// global context is reset.
// Note: This is temporary workaround to address https://github.com/godotengine/godot/issues/115924
// A proper fix involves updating the Android init flow so that DisplayServerAndroid can update the Android surface
// type (vulkan or opengl) after it's initialized.
bool xr_enabled = false;
if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) {
xr_enabled = GLOBAL_GET_CACHED(bool, "xr/shaders/enabled");
} else {
xr_enabled = XRServer::get_xr_mode() == XRServer::XRMODE_ON;
}
if (xr_enabled) {
DisplayServerAndroid::free_vulkan_global_context();
}
#endif // XR_DISABLED
#endif
String rendering_driver_source = rendering_source_to_string(OS::get_singleton()->get_current_rendering_driver_name_source());