mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -04:00
Fix the occasional eglCreateContext_p 3005
Also, move everything. Now the big libs have their respective loaders.
This commit is contained in:
parent
a7b0a10410
commit
fa52554163
@ -33,7 +33,9 @@ LOCAL_MODULE := pojavexec
|
|||||||
# -DGLES_TEST
|
# -DGLES_TEST
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
egl_bridge.c \
|
egl_bridge.c \
|
||||||
gl_bridge.c \
|
ctxbridges/gl_bridge.c \
|
||||||
|
ctxbridges/egl_loader.c \
|
||||||
|
ctxbridges/osmesa_loader.c \
|
||||||
input_bridge_v3.c \
|
input_bridge_v3.c \
|
||||||
jre_launcher.c \
|
jre_launcher.c \
|
||||||
utils.c
|
utils.c
|
||||||
|
51
app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c
Normal file
51
app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// Created by maks on 21.09.2022.
|
||||||
|
//
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include "egl_loader.h"
|
||||||
|
|
||||||
|
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||||
|
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
|
||||||
|
EGLBoolean (*eglDestroySurface_p) (EGLDisplay dpy, EGLSurface surface);
|
||||||
|
EGLBoolean (*eglTerminate_p) (EGLDisplay dpy);
|
||||||
|
EGLBoolean (*eglReleaseThread_p) (void);
|
||||||
|
EGLContext (*eglGetCurrentContext_p) (void);
|
||||||
|
EGLDisplay (*eglGetDisplay_p) (NativeDisplayType display);
|
||||||
|
EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||||
|
EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||||
|
EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
||||||
|
EGLBoolean (*eglBindAPI_p) (EGLenum api);
|
||||||
|
EGLSurface (*eglCreatePbufferSurface_p) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||||
|
EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
|
||||||
|
EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
|
||||||
|
EGLint (*eglGetError_p) (void);
|
||||||
|
EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
|
||||||
|
EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
|
||||||
|
EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
|
||||||
|
|
||||||
|
void dlsym_EGL() {
|
||||||
|
void* dl_handle = NULL;
|
||||||
|
if(getenv("POJAVEXEC_EGL")) dl_handle = dlopen(getenv("POJAVEXEC_EGL"), RTLD_LAZY);
|
||||||
|
if(dl_handle == NULL) dl_handle = dlopen("libEGL.so", RTLD_LAZY);
|
||||||
|
if(dl_handle == NULL) abort();
|
||||||
|
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
|
||||||
|
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
|
||||||
|
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
|
||||||
|
eglCreatePbufferSurface_p = dlsym(dl_handle, "eglCreatePbufferSurface");
|
||||||
|
eglCreateWindowSurface_p = dlsym(dl_handle, "eglCreateWindowSurface");
|
||||||
|
eglDestroyContext_p = dlsym(dl_handle, "eglDestroyContext");
|
||||||
|
eglDestroySurface_p = dlsym(dl_handle, "eglDestroySurface");
|
||||||
|
eglGetConfigAttrib_p = dlsym(dl_handle, "eglGetConfigAttrib");
|
||||||
|
eglGetCurrentContext_p = dlsym(dl_handle, "eglGetCurrentContext");
|
||||||
|
eglGetDisplay_p = dlsym(dl_handle, "eglGetDisplay");
|
||||||
|
eglGetError_p = dlsym(dl_handle, "eglGetError");
|
||||||
|
eglInitialize_p = dlsym(dl_handle, "eglInitialize");
|
||||||
|
eglMakeCurrent_p = dlsym(dl_handle, "eglMakeCurrent");
|
||||||
|
eglSwapBuffers_p = dlsym(dl_handle, "eglSwapBuffers");
|
||||||
|
eglReleaseThread_p = dlsym(dl_handle, "eglReleaseThread");
|
||||||
|
eglSwapInterval_p = dlsym(dl_handle, "eglSwapInterval");
|
||||||
|
eglTerminate_p = dlsym(dl_handle, "eglTerminate");
|
||||||
|
eglGetCurrentSurface_p = dlsym(dl_handle,"eglGetCurrentSurface");
|
||||||
|
}
|
29
app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.h
Normal file
29
app_pojavlauncher/src/main/jni/ctxbridges/egl_loader.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// Created by maks on 21.09.2022.
|
||||||
|
//
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#ifndef POJAVLAUNCHER_EGL_LOADER_H
|
||||||
|
#define POJAVLAUNCHER_EGL_LOADER_H
|
||||||
|
|
||||||
|
extern EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||||
|
extern EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
|
||||||
|
extern EGLBoolean (*eglDestroySurface_p) (EGLDisplay dpy, EGLSurface surface);
|
||||||
|
extern EGLBoolean (*eglTerminate_p) (EGLDisplay dpy);
|
||||||
|
extern EGLBoolean (*eglReleaseThread_p) (void);
|
||||||
|
extern EGLContext (*eglGetCurrentContext_p) (void);
|
||||||
|
extern EGLDisplay (*eglGetDisplay_p) (NativeDisplayType display);
|
||||||
|
extern EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||||
|
extern EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||||
|
extern EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
||||||
|
extern EGLBoolean (*eglBindAPI_p) (EGLenum api);
|
||||||
|
extern EGLSurface (*eglCreatePbufferSurface_p) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||||
|
extern EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
|
||||||
|
extern EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
|
||||||
|
extern EGLint (*eglGetError_p) (void);
|
||||||
|
extern EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
|
||||||
|
extern EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
|
||||||
|
extern EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
|
||||||
|
|
||||||
|
void dlsym_EGL();
|
||||||
|
|
||||||
|
#endif //POJAVLAUNCHER_EGL_LOADER_H
|
@ -7,6 +7,7 @@
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "gl_bridge.h"
|
#include "gl_bridge.h"
|
||||||
|
#include "egl_loader.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Created by maks on 17.09.2022.
|
// Created by maks on 17.09.2022.
|
||||||
@ -16,57 +17,15 @@
|
|||||||
#define STATE_RENDERER_NEW_WINDOW 1
|
#define STATE_RENDERER_NEW_WINDOW 1
|
||||||
static char* g_LogTag = "GLBridge";
|
static char* g_LogTag = "GLBridge";
|
||||||
|
|
||||||
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
|
||||||
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
|
|
||||||
EGLBoolean (*eglDestroySurface_p) (EGLDisplay dpy, EGLSurface surface);
|
|
||||||
EGLBoolean (*eglTerminate_p) (EGLDisplay dpy);
|
|
||||||
EGLBoolean (*eglReleaseThread_p) (void);
|
|
||||||
EGLContext (*eglGetCurrentContext_p) (void);
|
|
||||||
EGLDisplay (*eglGetDisplay_p) (NativeDisplayType display);
|
|
||||||
EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
|
|
||||||
EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
|
||||||
EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
|
||||||
EGLBoolean (*eglBindAPI_p) (EGLenum api);
|
|
||||||
EGLSurface (*eglCreatePbufferSurface_p) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
|
||||||
EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
|
|
||||||
EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
|
|
||||||
EGLint (*eglGetError_p) (void);
|
|
||||||
EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
|
|
||||||
EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
|
|
||||||
EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
|
|
||||||
|
|
||||||
struct ANativeWindow* newWindow;
|
struct ANativeWindow* newWindow;
|
||||||
static __thread render_bundle_t* currentBundle;
|
static __thread render_window_t* currentBundle;
|
||||||
static render_bundle_t* mainWindowBundle;
|
static render_window_t* mainWindowBundle;
|
||||||
EGLDisplay g_EglDisplay;
|
EGLDisplay g_EglDisplay;
|
||||||
|
|
||||||
void gl_dlsym_EGL() {
|
|
||||||
void* dl_handle = NULL;
|
|
||||||
if(getenv("POJAVEXEC_EGL")) dl_handle = dlopen(getenv("POJAVEXEC_EGL"), RTLD_LAZY);
|
|
||||||
if(dl_handle == NULL) dl_handle = dlopen("libEGL.so", RTLD_LAZY);
|
|
||||||
if(dl_handle == NULL) abort();
|
|
||||||
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
|
|
||||||
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
|
|
||||||
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
|
|
||||||
eglCreatePbufferSurface_p = dlsym(dl_handle, "eglCreatePbufferSurface");
|
|
||||||
eglCreateWindowSurface_p = dlsym(dl_handle, "eglCreateWindowSurface");
|
|
||||||
eglDestroyContext_p = dlsym(dl_handle, "eglDestroyContext");
|
|
||||||
eglDestroySurface_p = dlsym(dl_handle, "eglDestroySurface");
|
|
||||||
eglGetConfigAttrib_p = dlsym(dl_handle, "eglGetConfigAttrib");
|
|
||||||
eglGetCurrentContext_p = dlsym(dl_handle, "eglGetCurrentContext");
|
|
||||||
eglGetDisplay_p = dlsym(dl_handle, "eglGetDisplay");
|
|
||||||
eglGetError_p = dlsym(dl_handle, "eglGetError");
|
|
||||||
eglInitialize_p = dlsym(dl_handle, "eglInitialize");
|
|
||||||
eglMakeCurrent_p = dlsym(dl_handle, "eglMakeCurrent");
|
|
||||||
eglSwapBuffers_p = dlsym(dl_handle, "eglSwapBuffers");
|
|
||||||
eglReleaseThread_p = dlsym(dl_handle, "eglReleaseThread");
|
|
||||||
eglSwapInterval_p = dlsym(dl_handle, "eglSwapInterval");
|
|
||||||
eglTerminate_p = dlsym(dl_handle, "eglTerminate");
|
|
||||||
eglGetCurrentSurface_p = dlsym(dl_handle,"eglGetCurrentSurface");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool gl_init() {
|
bool gl_init() {
|
||||||
gl_dlsym_EGL();
|
dlsym_EGL();
|
||||||
g_EglDisplay = eglGetDisplay_p(EGL_DEFAULT_DISPLAY);
|
g_EglDisplay = eglGetDisplay_p(EGL_DEFAULT_DISPLAY);
|
||||||
if (g_EglDisplay == EGL_NO_DISPLAY) {
|
if (g_EglDisplay == EGL_NO_DISPLAY) {
|
||||||
__android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s",
|
__android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s",
|
||||||
@ -82,8 +41,8 @@ bool gl_init() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
render_bundle_t* gl_init_context(render_bundle_t *share) {
|
render_window_t* gl_init_context(render_window_t *share) {
|
||||||
render_bundle_t* bundle = malloc(sizeof(render_bundle_t));
|
render_window_t* bundle = malloc(sizeof(render_window_t));
|
||||||
const EGLint egl_attributes[] = { EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT, EGL_NONE };
|
const EGLint egl_attributes[] = { EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT, EGL_NONE };
|
||||||
EGLint num_configs = 0;
|
EGLint num_configs = 0;
|
||||||
if (eglChooseConfig_p(g_EglDisplay, egl_attributes, NULL, 0, &num_configs) != EGL_TRUE) {
|
if (eglChooseConfig_p(g_EglDisplay, egl_attributes, NULL, 0, &num_configs) != EGL_TRUE) {
|
||||||
@ -106,7 +65,7 @@ render_bundle_t* gl_init_context(render_bundle_t *share) {
|
|||||||
int libgl_es = strtol(getenv("LIBGL_ES"), NULL, 0);
|
int libgl_es = strtol(getenv("LIBGL_ES"), NULL, 0);
|
||||||
if(libgl_es < 0 || libgl_es > INT16_MAX) libgl_es = 2;
|
if(libgl_es < 0 || libgl_es > INT16_MAX) libgl_es = 2;
|
||||||
const EGLint egl_context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
|
const EGLint egl_context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
|
||||||
bundle->context = eglCreateContext_p(g_EglDisplay, bundle->context, share == NULL ? EGL_NO_CONTEXT : share->context, egl_context_attributes);
|
bundle->context = eglCreateContext_p(g_EglDisplay, bundle->config, share == NULL ? EGL_NO_CONTEXT : share->context, egl_context_attributes);
|
||||||
|
|
||||||
if (bundle->context == EGL_NO_CONTEXT) {
|
if (bundle->context == EGL_NO_CONTEXT) {
|
||||||
__android_log_print(ANDROID_LOG_ERROR, g_LogTag, "eglCreateContext_p() finished with error: %04x",
|
__android_log_print(ANDROID_LOG_ERROR, g_LogTag, "eglCreateContext_p() finished with error: %04x",
|
||||||
@ -117,7 +76,7 @@ render_bundle_t* gl_init_context(render_bundle_t *share) {
|
|||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_swap_surface(render_bundle_t* bundle) {
|
void gl_swap_surface(render_window_t* bundle) {
|
||||||
if(bundle->nativeSurface != NULL) {
|
if(bundle->nativeSurface != NULL) {
|
||||||
ANativeWindow_release(bundle->nativeSurface);
|
ANativeWindow_release(bundle->nativeSurface);
|
||||||
}
|
}
|
||||||
@ -137,7 +96,7 @@ void gl_swap_surface(render_bundle_t* bundle) {
|
|||||||
//eglMakeCurrent_p(g_EglDisplay, bundle->surface, bundle->surface, bundle->context);
|
//eglMakeCurrent_p(g_EglDisplay, bundle->surface, bundle->surface, bundle->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_make_current(render_bundle_t* bundle) {
|
void gl_make_current(render_window_t* bundle) {
|
||||||
if(bundle == NULL) {
|
if(bundle == NULL) {
|
||||||
if(eglMakeCurrent_p(g_EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
|
if(eglMakeCurrent_p(g_EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
|
||||||
currentBundle = NULL;
|
currentBundle = NULL;
|
@ -13,11 +13,11 @@ typedef struct {
|
|||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
struct ANativeWindow *nativeSurface;
|
struct ANativeWindow *nativeSurface;
|
||||||
struct ANativeWindow *newNativeSurface;
|
struct ANativeWindow *newNativeSurface;
|
||||||
} render_bundle_t;
|
} render_window_t;
|
||||||
|
|
||||||
bool gl_init();
|
bool gl_init();
|
||||||
render_bundle_t* gl_init_context(render_bundle_t* share);
|
render_window_t* gl_init_context(render_window_t* share);
|
||||||
void gl_make_current(render_bundle_t* bundle);
|
void gl_make_current(render_window_t* bundle);
|
||||||
void gl_swap_buffers();
|
void gl_swap_buffers();
|
||||||
void gl_setup_window(struct ANativeWindow* window);
|
void gl_setup_window(struct ANativeWindow* window);
|
||||||
void gl_swap_interval(int swapInterval);
|
void gl_swap_interval(int swapInterval);
|
42
app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c
Normal file
42
app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// Created by maks on 21.09.2022.
|
||||||
|
//
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include "osmesa_loader.h"
|
||||||
|
|
||||||
|
GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
|
||||||
|
GLsizei width, GLsizei height);
|
||||||
|
OSMesaContext (*OSMesaGetCurrentContext_p) (void);
|
||||||
|
OSMesaContext (*OSMesaCreateContext_p) (GLenum format, OSMesaContext sharelist);
|
||||||
|
void (*OSMesaDestroyContext_p) (OSMesaContext ctx);
|
||||||
|
void (*OSMesaPixelStore_p) ( GLint pname, GLint value );
|
||||||
|
GLubyte* (*glGetString_p) (GLenum name);
|
||||||
|
void (*glFinish_p) (void);
|
||||||
|
void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||||
|
void (*glClear_p) (GLbitfield mask);
|
||||||
|
void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);
|
||||||
|
|
||||||
|
void dlsym_OSMesa() {
|
||||||
|
char* main_path = NULL;
|
||||||
|
char* alt_path = NULL;
|
||||||
|
if(asprintf(&main_path, "%s/libOSMesa_8.so", getenv("POJAV_NATIVEDIR")) == -1 ||
|
||||||
|
asprintf(&alt_path, "%s/libOSMesa.so.8", getenv("POJAV_NATIVEDIR")) == -1) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
void* dl_handle = NULL;
|
||||||
|
dl_handle = dlopen(alt_path, RTLD_GLOBAL);
|
||||||
|
if(dl_handle == NULL) dl_handle = dlopen(main_path, RTLD_GLOBAL);
|
||||||
|
if(dl_handle == NULL) abort();
|
||||||
|
OSMesaMakeCurrent_p = dlsym(dl_handle, "OSMesaMakeCurrent");
|
||||||
|
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
|
||||||
|
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
|
||||||
|
OSMesaDestroyContext_p = dlsym(dl_handle, "OSMesaDestroyContext");
|
||||||
|
OSMesaPixelStore_p = dlsym(dl_handle,"OSMesaPixelStore");
|
||||||
|
glGetString_p = dlsym(dl_handle,"glGetString");
|
||||||
|
glClearColor_p = dlsym(dl_handle, "glClearColor");
|
||||||
|
glClear_p = dlsym(dl_handle,"glClear");
|
||||||
|
glFinish_p = dlsym(dl_handle,"glFinish");
|
||||||
|
glReadPixels_p = dlsym(dl_handle,"glReadPixels");
|
||||||
|
}
|
22
app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.h
Normal file
22
app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// Created by maks on 21.09.2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef POJAVLAUNCHER_OSMESA_LOADER_H
|
||||||
|
#define POJAVLAUNCHER_OSMESA_LOADER_H
|
||||||
|
|
||||||
|
#include <GL/osmesa.h>
|
||||||
|
|
||||||
|
extern GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
|
||||||
|
GLsizei width, GLsizei height);
|
||||||
|
extern OSMesaContext (*OSMesaGetCurrentContext_p) (void);
|
||||||
|
extern OSMesaContext (*OSMesaCreateContext_p) (GLenum format, OSMesaContext sharelist);
|
||||||
|
extern void (*OSMesaDestroyContext_p) (OSMesaContext ctx);
|
||||||
|
extern void (*OSMesaPixelStore_p) ( GLint pname, GLint value );
|
||||||
|
extern GLubyte* (*glGetString_p) (GLenum name);
|
||||||
|
extern void (*glFinish_p) (void);
|
||||||
|
extern void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||||
|
extern void (*glClear_p) (GLbitfield mask);
|
||||||
|
extern void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);
|
||||||
|
void dlsym_OSMesa();
|
||||||
|
#endif //POJAVLAUNCHER_OSMESA_LOADER_H
|
@ -21,7 +21,7 @@
|
|||||||
#include <android/rect.h>
|
#include <android/rect.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "gl_bridge.h"
|
#include "ctxbridges/gl_bridge.h"
|
||||||
// region OSMESA internals
|
// region OSMESA internals
|
||||||
|
|
||||||
struct pipe_screen;
|
struct pipe_screen;
|
||||||
@ -594,38 +594,8 @@ struct PotatoBridge {
|
|||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
struct PotatoBridge potatoBridge;
|
struct PotatoBridge potatoBridge;
|
||||||
|
|
||||||
/* OSMesa functions */
|
#include "ctxbridges/egl_loader.h"
|
||||||
GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
|
#include "ctxbridges/osmesa_loader.h"
|
||||||
GLsizei width, GLsizei height);
|
|
||||||
OSMesaContext (*OSMesaGetCurrentContext_p) (void);
|
|
||||||
OSMesaContext (*OSMesaCreateContext_p) (GLenum format, OSMesaContext sharelist);
|
|
||||||
void (*OSMesaDestroyContext_p) (OSMesaContext ctx);
|
|
||||||
void (*OSMesaPixelStore_p) ( GLint pname, GLint value );
|
|
||||||
GLubyte* (*glGetString_p) (GLenum name);
|
|
||||||
void (*glFinish_p) (void);
|
|
||||||
void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
|
||||||
void (*glClear_p) (GLbitfield mask);
|
|
||||||
void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);
|
|
||||||
|
|
||||||
/*EGL functions */
|
|
||||||
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
|
||||||
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
|
|
||||||
EGLBoolean (*eglDestroySurface_p) (EGLDisplay dpy, EGLSurface surface);
|
|
||||||
EGLBoolean (*eglTerminate_p) (EGLDisplay dpy);
|
|
||||||
EGLBoolean (*eglReleaseThread_p) (void);
|
|
||||||
EGLContext (*eglGetCurrentContext_p) (void);
|
|
||||||
EGLDisplay (*eglGetDisplay_p) (NativeDisplayType display);
|
|
||||||
EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
|
|
||||||
EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
|
||||||
EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
|
||||||
EGLBoolean (*eglBindAPI_p) (EGLenum api);
|
|
||||||
EGLSurface (*eglCreatePbufferSurface_p) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
|
||||||
EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
|
|
||||||
EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
|
|
||||||
EGLint (*eglGetError_p) (void);
|
|
||||||
EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
|
|
||||||
EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
|
|
||||||
EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
|
|
||||||
int (*vtest_main_p) (int argc, char** argv);
|
int (*vtest_main_p) (int argc, char** argv);
|
||||||
void (*vtest_swap_buffers_p) (void);
|
void (*vtest_swap_buffers_p) (void);
|
||||||
|
|
||||||
@ -696,7 +666,7 @@ void* pojavGetCurrentContext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dlsym_EGL(void* dl_handle) {
|
/*void dlsym_EGL(void* dl_handle) {
|
||||||
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
|
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
|
||||||
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
|
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
|
||||||
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
|
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
|
||||||
@ -728,61 +698,24 @@ void dlsym_OSMesa(void* dl_handle) {
|
|||||||
glClear_p = dlsym(dl_handle,"glClear");
|
glClear_p = dlsym(dl_handle,"glClear");
|
||||||
glFinish_p = dlsym(dl_handle,"glFinish");
|
glFinish_p = dlsym(dl_handle,"glFinish");
|
||||||
glReadPixels_p = dlsym(dl_handle,"glReadPixels");
|
glReadPixels_p = dlsym(dl_handle,"glReadPixels");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
bool loadSymbols() {
|
bool loadSymbols() {
|
||||||
char* fileName = calloc(1, 1024);
|
|
||||||
char* fileNameExt = calloc(1, 1024);
|
|
||||||
switch (config_renderer) {
|
switch (config_renderer) {
|
||||||
|
case RENDERER_VIRGL:
|
||||||
|
dlsym_EGL();
|
||||||
case RENDERER_VK_ZINK:
|
case RENDERER_VK_ZINK:
|
||||||
sprintf(fileName, "%s/libOSMesa_8.so", getenv("POJAV_NATIVEDIR"));
|
dlsym_OSMesa();
|
||||||
sprintf(fileNameExt, "%s/libOSMesa.so.8", getenv("POJAV_NATIVEDIR"));
|
|
||||||
break;
|
break;
|
||||||
case RENDERER_GL4ES:
|
case RENDERER_GL4ES:
|
||||||
sprintf(fileName, "libEGL.so");
|
//inside glbridge
|
||||||
char* eglLib = getenv("POJAVEXEC_EGL");
|
|
||||||
if (eglLib) {
|
|
||||||
sprintf(fileNameExt, "%s", eglLib);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
void* dl_handle = dlopen(fileNameExt,RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
|
||||||
if (!dl_handle) {
|
|
||||||
dl_handle = dlopen(fileNameExt,RTLD_NOW|RTLD_GLOBAL);
|
|
||||||
}
|
|
||||||
if (!dl_handle) {
|
|
||||||
dl_handle = dlopen(fileName,RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
|
||||||
if (!dl_handle) {
|
|
||||||
dl_handle = dlopen(fileName,RTLD_NOW|RTLD_GLOBAL);
|
|
||||||
}
|
|
||||||
printf("DlLoader: using default %s\n", fileName);
|
|
||||||
} else {
|
|
||||||
printf("DlLoader: using external %s\n", fileNameExt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dl_handle == NULL) {
|
|
||||||
printf("DlLoader: unable to load: %s\n",dlerror());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
switch(config_renderer) {
|
|
||||||
case RENDERER_VK_ZINK:
|
|
||||||
dlsym_OSMesa(dl_handle);
|
|
||||||
break;
|
|
||||||
case RENDERER_GL4ES:
|
|
||||||
dlsym_EGL(dl_handle);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(fileName);
|
|
||||||
free(fileNameExt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadSymbolsVirGL() {
|
bool loadSymbolsVirGL() {
|
||||||
config_renderer = RENDERER_GL4ES;
|
|
||||||
loadSymbols();
|
|
||||||
config_renderer = RENDERER_VK_ZINK;
|
|
||||||
loadSymbols();
|
|
||||||
config_renderer = RENDERER_VIRGL;
|
config_renderer = RENDERER_VIRGL;
|
||||||
|
loadSymbols();
|
||||||
|
|
||||||
char* fileName = calloc(1, 1024);
|
char* fileName = calloc(1, 1024);
|
||||||
|
|
||||||
@ -999,7 +932,7 @@ void pojavMakeCurrent(void* window) {
|
|||||||
// return JNI_TRUE;
|
// return JNI_TRUE;
|
||||||
//}
|
//}
|
||||||
if(config_renderer == RENDERER_GL4ES) {
|
if(config_renderer == RENDERER_GL4ES) {
|
||||||
gl_make_current((render_bundle_t*)window);
|
gl_make_current((render_window_t*)window);
|
||||||
}
|
}
|
||||||
if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) {
|
if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) {
|
||||||
printf("OSMDroid: making current\n");
|
printf("OSMDroid: making current\n");
|
||||||
|
@ -148,7 +148,7 @@ JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env,
|
|||||||
// SA_RESETHAND;
|
// SA_RESETHAND;
|
||||||
#define CATCHSIG(X) sigaction(X, &catcher, &old_sa[X])
|
#define CATCHSIG(X) sigaction(X, &catcher, &old_sa[X])
|
||||||
CATCHSIG(SIGILL);
|
CATCHSIG(SIGILL);
|
||||||
CATCHSIG(SIGABRT);
|
//CATCHSIG(SIGABRT);
|
||||||
CATCHSIG(SIGBUS);
|
CATCHSIG(SIGBUS);
|
||||||
CATCHSIG(SIGFPE);
|
CATCHSIG(SIGFPE);
|
||||||
#ifdef TRY_SIG2JVM
|
#ifdef TRY_SIG2JVM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user