about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-06-05 12:00:59 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-06-05 12:01:04 +0200
commit736552a5599bff6dcb1b7b020ba2679814b83219 (patch)
treec0300c4e8fb423c9ff9e26ba74ea746dfb4a853c /src
parent162abb0a3228125c456fcc47e457d1a8c4c38aa8 (diff)
downloadbox64-736552a5599bff6dcb1b7b020ba2679814b83219.tar.gz
box64-736552a5599bff6dcb1b7b020ba2679814b83219.zip
Added preliminary support for wrapped libEGL
Diffstat (limited to 'src')
-rwxr-xr-xsrc/library_list.h1
-rw-r--r--src/wrapped/generated/functions_list.txt4
-rw-r--r--src/wrapped/generated/wrappedlibegldefs.h8
-rw-r--r--src/wrapped/generated/wrappedlibegltypes.h19
-rw-r--r--src/wrapped/generated/wrappedlibeglundefs.h8
-rw-r--r--src/wrapped/generated/wrapper.c3
-rw-r--r--src/wrapped/generated/wrapper.h1
-rwxr-xr-xsrc/wrapped/wrappedlibegl.c100
-rwxr-xr-xsrc/wrapped/wrappedlibegl_private.h49
-rwxr-xr-xsrc/wrapped/wrappedlibgl.c3
-rwxr-xr-xsrc/wrapped/wrappedlibgl_private.h76
11 files changed, 271 insertions, 1 deletions
diff --git a/src/library_list.h b/src/library_list.h
index f43da0d0..7c3c41cb 100755
--- a/src/library_list.h
+++ b/src/library_list.h
@@ -5,6 +5,7 @@
 GO("libc.so.6", libc)
 GO("libpthread.so.0", libpthread)
 GO("librt.so.1", librt)
+GO("libEGL.so.1", libegl)
 GO("libGL.so.1", libgl)
 GO("libGL.so", libgl)
 GO("libOpenGL.so.0", libgl)
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index e18e096d..7674a197 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1413,6 +1413,7 @@
 #() iFpUUUip
 #() iFpUUUUp
 #() iFpLLppp
+#() iFppiiii
 #() iFppiiip
 #() iFppiiuu
 #() iFppiipi
@@ -2905,6 +2906,9 @@ wrappedlibdl:
 - iFpppi:
   - dladdr1
 wrappedlibdrm:
+wrappedlibegl:
+- pFp:
+  - eglGetProcAddress
 wrappedlibform:
 wrappedlibformw:
 wrappedlibfuse:
diff --git a/src/wrapped/generated/wrappedlibegldefs.h b/src/wrapped/generated/wrappedlibegldefs.h
new file mode 100644
index 00000000..7218dddb
--- /dev/null
+++ b/src/wrapped/generated/wrappedlibegldefs.h
@@ -0,0 +1,8 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.1.0.16) *
+ *******************************************************************/
+#ifndef __wrappedlibeglDEFS_H_
+#define __wrappedlibeglDEFS_H_
+
+
+#endif // __wrappedlibeglDEFS_H_
diff --git a/src/wrapped/generated/wrappedlibegltypes.h b/src/wrapped/generated/wrappedlibegltypes.h
new file mode 100644
index 00000000..5986170d
--- /dev/null
+++ b/src/wrapped/generated/wrappedlibegltypes.h
@@ -0,0 +1,19 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.1.0.16) *
+ *******************************************************************/
+#ifndef __wrappedlibeglTYPES_H_
+#define __wrappedlibeglTYPES_H_
+
+#ifndef LIBNAME
+#error You should only #include this file inside a wrapped*.c file
+#endif
+#ifndef ADDED_FUNCTIONS
+#define ADDED_FUNCTIONS() 
+#endif
+
+typedef void* (*pFp_t)(void*);
+
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(eglGetProcAddress, pFp_t)
+
+#endif // __wrappedlibeglTYPES_H_
diff --git a/src/wrapped/generated/wrappedlibeglundefs.h b/src/wrapped/generated/wrappedlibeglundefs.h
new file mode 100644
index 00000000..739fd1b6
--- /dev/null
+++ b/src/wrapped/generated/wrappedlibeglundefs.h
@@ -0,0 +1,8 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.1.0.16) *
+ *******************************************************************/
+#ifndef __wrappedlibeglUNDEFS_H_
+#define __wrappedlibeglUNDEFS_H_
+
+
+#endif // __wrappedlibeglUNDEFS_H_
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index 006ceaa5..3a0aa8f5 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -1447,6 +1447,7 @@ typedef int64_t (*iFpUuupp_t)(void*, uint64_t, uint64_t, uint64_t, void*, void*)
 typedef int64_t (*iFpUUUip_t)(void*, uint64_t, uint64_t, uint64_t, int64_t, void*);
 typedef int64_t (*iFpUUUUp_t)(void*, uint64_t, uint64_t, uint64_t, uint64_t, void*);
 typedef int64_t (*iFpLLppp_t)(void*, uintptr_t, uintptr_t, void*, void*, void*);
+typedef int64_t (*iFppiiii_t)(void*, void*, int64_t, int64_t, int64_t, int64_t);
 typedef int64_t (*iFppiiip_t)(void*, void*, int64_t, int64_t, int64_t, void*);
 typedef int64_t (*iFppiiuu_t)(void*, void*, int64_t, int64_t, uint64_t, uint64_t);
 typedef int64_t (*iFppiipi_t)(void*, void*, int64_t, int64_t, void*, int64_t);
@@ -3535,6 +3536,7 @@ void iFpUuupp(x64emu_t *emu, uintptr_t fcn) { iFpUuupp_t fn = (iFpUuupp_t)fcn; R
 void iFpUUUip(x64emu_t *emu, uintptr_t fcn) { iFpUUUip_t fn = (iFpUUUip_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (int64_t)R_R8, (void*)R_R9); }
 void iFpUUUUp(x64emu_t *emu, uintptr_t fcn) { iFpUUUUp_t fn = (iFpUUUUp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (uint64_t)R_R8, (void*)R_R9); }
 void iFpLLppp(x64emu_t *emu, uintptr_t fcn) { iFpLLppp_t fn = (iFpLLppp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); }
+void iFppiiii(x64emu_t *emu, uintptr_t fcn) { iFppiiii_t fn = (iFppiiii_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9); }
 void iFppiiip(x64emu_t *emu, uintptr_t fcn) { iFppiiip_t fn = (iFppiiip_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (void*)R_R9); }
 void iFppiiuu(x64emu_t *emu, uintptr_t fcn) { iFppiiuu_t fn = (iFppiiuu_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (uint64_t)R_R8, (uint64_t)R_R9); }
 void iFppiipi(x64emu_t *emu, uintptr_t fcn) { iFppiipi_t fn = (iFppiipi_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8, (int64_t)R_R9); }
@@ -5423,6 +5425,7 @@ int isSimpleWrapper(wrapper_t fun) {
 	if (fun == &iFpUUUip) return 1;
 	if (fun == &iFpUUUUp) return 1;
 	if (fun == &iFpLLppp) return 1;
+	if (fun == &iFppiiii) return 1;
 	if (fun == &iFppiiip) return 1;
 	if (fun == &iFppiiuu) return 1;
 	if (fun == &iFppiipi) return 1;
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 1bb32e7a..fe914212 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -1446,6 +1446,7 @@ void iFpUuupp(x64emu_t *emu, uintptr_t fnc);
 void iFpUUUip(x64emu_t *emu, uintptr_t fnc);
 void iFpUUUUp(x64emu_t *emu, uintptr_t fnc);
 void iFpLLppp(x64emu_t *emu, uintptr_t fnc);
+void iFppiiii(x64emu_t *emu, uintptr_t fnc);
 void iFppiiip(x64emu_t *emu, uintptr_t fnc);
 void iFppiiuu(x64emu_t *emu, uintptr_t fnc);
 void iFppiipi(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlibegl.c b/src/wrapped/wrappedlibegl.c
new file mode 100755
index 00000000..7f8e7cb9
--- /dev/null
+++ b/src/wrapped/wrappedlibegl.c
@@ -0,0 +1,100 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define _GNU_SOURCE         /* See feature_test_macros(7) */
+#include <dlfcn.h>
+
+#include "wrappedlibs.h"
+
+#include "debug.h"
+#include "wrapper.h"
+#include "bridge.h"
+#include "librarian/library_private.h"
+#include "x64emu.h"
+#include "emu/x64emu_private.h"
+#include "box64context.h"
+#include "librarian.h"
+#include "callback.h"
+
+const char* libeglName = "libEGL.so.1";
+#define LIBNAME libegl
+
+#include "generated/wrappedlibegltypes.h"
+
+#include "wrappercallback.h"
+
+// FIXME: old wrapped* type of file, cannot use generated/wrappedlibgltypes.h
+
+void fillGLProcWrapper(box64context_t*);
+void freeProcWrapper(kh_symbolmap_t** symbolmap);
+
+EXPORT void* my_eglGetProcAddress(x64emu_t* emu, void* name) 
+{
+    khint_t k;
+    const char* rname = (const char*)name;
+    if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "Calling eglGetProcAddress(\"%s\") => ", rname);
+    if(!emu->context->glwrappers)
+        fillGLProcWrapper(emu->context);
+    // check if glxprocaddress is filled, and search for lib and fill it if needed
+    // 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;
+    void* symbol;
+    if(is_my) {
+        // try again, by using custom "my_" now...
+        char tmp[200];
+        strcpy(tmp, "my_");
+        strcat(tmp, rname);
+        symbol = dlsym(emu->context->box64lib, tmp);
+    } else 
+        symbol = my->eglGetProcAddress((void*)rname);
+    if(!symbol) {
+        if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", NULL);
+        return NULL;    // easy
+    }
+    // check if alread bridged
+    uintptr_t ret = CheckBridged(emu->context->system, symbol);
+    if(ret) {
+        if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", (void*)ret);
+        return (void*)ret; // already bridged
+    }
+    // get wrapper    
+    k = kh_get(symbolmap, emu->context->glwrappers, rname);
+    if(k==kh_end(emu->context->glwrappers) && strstr(rname, "ARB")==NULL) {
+        // try again, adding ARB at the end if not present
+        char tmp[200];
+        strcpy(tmp, rname);
+        strcat(tmp, "ARB");
+        k = kh_get(symbolmap, emu->context->glwrappers, tmp);
+    }
+    if(k==kh_end(emu->context->glwrappers) && strstr(rname, "EXT")==NULL) {
+        // try again, adding EXT at the end if not present
+        char tmp[200];
+        strcpy(tmp, rname);
+        strcat(tmp, "EXT");
+        k = kh_get(symbolmap, emu->context->glwrappers, tmp);
+    }
+    if(k==kh_end(emu->context->glwrappers)) {
+        if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", NULL);
+        if(dlsym_error && box64_log<LOG_INFO) printf_log(LOG_NONE, "Warning, no wrapper for %s\n", rname);
+        return NULL;
+    }
+    const char* constname = kh_key(emu->context->glwrappers, k);
+    AddOffsetSymbol(emu->context->maplib, symbol, rname);
+    ret = AddBridge(emu->context->system, kh_value(emu->context->glwrappers, k), symbol, 0, constname);
+    if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", (void*)ret);
+    return (void*)ret;
+
+}
+
+
+#define CUSTOM_INIT                 \
+    getMy(lib);                     \
+    if (!box64->glxprocaddress)     \
+        box64->glxprocaddress = (procaddess_t)my->eglGetProcAddress;
+
+#define CUSTOM_FINI \
+    freeMy();
+
+
+#include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibegl_private.h b/src/wrapped/wrappedlibegl_private.h
new file mode 100755
index 00000000..e109388a
--- /dev/null
+++ b/src/wrapped/wrappedlibegl_private.h
@@ -0,0 +1,49 @@
+#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
+#error meh!
+#endif
+
+GO(eglBindAPI, iFi)
+GO(eglBindTexImage, iFppi)
+GO(eglChooseConfig, iFpppip)
+//GO(eglClientWaitSync, 
+GO(eglCopyBuffers, iFppp)
+GO(eglCreateContext, pFpppp)
+//GO(eglCreateImage, 
+GO(eglCreatePbufferFromClientBuffer, pFpippp)
+GO(eglCreatePbufferSurface, pFppp)
+GO(eglCreatePixmapSurface, pFpppp)
+//GO(eglCreatePlatformPixmapSurface, 
+//GO(eglCreatePlatformWindowSurface, 
+//GO(eglCreateSync, 
+GO(eglCreateWindowSurface, pFpppp)
+GO(eglDestroyContext, iFpp)
+//GO(eglDestroyImage, 
+GO(eglDestroySurface, iFpp)
+//GO(eglDestroySync, 
+GO(eglGetConfigAttrib, iFppip)
+GO(eglGetConfigs, iFppip)
+GO(eglGetCurrentContext, pFv)
+GO(eglGetCurrentDisplay, pFv)
+GO(eglGetCurrentSurface, pFi)
+GO(eglGetDisplay, pFp)
+GO(eglGetError, iFv)
+//GO(eglGetPlatformDisplay, 
+GOM(eglGetProcAddress, pFEp)
+//GO(eglGetSyncAttrib, 
+GO(eglInitialize, iFppp)
+GO(eglMakeCurrent, iFpppp)
+GO(eglQueryAPI, iFv)
+GO(eglQueryContext, iFppip)
+GO(eglQueryString, pFpi)
+GO(eglQuerySurface, iFppip)
+GO(eglReleaseTexImage, iFppi)
+GO(eglReleaseThread, iFv)
+GO(eglSurfaceAttrib, iFppii)
+GO(eglSwapBuffers, iFpp)
+GO(eglSwapInterval, iFpi)
+GO(eglTerminate, iFp)
+GO(eglWaitClient, iFv)
+GO(eglWaitGL, iFv)
+GO(eglWaitNative, iFi)
+//GO(eglWaitSync, 
+
diff --git a/src/wrapped/wrappedlibgl.c b/src/wrapped/wrappedlibgl.c
index 17fed02e..95b14717 100755
--- a/src/wrapped/wrappedlibgl.c
+++ b/src/wrapped/wrappedlibgl.c
@@ -187,7 +187,8 @@ EXPORT void my_glProgramCallbackMESA(x64emu_t* emu, void* f, void* data)
 #define PRE_INIT if(libGL) {lib->priv.w.lib = dlopen(libGL, RTLD_LAZY | RTLD_GLOBAL); lib->path = strdup(libGL);} else
 #define CUSTOM_INIT \
     lib->priv.w.priv = dlsym(lib->priv.w.lib, "glXGetProcAddress"); \
-    box64->glxprocaddress = lib->priv.w.priv;
+    if (!box64->glxprocaddress) \
+        box64->glxprocaddress = lib->priv.w.priv;
 
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibgl_private.h b/src/wrapped/wrappedlibgl_private.h
index 3d45f20f..18b4bd80 100755
--- a/src/wrapped/wrappedlibgl_private.h
+++ b/src/wrapped/wrappedlibgl_private.h
@@ -3307,3 +3307,79 @@ GO(glResolveDepthValuesNV, vFv)
 
 //GL_OVR_multiview
 GO(glFramebufferTextureMultiviewOVR, vFiiuiil)
+
+// EGL stuffs
+GO(eglBindAPI, iFi)
+GO(eglBindTexImage, iFppi)
+GO(eglChooseConfig, iFpppip)
+GO(eglClientWaitSyncKHR, iFppip)
+GO(eglClientWaitSyncNV, iFpip)
+GO(eglCopyBuffers, iFppp)
+GO(eglCreateContext, pFpppp)
+GO(eglCreateDRMImageMESA, pFpp)
+GO(eglCreateFenceSyncNV, pFpip)
+GO(eglCreateImageKHR, pFppipp)
+GO(eglCreatePbufferFromClientBuffer, pFpippp)
+GO(eglCreatePbufferSurface, pFppp)
+GO(eglCreatePixmapSurface, pFpppp)
+GO(eglCreatePixmapSurfaceHI, pFppp)
+GO(eglCreateStreamFromFileDescriptorKHR, pFpi)
+GO(eglCreateStreamKHR, pFpp)
+GO(eglCreateStreamProducerSurfaceKHR, pFpppp)
+GO(eglCreateSyncKHR, pFpip)
+GO(eglCreateWindowSurface, pFpppp)
+GO(eglDestroyContext, iFpp)
+GO(eglDestroyImageKHR, iFpp)
+GO(eglDestroyStreamKHR, iFpp)
+GO(eglDestroySurface, iFpp)
+GO(eglDestroySyncKHR, iFpp)
+GO(eglDestroySyncNV, iFp)
+GO(eglDupNativeFenceFDANDROID, iFpp)
+GO(eglExportDRMImageMESA, iFppppp)
+GO(eglFenceNV, iFp)
+GO(eglGetConfigAttrib, iFppip)
+GO(eglGetConfigs, iFppip)
+GO(eglGetCurrentContext, pFv)
+GO(eglGetCurrentDisplay, pFv)
+GO(eglGetCurrentSurface, pFi)
+GO(eglGetDisplay, pFp)
+GO(eglGetError, iFv)
+GO(eglGetStreamFileDescriptorKHR, iFpp)
+GO(eglGetSyncAttribKHR, iFppip)
+GO(eglGetSyncAttribNV, iFpip)
+GO(eglGetSystemTimeFrequencyNV, UFv)
+GO(eglGetSystemTimeNV, UFv)
+GO(eglInitialize, iFppp)
+GO(eglLockSurfaceKHR, iFppp)
+GO(eglMakeCurrent, iFpppp)
+GO(eglPostSubBufferNV, iFppiiii)
+GO(eglQueryAPI, iFv)
+GO(eglQueryContext, iFppip)
+GO(eglQueryNativeDisplayNV, iFpp)
+GO(eglQueryNativePixmapNV, iFppp)
+GO(eglQueryNativeWindowNV, iFppp)
+GO(eglQueryStreamKHR, iFppip)
+GO(eglQueryStreamTimeKHR, iFppip)
+GO(eglQueryStreamu64KHR, iFppip)
+GO(eglQueryString, pFpi)
+GO(eglQuerySurface, iFppip)
+GO(eglQuerySurfacePointerANGLE, iFppip)
+GO(eglReleaseTexImage, iFppi)
+GO(eglReleaseThread, iFv)
+//GOM(eglSetBlobCacheFuncsANDROID, vFpBB)
+GO(eglSignalSyncKHR, iFppi)
+GO(eglSignalSyncNV, iFpi)
+GO(eglStreamAttribKHR, iFppii)
+GO(eglStreamConsumerAcquireKHR, iFpp)
+GO(eglStreamConsumerGLTextureExternalKHR, iFpp)
+GO(eglStreamConsumerReleaseKHR, iFpp)
+GO(eglSurfaceAttrib, iFppii)
+GO(eglSwapBuffers, iFpp)
+GO(eglSwapBuffersWithDamageEXT, iFpppi)
+GO(eglSwapInterval, iFpi)
+GO(eglTerminate, iFp)
+GO(eglUnlockSurfaceKHR, iFpp)
+GO(eglWaitClient, iFv)
+GO(eglWaitGL, iFv)
+GO(eglWaitNative, iFi)
+GO(eglWaitSyncKHR, iFppi)
\ No newline at end of file