From 20377b992768be46a9deb526de748bc3b5619fda Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 12 Apr 2025 15:22:14 +0200 Subject: [PATCH] [BOX32][WRAPPER] Added 32bits wrapped libGLX --- CMakeLists.txt | 1 + rebuild_wrappers_32.py | 1 + src/library_list_32.h | 2 + src/wrapped32/generated/functions_list.txt | 13 +++ src/wrapped32/generated/wrappedlibglxdefs32.h | 8 ++ .../generated/wrappedlibglxtypes32.h | 29 ++++++ .../generated/wrappedlibglxundefs32.h | 8 ++ src/wrapped32/wrappedlibglx.c | 97 +++++++++++++++++++ src/wrapped32/wrappedlibglx_private.h | 48 +++++++++ 9 files changed, 207 insertions(+) create mode 100644 src/wrapped32/generated/wrappedlibglxdefs32.h create mode 100644 src/wrapped32/generated/wrappedlibglxtypes32.h create mode 100644 src/wrapped32/generated/wrappedlibglxundefs32.h create mode 100644 src/wrapped32/wrappedlibglx.c create mode 100644 src/wrapped32/wrappedlibglx_private.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8870794a8..fbcd14786 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -863,6 +863,7 @@ if(BOX32) "${BOX64_ROOT}/src/wrapped32/wrappedlibcups.c" "${BOX64_ROOT}/src/wrapped32/wrappedgbm.c" "${BOX64_ROOT}/src/wrapped32/wrappedlibegl.c" + "${BOX64_ROOT}/src/wrapped32/wrappedlibglx.c" ) endif() string(REPLACE ".c" "_private.h" MODROOT ${BOX64_ROOT}) diff --git a/rebuild_wrappers_32.py b/rebuild_wrappers_32.py index 803f31924..437ab3364 100755 --- a/rebuild_wrappers_32.py +++ b/rebuild_wrappers_32.py @@ -875,6 +875,7 @@ def readFiles(files: Iterable[str]) -> Tuple[JumbledFunctions, JumbledFunctions, or match("gstreamer010","gstreamer") \ or match("appindicator","appindicator3")\ or match("libgl", "libegl") \ + or match("libgl", "libglx") \ \ or match("libc", "tcmallocminimal") \ or match("libc", "ldlinux") \ diff --git a/src/library_list_32.h b/src/library_list_32.h index a085c164a..f6ff790ca 100644 --- a/src/library_list_32.h +++ b/src/library_list_32.h @@ -33,6 +33,8 @@ GO("libfreetype.so.6", freetype) GO("libfontconfig.so.1", fontconfig) GO("libEGL.so", libegl) GO("libEGL.so.1", libegl) +GO("libGLX.so", libglx) +GO("libGLX.so.0", libglx) GO("libX11.so", libx11) GO("libXdamage.so", libxdamage) diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 14a96b97e..7fc7a4750 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -2525,6 +2525,19 @@ wrappedlibglu: - gluNurbsCallback - gluQuadricCallback - gluTessCallback +wrappedlibglx: +- pFp: + - glXGetProcAddress + - glXGetProcAddressARB +- pFXp: + - glXGetVisualFromFBConfig +- pFXip: + - glXChooseVisual + - glXGetFBConfigs +- pFXipp: + - glXChooseFBConfig +- pFXppi: + - glXCreateContext wrappedlibm: - UEs: - cacosf diff --git a/src/wrapped32/generated/wrappedlibglxdefs32.h b/src/wrapped32/generated/wrappedlibglxdefs32.h new file mode 100644 index 000000000..79be6f7a0 --- /dev/null +++ b/src/wrapped32/generated/wrappedlibglxdefs32.h @@ -0,0 +1,8 @@ +/********************************************************************* + * File automatically generated by rebuild_wrappers_32.py (v0.0.2.2) * + *********************************************************************/ +#ifndef __wrappedlibglxDEFS32_H_ +#define __wrappedlibglxDEFS32_H_ + + +#endif // __wrappedlibglxDEFS32_H_ diff --git a/src/wrapped32/generated/wrappedlibglxtypes32.h b/src/wrapped32/generated/wrappedlibglxtypes32.h new file mode 100644 index 000000000..4e2436e6c --- /dev/null +++ b/src/wrapped32/generated/wrappedlibglxtypes32.h @@ -0,0 +1,29 @@ +/********************************************************************* + * File automatically generated by rebuild_wrappers_32.py (v0.0.2.2) * + *********************************************************************/ +#ifndef __wrappedlibglxTYPES32_H_ +#define __wrappedlibglxTYPES32_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*); +typedef void* (*pFXp_t)(void*, void*); +typedef void* (*pFXip_t)(void*, int32_t, void*); +typedef void* (*pFXipp_t)(void*, int32_t, void*, void*); +typedef void* (*pFXppi_t)(void*, void*, void*, int32_t); + +#define SUPER() ADDED_FUNCTIONS() \ + GO(glXGetProcAddress, pFp_t) \ + GO(glXGetProcAddressARB, pFp_t) \ + GO(glXGetVisualFromFBConfig, pFXp_t) \ + GO(glXChooseVisual, pFXip_t) \ + GO(glXGetFBConfigs, pFXip_t) \ + GO(glXChooseFBConfig, pFXipp_t) \ + GO(glXCreateContext, pFXppi_t) + +#endif // __wrappedlibglxTYPES32_H_ diff --git a/src/wrapped32/generated/wrappedlibglxundefs32.h b/src/wrapped32/generated/wrappedlibglxundefs32.h new file mode 100644 index 000000000..5d7cddd38 --- /dev/null +++ b/src/wrapped32/generated/wrappedlibglxundefs32.h @@ -0,0 +1,8 @@ +/********************************************************************* + * File automatically generated by rebuild_wrappers_32.py (v0.0.2.2) * + *********************************************************************/ +#ifndef __wrappedlibglxUNDEFS32_H_ +#define __wrappedlibglxUNDEFS32_H_ + + +#endif // __wrappedlibglxUNDEFS32_H_ diff --git a/src/wrapped32/wrappedlibglx.c b/src/wrapped32/wrappedlibglx.c new file mode 100644 index 000000000..4da58cc06 --- /dev/null +++ b/src/wrapped32/wrappedlibglx.c @@ -0,0 +1,97 @@ +#include +#include +#include +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include + +#include "wrappedlibs.h" + +#include "debug.h" +#include "wrapper32.h" +#include "bridge.h" +#include "librarian/library_private.h" +#include "x64emu.h" +#include "emu/x64emu_private.h" +#include "callback.h" +#include "librarian.h" +#include "box32context.h" +#include "emu/x64emu_private.h" +#include "myalign32.h" +#include "gltools.h" +#include "libtools/my_x11_conv.h" + +static const char* libglxName = "libGLX.so.0"; +#define LIBNAME libglx + +#include "generated/wrappedlibglxtypes32.h" + +#include "wrappercallback32.h" + +#define SUPER() \ +GO(0) \ +GO(1) \ +GO(2) \ +GO(3) \ + + +#undef SUPER + +EXPORT void* myx32_glXGetProcAddress(x64emu_t* emu, void* name) +{ + khint_t k; + const char* rname = (const char*)name; + return getGLProcAddress32(emu, (glprocaddress_t)my->glXGetProcAddress, rname); +} +EXPORT void* myx32_glXGetProcAddressARB(x64emu_t* emu, void* name) __attribute__((alias("myx32_glXGetProcAddress"))); + +EXPORT void* myx32_glXChooseFBConfig(x64emu_t* emu, void* dpy, int screen, int* list, int* nelement) +{ + void** res = my->glXChooseFBConfig(dpy, screen, list, nelement); + if(!res) + return NULL; + ptr_t *fbconfig = (ptr_t*)res; + for(int i=0; i<*nelement; ++i) + fbconfig[i] = to_ptrv(res[i]); + return res; +} + +EXPORT void* myx32_glXGetVisualFromFBConfig(x64emu_t* emu, void* dpy, void* config) +{ + void* res = my->glXGetVisualFromFBConfig(dpy, config); + if(!res) return NULL; + my_XVisualInfo_32_t* vinfo = (my_XVisualInfo_32_t*)res; + convert_XVisualInfo_to_32(dpy, vinfo, res); + return vinfo; +} + +EXPORT void* myx32_glXChooseVisual(x64emu_t* emu, void* dpy, int screen, int* attr) +{ + void* res = my->glXChooseVisual(dpy, screen, attr); + if(!res) return NULL; + my_XVisualInfo_32_t* vinfo = (my_XVisualInfo_32_t*)res; + convert_XVisualInfo_to_32(dpy, vinfo, res); + return vinfo; +} + +EXPORT void* myx32_glXCreateContext(x64emu_t* emu, void* dpy, my_XVisualInfo_32_t* info, void* shared, int direct) +{ + my_XVisualInfo_t info_l = {0}; + convert_XVisualInfo_to_64(dpy, &info_l, info); + return my->glXCreateContext(dpy, &info_l, shared, direct); +} + +EXPORT void* myx32_glXGetFBConfigs(x64emu_t* emu, void* dpy, int screen, int* n) +{ + void* ret = my->glXGetFBConfigs(dpy, screen, n); + if(!ret) return NULL; + ptr_t* dst = ret; + void** src = ret; + for(int i=0; i<*n; ++i) + dst[i] = to_ptrv(src[i]); + return ret; +} + + +#define ALTMY myx32_ + +#include "wrappedlib_init32.h" diff --git a/src/wrapped32/wrappedlibglx_private.h b/src/wrapped32/wrappedlibglx_private.h new file mode 100644 index 000000000..9e658c6d1 --- /dev/null +++ b/src/wrapped32/wrappedlibglx_private.h @@ -0,0 +1,48 @@ +#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) +#error Meh... +#endif + +// __glXGLLoadGLXFunction +GOM(glXChooseFBConfig, pFEXipp) +GOM(glXChooseVisual, pFEXip) +GO(glXCopyContext, vFXppL) +GOM(glXCreateContext, pFEXppi) +//GOM(glXCreateGLXPixmap, LFEXbpLiiiLLLii_L) +GO(glXCreateNewContext, pFXpipi) +GO(glXCreatePbuffer, LFXpp) +GO(glXCreatePixmap, LFXpLp) +GO(glXCreateWindow, LFXpLp) +GO(glXDestroyContext, vFXp) +GO(glXDestroyGLXPixmap, vFXL) +GO(glXDestroyPbuffer, vFXL) +GO(glXDestroyPixmap, vFXL) +GO(glXDestroyWindow, vFXL) +GO(glXGetClientString, pFXi) +//GOM(glXGetConfig, iFEXbpLiiiLLLii_ip) +GO(glXGetCurrentContext, pFv) +GO(glXGetCurrentDisplay, XFv) +GO(glXGetCurrentDrawable, LFv) +GO(glXGetCurrentReadDrawable, LFv) +GO(glXGetFBConfigAttrib, iFXpip) +GOM(glXGetFBConfigs, pFEXip) +GOM(glXGetProcAddress, pFEp) +GOM(glXGetProcAddressARB, pFEp) +GO(glXGetSelectedEvent, vFXLbL_) +GOM(glXGetVisualFromFBConfig, pFEXp) +GO(glXIsDirect, iFXp) +GO(glXMakeContextCurrent, iFXLLp) +GO(glXMakeCurrent, iFXLp) +GO(glXQueryContext, iFXpip) +GO(glXQueryDrawable, vFXLip) +GO(glXQueryExtension, iFXpp) +GO(glXQueryExtensionsString, pFXi) +GO(glXQueryServerString, pFXii) +GO(glXQueryVersion, iFXpp) +GO(glXSelectEvent, vFXLL) +GO(glXSwapBuffers, vFXL) +GO(glXUseXFont, vFLiii) +GO(glXWaitGL, vFv) +GO(glXWaitX, vFv) + + +