glxmodule.c revision 05b261ec
1/************************************************************************** 2 3Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 4All Rights Reserved. 5 6Permission is hereby granted, free of charge, to any person obtaining a 7copy of this software and associated documentation files (the 8"Software"), to deal in the Software without restriction, including 9without limitation the rights to use, copy, modify, merge, publish, 10distribute, sub license, and/or sell copies of the Software, and to 11permit persons to whom the Software is furnished to do so, subject to 12the following conditions: 13 14The above copyright notice and this permission notice (including the 15next paragraph) shall be included in all copies or substantial portions 16of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 22ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 26**************************************************************************/ 27 28/* 29 * Authors: 30 * Kevin E. Martin <kevin@precisioninsight.com> 31 * 32 */ 33 34#ifdef HAVE_XORG_CONFIG_H 35#include <xorg-config.h> 36#endif 37 38#include "xf86Module.h" 39#include "xf86Priv.h" 40#include "xf86.h" 41#include "colormap.h" 42#include "micmap.h" 43#include "globals.h" 44 45typedef struct __GLXscreen __GLXscreen; 46typedef struct __GLXprovider __GLXprovider; 47struct __GLXprovider { 48 __GLXscreen *(*screenProbe)(ScreenPtr pScreen); 49 const char *name; 50 __GLXprovider *next; 51}; 52 53extern void GlxPushProvider(__GLXprovider *provider); 54extern void GlxExtensionInit(void); 55extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); 56 57static MODULESETUPPROTO(glxSetup); 58 59static const char *initdeps[] = { "DOUBLE-BUFFER", NULL }; 60 61static ExtensionModule GLXExt = 62{ 63 GlxExtensionInit, 64 "GLX", 65 &noGlxExtension, 66 NULL, 67 initdeps 68}; 69 70static XF86ModuleVersionInfo VersRec = 71{ 72 "glx", 73 MODULEVENDORSTRING, 74 MODINFOSTRING1, 75 MODINFOSTRING2, 76 XORG_VERSION_CURRENT, 77 1, 0, 0, 78 ABI_CLASS_EXTENSION, 79 ABI_EXTENSION_VERSION, 80 MOD_CLASS_NONE, 81 {0,0,0,0} 82}; 83 84_X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL }; 85 86/* We do a little proxy dance here, so we can avoid loading GLcore 87 * unless we really need to.*/ 88 89static pointer glxModule; 90 91static __GLXscreen * 92__glXMesaProxyScreenProbe(ScreenPtr pScreen) 93{ 94 pointer GLcore; 95 static __GLXprovider *provider; 96 97 if (provider == NULL) { 98 GLcore = LoadSubModule(glxModule, "GLcore", NULL, NULL, NULL, NULL, 99 NULL, NULL); 100 if (GLcore == NULL) 101 return NULL; 102 103 provider = LoaderSymbol("__glXMesaProvider"); 104 if (provider == NULL) 105 return NULL; 106 } 107 108 return provider->screenProbe(pScreen); 109} 110 111static __GLXprovider __glXMesaProxyProvider = { 112 __glXMesaProxyScreenProbe, 113 "MESA-PROXY", 114 NULL 115}; 116 117 118static pointer 119glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) 120{ 121 static Bool setupDone = FALSE; 122 __GLXprovider *provider; 123 124 if (setupDone) { 125 if (errmaj) *errmaj = LDR_ONCEONLY; 126 return NULL; 127 } 128 129 setupDone = TRUE; 130 131 glxModule = module; 132 GlxPushProvider(&__glXMesaProxyProvider); 133 134 xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n", 135 xf86Info.aiglx ? "enabled" : "disabled"); 136 if (xf86Info.aiglx) { 137 provider = LoaderSymbol("__glXDRIProvider"); 138 if (provider) 139 GlxPushProvider(provider); 140 } 141 142 LoadExtension(&GLXExt, FALSE); 143 /* Wrap the init visuals routine in micmap.c */ 144 GlxWrapInitVisuals(&miInitVisualsProc); 145 /* Make sure this gets wrapped each time InitVisualWrap is called */ 146 miHookInitVisuals(NULL, GlxWrapInitVisuals); 147 148 bail: 149 return module; 150} 151