Commit 799208dd authored by Adam Jackson's avatar Adam Jackson 🦃

Bug #377: Make lib{glx,GLcore,dri} work when compiled as dlloader modules.

parent f15f8817
...@@ -109,7 +109,7 @@ static void glAquaResetExtension(void); ...@@ -109,7 +109,7 @@ static void glAquaResetExtension(void);
* struct. In particular, the contextCreate, pGlxVisual, numVisuals, * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
* and numUsableVisuals fields must be initialized. * and numUsableVisuals fields must be initialized.
*/ */
__GLXscreenInfo __glDDXScreenInfo = { static __GLXscreenInfo __glDDXScreenInfo = {
glAquaScreenProbe, /* Must be generic and handle all screens */ glAquaScreenProbe, /* Must be generic and handle all screens */
glAquaCreateContext, /* Substitute screen's createContext routine */ glAquaCreateContext, /* Substitute screen's createContext routine */
glAquaCreateBuffer, /* Substitute screen's createBuffer routine */ glAquaCreateBuffer, /* Substitute screen's createBuffer routine */
...@@ -123,13 +123,21 @@ __GLXscreenInfo __glDDXScreenInfo = { ...@@ -123,13 +123,21 @@ __GLXscreenInfo __glDDXScreenInfo = {
NULL /* WrappedPositionWindow is overwritten */ NULL /* WrappedPositionWindow is overwritten */
}; };
__GLXextensionInfo __glDDXExtensionInfo = { void *__glXglDDXScreenInfo(void) {
return &__glDDXScreenInfo;
}
static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_APPLE, GL_CORE_APPLE,
glAquaResetExtension, glAquaResetExtension,
glAquaInitVisuals, glAquaInitVisuals,
glAquaSetVisualConfigs glAquaSetVisualConfigs
}; };
void *__glXglDDXExtensionInfo(void) {
return &__glDDXExtensionInfo;
}
// prototypes // prototypes
static GLboolean glAquaDestroyContext(__GLcontext *gc); static GLboolean glAquaDestroyContext(__GLcontext *gc);
......
/* $XFree86: xc/programs/Xserver/GL/glx/glxext.c,v 1.8 2001/08/23 18:25:40 alanh Exp $ /* $XFree86: xc/programs/Xserver/GL/glx/glxext.c,v 1.9 2003/09/28 20:15:43 alanh Exp $
** The contents of this file are subject to the GLX Public License Version 1.0 ** The contents of this file are subject to the GLX Public License Version 1.0
** (the "License"). You may not use this file except in compliance with the ** (the "License"). You may not use this file except in compliance with the
** License. You may obtain a copy of the License at Silicon Graphics, Inc., ** License. You may obtain a copy of the License at Silicon Graphics, Inc.,
...@@ -30,12 +30,11 @@ ...@@ -30,12 +30,11 @@
#include "micmap.h" #include "micmap.h"
extern __GLXextensionInfo __glDDXExtensionInfo;
void GlxWrapInitVisuals(miInitVisualsProcPtr *); void GlxWrapInitVisuals(miInitVisualsProcPtr *);
void GlxSetVisualConfigs(int nconfigs, void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs, void **privates); __GLXvisualConfig *configs, void **privates);
__GLXextensionInfo *__glXExt = &__glDDXExtensionInfo; static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */;
/* /*
** Forward declarations. ** Forward declarations.
...@@ -314,6 +313,8 @@ GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc) ...@@ -314,6 +313,8 @@ GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
{ {
saveInitVisualsProc = *initVisProc; saveInitVisualsProc = *initVisProc;
*initVisProc = GlxInitVisuals; *initVisProc = GlxInitVisuals;
/* HACK: this shouldn't be done here but it's the earliest time */
__glXExt = __glXglDDXExtensionInfo(); /* from GLcore */
} }
/************************************************************************/ /************************************************************************/
......
...@@ -142,22 +142,25 @@ static char GLXServerExtensions[] = ...@@ -142,22 +142,25 @@ static char GLXServerExtensions[] =
; ;
/* /*
** This comes from the GL library that the server will link with. Right * __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at
** now, that is the DDX Sample OpenGL. * module open time. Leave a placeholder, and fill this in when we first
*/ * need it (in __glXScreenInit). XXX Why make this an array?
extern __GLXscreenInfo __glDDXScreenInfo; */
static __GLXscreenInfo *__glXScreens[] = {
__GLXscreenInfo *__glXScreens[] = { NULL /* &__glDDXScreenInfo */ ,
&__glDDXScreenInfo,
}; };
GLint __glXNumStaticScreens = (sizeof __glXScreens / sizeof __glXScreens[0]); static GLint __glXNumStaticScreens =
(sizeof __glXScreens / sizeof __glXScreens[0]);
__GLXscreenInfo *__glXActiveScreens; __GLXscreenInfo *__glXActiveScreens;
GLint __glXNumActiveScreens; GLint __glXNumActiveScreens;
RESTYPE __glXDrawableRes; RESTYPE __glXDrawableRes;
__GLXscreenInfo *__glXgetActiveScreen(int num) {
return &__glXActiveScreens[num];
}
/* /*
** Destroy routine that gets called when a drawable is freed. A drawable ** Destroy routine that gets called when a drawable is freed. A drawable
...@@ -273,6 +276,8 @@ void __glXScreenInit(GLint numscreens) ...@@ -273,6 +276,8 @@ void __glXScreenInit(GLint numscreens)
{ {
GLint i,j; GLint i,j;
__glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */
/* /*
** This alloc has to work or else the server might as well core dump. ** This alloc has to work or else the server might as well core dump.
*/ */
......
/* $XFree86: xc/programs/Xserver/GL/glx/glxserver.h,v 1.4 2001/08/23 18:25:40 alanh Exp $ */ /* $XFree86: xc/programs/Xserver/GL/glx/glxserver.h,v 1.5 2003/09/28 20:15:43 alanh Exp $ */
#ifndef _GLX_server_h_ #ifndef _GLX_server_h_
#define _GLX_server_h_ #define _GLX_server_h_
...@@ -92,6 +92,7 @@ typedef struct __GLXclientStateRec __GLXclientState; ...@@ -92,6 +92,7 @@ typedef struct __GLXclientStateRec __GLXclientState;
extern __GLXscreenInfo *__glXActiveScreens; extern __GLXscreenInfo *__glXActiveScreens;
extern GLint __glXNumActiveScreens; extern GLint __glXNumActiveScreens;
extern __GLXscreenInfo *__glXgetActiveScreen(int num);
/************************************************************************/ /************************************************************************/
......
...@@ -72,6 +72,9 @@ extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv); ...@@ -72,6 +72,9 @@ extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv);
/* context helper routines */ /* context helper routines */
extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag); extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag);
/* init helper routines */
extern void *__glXglDDXScreenInfo(void);
extern void *__glXglDDXExtensionInfo(void);
#endif /* _glxcmds_h_ */ #endif /* _glxcmds_h_ */
...@@ -76,7 +76,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ...@@ -76,7 +76,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* struct. In particular, the contextCreate, pGlxVisual, numVisuals, * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
* and numUsableVisuals fields must be initialized. * and numUsableVisuals fields must be initialized.
*/ */
__GLXscreenInfo __glDDXScreenInfo = { static __GLXscreenInfo __glDDXScreenInfo = {
__MESA_screenProbe, /* Must be generic and handle all screens */ __MESA_screenProbe, /* Must be generic and handle all screens */
__MESA_createContext, /* Substitute screen's createContext routine */ __MESA_createContext, /* Substitute screen's createContext routine */
__MESA_createBuffer, /* Substitute screen's createBuffer routine */ __MESA_createBuffer, /* Substitute screen's createBuffer routine */
...@@ -90,13 +90,21 @@ __GLXscreenInfo __glDDXScreenInfo = { ...@@ -90,13 +90,21 @@ __GLXscreenInfo __glDDXScreenInfo = {
NULL /* WrappedPositionWindow is overwritten */ NULL /* WrappedPositionWindow is overwritten */
}; };
__GLXextensionInfo __glDDXExtensionInfo = { void *__glXglDDXScreenInfo(void) {
return &__glDDXScreenInfo;
}
static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_MESA, GL_CORE_MESA,
__MESA_resetExtension, __MESA_resetExtension,
__MESA_initVisuals, __MESA_initVisuals,
__MESA_setVisualConfigs __MESA_setVisualConfigs
}; };
void *__glXglDDXExtensionInfo(void) {
return &__glDDXExtensionInfo;
}
static __MESA_screen MESAScreens[MAXSCREENS]; static __MESA_screen MESAScreens[MAXSCREENS];
static __GLcontext *MESA_CC = NULL; static __GLcontext *MESA_CC = NULL;
......
...@@ -172,7 +172,7 @@ static void glWinResetExtension(void); ...@@ -172,7 +172,7 @@ static void glWinResetExtension(void);
* struct. In particular, the contextCreate, pGlxVisual, numVisuals, * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
* and numUsableVisuals fields must be initialized. * and numUsableVisuals fields must be initialized.
*/ */
__GLXscreenInfo __glDDXScreenInfo = { static __GLXscreenInfo __glDDXScreenInfo = {
glWinScreenProbe, /* Must be generic and handle all screens */ glWinScreenProbe, /* Must be generic and handle all screens */
glWinCreateContext, /* Substitute screen's createContext routine */ glWinCreateContext, /* Substitute screen's createContext routine */
glWinCreateBuffer, /* Substitute screen's createBuffer routine */ glWinCreateBuffer, /* Substitute screen's createBuffer routine */
...@@ -186,13 +186,21 @@ __GLXscreenInfo __glDDXScreenInfo = { ...@@ -186,13 +186,21 @@ __GLXscreenInfo __glDDXScreenInfo = {
NULL /* WrappedPositionWindow is overwritten */ NULL /* WrappedPositionWindow is overwritten */
}; };
__GLXextensionInfo __glDDXExtensionInfo = { void *__glXglDDXScreenInfo(void) {
return &__glDDXScreenInfo;
}
static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_WINDOWS, GL_CORE_WINDOWS,
glWinResetExtension, glWinResetExtension,
glWinInitVisuals, glWinInitVisuals,
glWinSetVisualConfigs glWinSetVisualConfigs
}; };
void *__glXglDDXExtensionInfo(void) {
return &__glDDXExtensionInfo;
}
/* prototypes */ /* prototypes */
static GLboolean glWinDestroyContext(__GLcontext *gc); static GLboolean glWinDestroyContext(__GLcontext *gc);
......
...@@ -113,6 +113,8 @@ static const char *glcoreSymbols[] = { ...@@ -113,6 +113,8 @@ static const char *glcoreSymbols[] = {
"__glTexGeniv_size", "__glTexGeniv_size",
"__glTexParameterfv_size", "__glTexParameterfv_size",
"__glTexParameteriv_size", "__glTexParameteriv_size",
"__glXglDDXExtensionInfo",
"__glXglDDXScreenInfo",
"__glXActiveScreens", "__glXActiveScreens",
"__glXAssociateContext", "__glXAssociateContext",
"__glXBadContext", "__glXBadContext",
......
...@@ -779,7 +779,7 @@ static Bool ...@@ -779,7 +779,7 @@ static Bool
DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv) DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv)
{ {
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
__GLXscreenInfo *pGLXScreen = &__glXActiveScreens[pScreen->myNum]; __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum);
__GLcontextModes *modes = pGLXScreen->modes; __GLcontextModes *modes = pGLXScreen->modes;
void **pVisualConfigPriv = pGLXScreen->pVisualPriv; void **pVisualConfigPriv = pGLXScreen->pVisualPriv;
DRIContextPrivPtr pDRIContextPriv; DRIContextPrivPtr pDRIContextPriv;
...@@ -843,7 +843,7 @@ DRICreateContext(ScreenPtr pScreen, VisualPtr visual, ...@@ -843,7 +843,7 @@ DRICreateContext(ScreenPtr pScreen, VisualPtr visual,
XID context, drm_context_t * pHWContext) XID context, drm_context_t * pHWContext)
{ {
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
__GLXscreenInfo *pGLXScreen = &__glXActiveScreens[pScreen->myNum]; __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum);
__GLcontextModes *modes = pGLXScreen->modes; __GLcontextModes *modes = pGLXScreen->modes;
void **pVisualConfigPriv = pGLXScreen->pVisualPriv; void **pVisualConfigPriv = pGLXScreen->pVisualPriv;
DRIContextPrivPtr pDRIContextPriv; DRIContextPrivPtr pDRIContextPriv;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment