From e5071deac77c00e6f4e57117f18f18d399dd75f1 Mon Sep 17 00:00:00 2001 From: The Judge Date: Tue, 17 Dec 2024 20:04:55 -0800 Subject: [PATCH] Revert "Change vloader path" This reverts commit ab016d30c33f5549ff8c5c9bbafde89fe43c8866. --- src/main/jni/libopenxr_loader.so | 4 +-- src/main/jni/vloader.cpp | 46 +++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/jni/libopenxr_loader.so b/src/main/jni/libopenxr_loader.so index 35d27bee..4566e333 100644 --- a/src/main/jni/libopenxr_loader.so +++ b/src/main/jni/libopenxr_loader.so @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:547bc81d961b6830c6e2e6d19fb417cf583ebcba0819bb26f84d9fbabf8acb97 -size 1583672 +oid sha256:3c99b192c4f37c70240163377d960b57e8a05ea746464d7e0b6c94c4ec55ea0c +size 1579592 diff --git a/src/main/jni/vloader.cpp b/src/main/jni/vloader.cpp index c45065b5..338c4aab 100644 --- a/src/main/jni/vloader.cpp +++ b/src/main/jni/vloader.cpp @@ -18,19 +18,19 @@ extern "C" JNIEXPORT jlong JNICALL -Java_org_digitalgenesis_VLoader_getEGLDisplay(JNIEnv* env, jclass clazz) { +Java_org_vivecraft_util_VLoader_getEGLDisplay(JNIEnv* env, jclass clazz) { return reinterpret_cast(eglGetCurrentDisplay()); } extern "C" JNIEXPORT jlong JNICALL -Java_org_digitalgenesis_VLoader_getEGLContext(JNIEnv* env, jclass clazz) { +Java_org_vivecraft_util_VLoader_getEGLContext(JNIEnv* env, jclass clazz) { return reinterpret_cast(eglGetCurrentContext()); } extern "C" JNIEXPORT jlong JNICALL -Java_org_digitalgenesis_VLoader_getEGLConfig(JNIEnv* env, jclass clazz) { +Java_org_vivecraft_util_VLoader_getEGLConfig(JNIEnv* env, jclass clazz) { EGLConfig cfg; EGLint num_configs; @@ -51,22 +51,44 @@ Java_org_digitalgenesis_VLoader_getEGLConfig(JNIEnv* env, jclass clazz) { } extern "C" -JNIEXPORT jlong JNICALL -Java_org_digitalgenesis_VLoader_getDalvikVM(JNIEnv* env, jclass clazz) { - return reinterpret_cast(pojav_environ->dalvikJavaVMPtr); +JNIEXPORT void JNICALL +Java_org_vivecraft_util_VLoader_initOpenXRLoader(JNIEnv* env, jclass clazz) { + PFN_xrInitializeLoaderKHR initializeLoader = nullptr; + XrResult res; + + res = xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", + (PFN_xrVoidFunction *) (&initializeLoader)); + + if (!XR_SUCCEEDED(res)) { + printf("xrGetInstanceProcAddr returned %d.\n", res); + } + + XrLoaderInitInfoAndroidKHR loaderInitInfoAndroidKhr = { + XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR, + nullptr, + (void *) pojav_environ->dalvikJavaVMPtr, + (void *) pojav_environ->activity + }; + + res = initializeLoader((const XrLoaderInitInfoBaseHeaderKHR *) &loaderInitInfoAndroidKhr); + if (!XR_SUCCEEDED(res)) { + printf("xrInitializeLoaderKHR returned %d.\n", res); + } + + JNIEnv *newEnv; + pojav_environ->dalvikJavaVMPtr->AttachCurrentThread(&newEnv, NULL); } extern "C" JNIEXPORT jlong JNICALL -Java_org_digitalgenesis_VLoader_getDalvikActivity(JNIEnv* env, jclass clazz) { - return reinterpret_cast(pojav_environ->activity); +Java_org_vivecraft_util_VLoader_getDalvikVM(JNIEnv* env, jclass clazz) { + return reinterpret_cast(pojav_environ->dalvikJavaVMPtr); } extern "C" -JNIEXPORT void JNICALL -Java_org_digitalgenesis_VLoader_setupAndroid(JNIEnv* env, jclass clazz) { - JNIEnv *newEnv; - pojav_environ->dalvikJavaVMPtr->AttachCurrentThread(&newEnv, NULL); +JNIEXPORT jlong JNICALL +Java_org_vivecraft_util_VLoader_getDalvikActivity(JNIEnv* env, jclass clazz) { + return reinterpret_cast(pojav_environ->activity); } extern "C"