VirtualBox

Changeset 76263 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 17, 2018 3:03:28 PM (6 years ago)
Author:
vboxsync
Message:

DevVGA-SVGA3d: dynamic loading of OpenGL: X11 too

Location:
trunk/src/VBox/Devices
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-glLdr.cpp

    r76255 r76263  
    124124    return NULL;
    125125}
     126
     127static PFNRT MyX11GetProcAddress(const char *pszSymbol)
     128{
     129    int rc;
     130
     131    static RTLDRMOD s_hX11 = NULL;
     132    if (s_hX11 == NULL)
     133    {
     134        static const char s_szLibX11[] = "libX11.so.6";
     135        rc = RTLdrLoadEx(s_szLibX11, &s_hX11, RTLDRLOAD_FLAGS_GLOBAL | RTLDRLOAD_FLAGS_NO_UNLOAD, NULL);
     136        if (RT_FAILURE(rc))
     137        {
     138            LogRel(("VMSVGA3d: failed to load %s: %Rrc\n", s_szLibX11, rc));
     139            s_hX11 = NULL;
     140            return NULL;
     141        }
     142    }
     143
     144    PFNRT p = NULL;
     145    rc = RTLdrGetSymbol(s_hX11, pszSymbol, (void **)&p);
     146    if (RT_SUCCESS(rc))
     147        return p;
     148
     149    return NULL;
     150}
     151
     152#define X11GETPROC_(ProcName) do { \
     153    *(PFNRT *)&pfn_##ProcName = pfnRet = MyX11GetProcAddress(#ProcName); \
     154    if (pfnRet) { /* likely */ } \
     155    else \
     156    { \
     157        AssertLogRelMsg(pfnRet, ("%s missing\n", #ProcName)); \
     158        return PDMDevHlpVMSetError(pDevIns, VERR_VGA_GL_SYMBOL_NOT_FOUND, RT_SRC_POS, \
     159                                   "Missing libX11 symbol '%s'\n", #ProcName); \
     160    } \
     161} while(0)
    126162#endif
    127163
     
    223259    pfn_glXMakeCurrent = 0;
    224260    pfn_glXDestroyContext = 0;
     261    pfn_XConfigureWindow = 0;
     262    pfn_XCloseDisplay = 0;
     263    pfn_XCreateColormap = 0;
     264    pfn_XCreateWindow = 0;
     265    pfn_XDefaultRootWindow = 0;
     266    pfn_XDestroyWindow = 0;
     267    pfn_XNextEvent = 0;
     268    pfn_XOpenDisplay = 0;
     269    pfn_XPending = 0;
    225270#endif
    226271
     
    300345    GLGETPROC_(glXMakeCurrent, "");
    301346    GLGETPROC_(glXDestroyContext, "");
     347    X11GETPROC_(XConfigureWindow);
     348    X11GETPROC_(XCloseDisplay);
     349    X11GETPROC_(XCreateColormap);
     350    X11GETPROC_(XCreateWindow);
     351    X11GETPROC_(XDefaultRootWindow);
     352    X11GETPROC_(XDestroyWindow);
     353    X11GETPROC_(XNextEvent);
     354    X11GETPROC_(XOpenDisplay);
     355    X11GETPROC_(XPending);
    302356#endif
    303357    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-glLdr.h

    r76255 r76263  
    328328#define glXDestroyContext pfn_glXDestroyContext
    329329
    330 #endif
    331 
    332 #endif
     330/*
     331 * X11
     332 */
     333GLPFN int (* pfn_XConfigureWindow)(Display *display, Window w, unsigned value_mask, XWindowChanges *changes);
     334#define XConfigureWindow pfn_XConfigureWindow
     335
     336GLPFN int (* pfn_XCloseDisplay)(Display *display);
     337#define XCloseDisplay pfn_XCloseDisplay
     338
     339GLPFN Colormap (* pfn_XCreateColormap)(Display *display, Window w, Visual *visual, int alloc);
     340#define XCreateColormap pfn_XCreateColormap
     341
     342GLPFN Window (* pfn_XCreateWindow)(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height,
     343    unsigned int border_width, int depth, unsigned int window_class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attributes);
     344#define XCreateWindow pfn_XCreateWindow
     345
     346GLPFN Window (* pfn_XDefaultRootWindow)(Display *display);
     347#define XDefaultRootWindow pfn_XDefaultRootWindow
     348
     349GLPFN int (* pfn_XDestroyWindow)(Display *display, Window w);
     350#define XDestroyWindow pfn_XDestroyWindow
     351
     352GLPFN int (* pfn_XNextEvent)(Display *display, XEvent *event_return);
     353#define XNextEvent pfn_XNextEvent
     354
     355GLPFN Display *(* pfn_XOpenDisplay)(char *display_name);
     356#define XOpenDisplay pfn_XOpenDisplay
     357
     358GLPFN int (* pfn_XPending)(Display *display);
     359#define XPending pfn_XPending
     360
     361#endif
     362
     363#endif
  • trunk/src/VBox/Devices/Makefile.kmk

    r76260 r76263  
    311311        $(VBOX_DEF_2_LAZY_LOAD) --explicit-load-function --library VBoxSVGA3DObjC --output "$@" $(filter %.def, $^)
    312312
    313    # VBoxDD_LIBS.linux    += X11
    314313   ifdef VBOX_WITH_VMSVGA3D_DYNAMIC_LOAD
    315314   VBoxDD_DEFS          += VMSVGA3D_DYNAMIC_LOAD
     
    317316        Graphics/DevVGA-SVGA3d-glLdr.cpp
    318317   else
    319    VBoxDD_LIBS.linux    += GL
     318   VBoxDD_LIBS.linux    += X11 GL
    320319   VBoxDD_LIBS.win      += $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Opengl32.lib
    321320   endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette