diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-06-01 10:32:46 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-06-01 10:32:46 +0200 |
| commit | cd247ef6c13b718da3b891eae158fc86a67400ab (patch) | |
| tree | e43d582fb808608bb0513fb4235dcb83e235d49f /src | |
| parent | 104cf8a58b5c15b19d961f66375ff70c8d14a8cf (diff) | |
| download | box64-cd247ef6c13b718da3b891eae158fc86a67400ab.tar.gz box64-cd247ef6c13b718da3b891eae158fc86a67400ab.zip | |
Improved custom named libGL handling
Diffstat (limited to 'src')
| -rwxr-xr-x | src/librarian/library.c | 6 | ||||
| -rwxr-xr-x | src/wrapped/wrappedsdl2.c | 30 |
2 files changed, 25 insertions, 11 deletions
diff --git a/src/librarian/library.c b/src/librarian/library.c index 68ccf919..4d2a1d22 100755 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -233,12 +233,16 @@ static void initEmulatedLib(const char* path, library_t *lib, box64context_t* co loadEmulatedLib(libname, lib, context); } +extern char* libGL; library_t *NewLibrary(const char* path, box64context_t* context) { printf_log(LOG_DEBUG, "Trying to load \"%s\"\n", path); library_t *lib = (library_t*)calloc(1, sizeof(library_t)); lib->path = strdup(path); - lib->name = Path2Name(path); + if(libGL && !strcmp(path, libGL)) + lib->name = strdup("libGL.so.1"); + else + lib->name = Path2Name(path); lib->nbdot = NbDot(lib->name); lib->context = context; lib->type = -1; diff --git a/src/wrapped/wrappedsdl2.c b/src/wrapped/wrappedsdl2.c index f2e5e26d..2c4c544d 100755 --- a/src/wrapped/wrappedsdl2.c +++ b/src/wrapped/wrappedsdl2.c @@ -21,6 +21,11 @@ const char* sdl2Name = "libSDL2-2.0.so.0"; #define LIBNAME sdl2 +static void* my_glhandle = NULL; +// DL functions from wrappedlibdl.c +void* my_dlopen(x64emu_t* emu, void *filename, int flag); +int my_dlclose(x64emu_t* emu, void *handle); +void* my_dlsym(x64emu_t* emu, void *handle, void *symbol); static int sdl_Yes() { return 1;} static int sdl_No() { return 0;} @@ -638,6 +643,7 @@ EXPORT void my2_SDL_Log(x64emu_t* emu, void* fmt, void *b) { } void fillGLProcWrapper(box64context_t*); +extern char* libGL; EXPORT void* my2_SDL_GL_GetProcAddress(x64emu_t* emu, void* name) { khint_t k; @@ -647,8 +653,14 @@ EXPORT void* my2_SDL_GL_GetProcAddress(x64emu_t* emu, void* name) // check if glxprocaddress is filled, and search for lib and fill it if needed if(!emu->context->glxprocaddress) emu->context->glxprocaddress = (procaddess_t)my->SDL_GL_GetProcAddress; - if(!emu->context->glwrappers) + if(!emu->context->glwrappers) { fillGLProcWrapper(emu->context); + // check if libGL is loaded, load it if not (helps DeadCells) + if(!my_glhandle && !GetLibInternal(libGL?libGL:"libGL.so.1")) { + // use a my_dlopen to actually open that lib, like SDL2 is doing... + my_glhandle = my_dlopen(emu, libGL?libGL:"libGL.so.1", RTLD_LAZY|RTLD_GLOBAL); + } + } // get proc adress using actual glXGetProcAddress k = kh_get(symbolmap, emu->context->glmymap, rname); int is_my = (k==kh_end(emu->context->glmymap))?0:1; @@ -767,10 +779,6 @@ EXPORT void my2_SDL_DelEventWatch(x64emu_t* emu, void* p, void* userdata) my->SDL_DelEventWatch(find_eventfilter_Fct(p), userdata); } -// DL functions from wrappedlibdl.c -void* my_dlopen(x64emu_t* emu, void *filename, int flag); -int my_dlclose(x64emu_t* emu, void *handle); -void* my_dlsym(x64emu_t* emu, void *handle, void *symbol); EXPORT void* my2_SDL_LoadObject(x64emu_t* emu, void* sofile) { return my_dlopen(emu, sofile, 0); // TODO: check correct flag value... @@ -876,11 +884,13 @@ EXPORT void* my2_SDL_Vulkan_GetVkGetInstanceProcAddr(x64emu_t* emu) lib->priv.w.neededlibs[3] = strdup("libpthread.so.0"); #define CUSTOM_FINI \ - ((sdl2_my_t *)lib->priv.w.p2)->SDL_Quit(); \ - freeSDL2My(lib->priv.w.p2); \ - free(lib->priv.w.p2); \ - ((box64context_t*)(lib->context))->sdl2lib = NULL; \ - ((box64context_t*)(lib->context))->sdl2allocrw = NULL; \ + ((sdl2_my_t *)lib->priv.w.p2)->SDL_Quit(); \ + if(my_glhandle) my_dlclose(thread_get_emu(), my_glhandle); \ + my_glhandle = NULL; \ + freeSDL2My(lib->priv.w.p2); \ + free(lib->priv.w.p2); \ + ((box64context_t*)(lib->context))->sdl2lib = NULL; \ + ((box64context_t*)(lib->context))->sdl2allocrw = NULL; \ ((box64context_t*)(lib->context))->sdl2freerw = NULL; |