attempt fix blank + updated x64 libs

This commit is contained in:
khanhduytran0 2021-11-09 18:57:03 +07:00
parent 04cc1f4646
commit 0967dae16c
3 changed files with 11 additions and 30 deletions

View File

@ -36,8 +36,6 @@ LOCAL_SRC_FILES := \
input_bridge_v3.c \ input_bridge_v3.c \
jre_launcher.c \ jre_launcher.c \
utils.c utils.c
LOCAL_SHARED_LIBRARIES := xhook
LOCAL_C_INCLUDES := $(LOCAL_PATH)/xhook
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)

View File

@ -664,6 +664,9 @@ void pojavTerminate() {
JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, jclass clazz, jobject surface) { JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, jclass clazz, jobject surface) {
potatoBridge.androidWindow = ANativeWindow_fromSurface(env, surface); potatoBridge.androidWindow = ANativeWindow_fromSurface(env, surface);
char *ptrStr = malloc(sizeof(long));
sprintf(ptrStr, "%ld", (long) potatoBridge.androidWindow);
setenv("POJAV_WINDOW_PTR", ptrStr, 1);
} }
void* pojavGetCurrentContext() { void* pojavGetCurrentContext() {
@ -762,6 +765,7 @@ bool loadSymbolsVirGL() {
} }
int pojavInit() { int pojavInit() {
potatoBridge.androidWindow = (void *)atol(getenv("POJAV_WINDOW_PTR"));
ANativeWindow_acquire(potatoBridge.androidWindow); ANativeWindow_acquire(potatoBridge.androidWindow);
savedWidth = ANativeWindow_getWidth(potatoBridge.androidWindow); savedWidth = ANativeWindow_getWidth(potatoBridge.androidWindow);
savedHeight = ANativeWindow_getHeight(potatoBridge.androidWindow); savedHeight = ANativeWindow_getHeight(potatoBridge.androidWindow);
@ -1032,22 +1036,19 @@ Java_org_lwjgl_glfw_GLFW_nativeEglDetachOnCurrentThread(JNIEnv *env, jclass claz
} }
*/ */
JNIEXPORT jlong JNICALL void* pojavCreateContext(void* contextSrc) {
Java_org_lwjgl_glfw_GLFW_nativeEglCreateContext(JNIEnv *env, jclass clazz, jlong contextSrc) {
if (config_renderer == RENDERER_GL4ES) { if (config_renderer == RENDERER_GL4ES) {
const EGLint ctx_attribs[] = { const EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, atoi(getenv("LIBGL_ES")), EGL_CONTEXT_CLIENT_VERSION, atoi(getenv("LIBGL_ES")),
EGL_NONE EGL_NONE
}; };
EGLContext* ctx = eglCreateContext_p(potatoBridge.eglDisplay, config, (void*)contextSrc, ctx_attribs); EGLContext* ctx = eglCreateContext_p(potatoBridge.eglDisplay, config, (void*)contextSrc, ctx_attribs);
potatoBridge.eglContext = ctx; potatoBridge.eglContext = ctx;
printf("EGLBridge: Created CTX pointer = %p\n",ctx); printf("EGLBridge: Created CTX pointer = %p\n",ctx);
//(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception"); //(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception");
return (long)ctx; return (long)ctx;
} }
if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) { if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) {
printf("OSMDroid: generating context\n"); printf("OSMDroid: generating context\n");
void* ctx = OSMesaCreateContext_p(OSMESA_RGBA,contextSrc); void* ctx = OSMesaCreateContext_p(OSMESA_RGBA,contextSrc);
@ -1082,7 +1083,7 @@ void pojavSwapInterval(int interval) {
case RENDERER_VIRGL: { case RENDERER_VIRGL: {
eglSwapInterval_p(potatoBridge.eglDisplay, interval); eglSwapInterval_p(potatoBridge.eglDisplay, interval);
} break; } break;
case RENDERER_VK_ZINK: { case RENDERER_VK_ZINK: {
printf("eglSwapInterval: NOT IMPLEMENTED YET!\n"); printf("eglSwapInterval: NOT IMPLEMENTED YET!\n");
// Nothing to do here // Nothing to do here

View File

@ -33,8 +33,6 @@
// Boardwalk: missing include // Boardwalk: missing include
#include <string.h> #include <string.h>
#include <xhook.h>
#include "log.h" #include "log.h"
#include "utils.h" #include "utils.h"
@ -85,18 +83,9 @@ typedef jint JLI_Launch_func(int argc, char ** argv, /* main argc, argc */
jint ergo /* ergonomics class policy */ jint ergo /* ergonomics class policy */
); );
void* (*old_dlopen)(const char *filename, int flags);
void* custom_dlopen(const char *filename, int flags) {
if (flags == (RTLD_LAZY | RTLD_LOCAL)) {
return old_dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
} else {
return old_dlopen(filename, flags);
}
}
static jint launchJVM(int margc, char** margv) { static jint launchJVM(int margc, char** margv) {
void* libjli = dlopen("libjli.so", RTLD_LAZY | RTLD_GLOBAL); void* libjli = dlopen("libjli.so", RTLD_LAZY | RTLD_GLOBAL);
// Boardwalk: silence // Boardwalk: silence
// LOGD("JLI lib = %x", (int)libjli); // LOGD("JLI lib = %x", (int)libjli);
if (NULL == libjli) { if (NULL == libjli) {
@ -170,13 +159,6 @@ JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env,
CATCHSIG(SIGXFSZ); CATCHSIG(SIGXFSZ);
//Signal trapper ready //Signal trapper ready
// Since we have moved from JNI call to LWJGL call for fixing GL context
// set incorrectly, we're facing another problem: fields in the previously
// loaded pojavexec aren't shared to LWJGL loaded one, is it because
// of RTLD_LOCAL? hook moment.
xhook_register(".*/liblwjgl.so$","dlopen",custom_dlopen,&old_dlopen);
xhook_refresh(1);
// Save dalvik JNIEnv pointer for JVM launch thread // Save dalvik JNIEnv pointer for JVM launch thread
dalvikJNIEnvPtr_ANDROID = env; dalvikJNIEnvPtr_ANDROID = env;
@ -188,15 +170,15 @@ JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env,
int argc = (*env)->GetArrayLength(env, argsArray); int argc = (*env)->GetArrayLength(env, argsArray);
char **argv = convert_to_char_array(env, argsArray); char **argv = convert_to_char_array(env, argsArray);
LOGD("Done processing args"); LOGD("Done processing args");
res = launchJVM(argc, argv); res = launchJVM(argc, argv);
LOGD("Going to free args"); LOGD("Going to free args");
free_char_array(env, argsArray, argv); free_char_array(env, argsArray, argv);
LOGD("Free done"); LOGD("Free done");
return res; return res;
} }