mirror of
https://github.com/godotengine/godot
synced 2024-09-05 19:19:43 +00:00
OpenXR: Fix initialization warning on Android
This commit adds proper checking for XR_KHR_loader_init support and fixes the warning regarding missing extensions on Android to only appear if neither XR_KHR_loader_init nor XR_KHR_loader_init_android are supported by the runtime.
This commit is contained in:
parent
9c02bf1b11
commit
b51acac638
|
@ -51,18 +51,17 @@ OpenXRAndroidExtension::OpenXRAndroidExtension() {
|
|||
HashMap<String, bool *> OpenXRAndroidExtension::get_requested_extensions() {
|
||||
HashMap<String, bool *> request_extensions;
|
||||
|
||||
request_extensions[XR_KHR_LOADER_INIT_ANDROID_EXTENSION_NAME] = &loader_init_extension_available;
|
||||
request_extensions[XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME] = &create_instance_extension_available;
|
||||
|
||||
return request_extensions;
|
||||
}
|
||||
|
||||
void OpenXRAndroidExtension::on_before_instance_created() {
|
||||
if (!loader_init_extension_available) {
|
||||
print_line("OpenXR: XR_KHR_loader_init_android is not reported as available - trying to initialize anyway...");
|
||||
if (XR_FAILED(EXT_TRY_INIT_XR_FUNC(xrInitializeLoaderKHR))) {
|
||||
// XR_KHR_loader_init not supported on this platform
|
||||
return;
|
||||
}
|
||||
|
||||
EXT_INIT_XR_FUNC(xrInitializeLoaderKHR);
|
||||
loader_init_extension_available = true;
|
||||
|
||||
JNIEnv *env = get_jni_env();
|
||||
JavaVM *vm;
|
||||
|
@ -85,6 +84,9 @@ static XrInstanceCreateInfoAndroidKHR instance_create_info;
|
|||
|
||||
void *OpenXRAndroidExtension::set_instance_create_info_and_get_next_pointer(void *p_next_pointer) {
|
||||
if (!create_instance_extension_available) {
|
||||
if (!loader_init_extension_available) {
|
||||
WARN_PRINT("No Android extensions available, couldn't pass JVM and Activity to OpenXR");
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1224,8 +1224,12 @@ bool OpenXRAPI::resolve_instance_openxr_symbols() {
|
|||
return true;
|
||||
}
|
||||
|
||||
XrResult OpenXRAPI::try_get_instance_proc_addr(const char *p_name, PFN_xrVoidFunction *p_addr) {
|
||||
return xrGetInstanceProcAddr(instance, p_name, p_addr);
|
||||
}
|
||||
|
||||
XrResult OpenXRAPI::get_instance_proc_addr(const char *p_name, PFN_xrVoidFunction *p_addr) {
|
||||
XrResult result = xrGetInstanceProcAddr(instance, p_name, p_addr);
|
||||
XrResult result = try_get_instance_proc_addr(p_name, p_addr);
|
||||
|
||||
if (result != XR_SUCCESS) {
|
||||
String error_message = String("Symbol ") + p_name + " not found in OpenXR instance.";
|
||||
|
|
|
@ -305,6 +305,7 @@ public:
|
|||
static bool openxr_is_enabled(bool p_check_run_in_editor = true);
|
||||
_FORCE_INLINE_ static OpenXRAPI *get_singleton() { return singleton; }
|
||||
|
||||
XrResult try_get_instance_proc_addr(const char *p_name, PFN_xrVoidFunction *p_addr);
|
||||
XrResult get_instance_proc_addr(const char *p_name, PFN_xrVoidFunction *p_addr);
|
||||
String get_error_string(XrResult result);
|
||||
String get_swapchain_format_name(int64_t p_swapchain_format) const;
|
||||
|
|
|
@ -53,6 +53,12 @@
|
|||
#define EXT_INIT_XR_FUNC(name) INIT_XR_FUNC(OpenXRAPI::get_singleton(), name)
|
||||
#define OPENXR_API_INIT_XR_FUNC(name) INIT_XR_FUNC(this, name)
|
||||
|
||||
#define TRY_INIT_XR_FUNC(openxr_api, name) \
|
||||
openxr_api->try_get_instance_proc_addr(#name, (PFN_xrVoidFunction *)&name##_ptr)
|
||||
|
||||
#define EXT_TRY_INIT_XR_FUNC(name) TRY_INIT_XR_FUNC(OpenXRAPI::get_singleton(), name)
|
||||
#define OPENXR_TRY_API_INIT_XR_FUNC(name) TRY_INIT_XR_FUNC(this, name)
|
||||
|
||||
#define EXT_PROTO_XRRESULT_FUNC1(func_name, arg1_type, arg1) \
|
||||
PFN_##func_name func_name##_ptr = nullptr; \
|
||||
XRAPI_ATTR XrResult XRAPI_CALL func_name(UNPACK arg1_type p_##arg1) const { \
|
||||
|
|
Loading…
Reference in a new issue