Introduce a new "GlxVisuals" option that controls which visuals are added.

Right now we default to "all" which gives us a situation much like before,
but when the "typical" option is implemented, we can change the default and
reduce the number of visuals the GLX module bloats the X server with.
This commit is contained in:
Kristian Høgsberg 2007-10-18 21:01:51 -04:00
parent 9e3cfd950d
commit 8e3c1dfc48
7 changed files with 161 additions and 51 deletions

View File

@ -42,10 +42,6 @@
#include <damage.h> #include <damage.h>
#ifdef XF86DRI
#include <GL/internal/dri_interface.h>
#endif
/* We just need to avoid clashing with DRAWABLE_{WINDOW,PIXMAP} */ /* We just need to avoid clashing with DRAWABLE_{WINDOW,PIXMAP} */
enum { enum {
GLX_DRAWABLE_WINDOW, GLX_DRAWABLE_WINDOW,

View File

@ -393,10 +393,7 @@ findFirstSet(unsigned int v)
static void static void
initGlxVisual(VisualPtr visual, __GLcontextModes *config) initGlxVisual(VisualPtr visual, __GLcontextModes *config)
{ {
ErrorF("Adding visual 0x%02lx for fbconfig %d\n", config->visualID = visual->vid;
visual->vid, config->fbconfigID);
config->visualID = visual[0].vid;
visual->class = _gl_convert_to_x_visual_type(config->visualType); visual->class = _gl_convert_to_x_visual_type(config->visualType);
visual->bitsPerRGBValue = config->redBits; visual->bitsPerRGBValue = config->redBits;
visual->ColormapEntries = 1 << config->redBits; visual->ColormapEntries = 1 << config->redBits;
@ -411,37 +408,84 @@ initGlxVisual(VisualPtr visual, __GLcontextModes *config)
} }
static void static void
addGlxVisuals(__GLXscreen *pGlxScreen) addMinimalSet(__GLXscreen *pGlxScreen)
{ {
__GLcontextModes *config; __GLcontextModes *config;
VisualPtr visual; VisualPtr visuals;
int depth;
/* Select a subset of fbconfigs that we send to the client when it for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
* asks for the glx visuals. All the fbconfigs here have a valid if (config->visualRating != GLX_NONE)
* value for visual ID and each visual ID is only present once. continue;
* This runs before composite adds its extra visual so we have to if (config->doubleBufferMode && config->depthBits > 0)
* remember the number of visuals here.*/
/* For now, just add the first double buffer fbconfig. */
for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next)
if (config->doubleBufferMode)
break; break;
}
if (config == NULL) if (config == NULL)
config = pGlxScreen->fbconfigs; config = pGlxScreen->fbconfigs;
pGlxScreen->visuals = xcalloc(1, sizeof (__GLcontextModes *)); pGlxScreen->visuals = xcalloc(1, sizeof (__GLcontextModes *));
visual = AddScreenVisuals(pGlxScreen->pScreen, 1, config->rgbBits); if (pGlxScreen->visuals == NULL) {
if (visual == NULL) { ErrorF("Failed to allocate for minimal set of GLX visuals\n");
return;
}
depth = config->redBits + config->greenBits + config->blueBits;
visuals = AddScreenVisuals(pGlxScreen->pScreen, 1, depth);
if (visuals == NULL) {
xfree(pGlxScreen->visuals); xfree(pGlxScreen->visuals);
return; return;
} }
pGlxScreen->numVisuals = 1; pGlxScreen->numVisuals = 1;
pGlxScreen->visuals[0] = config; pGlxScreen->visuals[0] = config;
initGlxVisual(&visual[0], config); initGlxVisual(&visuals[0], config);
} }
void __glXScreenInit(__GLXscreen *glxScreen, ScreenPtr pScreen) static void
addTypicalSet(__GLXscreen *pGlxScreen)
{
addMinimalSet(pGlxScreen);
}
static void
addFullSet(__GLXscreen *pGlxScreen)
{
__GLcontextModes *config;
VisualPtr visuals;
int i, depth;
pGlxScreen->visuals =
xcalloc(pGlxScreen->numFBConfigs, sizeof (__GLcontextModes *));
if (pGlxScreen->visuals == NULL) {
ErrorF("Failed to allocate for full set of GLX visuals\n");
return;
}
config = pGlxScreen->fbconfigs;
depth = config->redBits + config->greenBits + config->blueBits;
visuals = AddScreenVisuals(pGlxScreen->pScreen, pGlxScreen->numFBConfigs, depth);
if (visuals == NULL) {
xfree(pGlxScreen->visuals);
return;
}
ErrorF("addFullSet, setting numVisuals to %d\n", pGlxScreen->numFBConfigs);
pGlxScreen->numVisuals = pGlxScreen->numFBConfigs;
for (i = 0, config = pGlxScreen->fbconfigs; config; config = config->next, i++) {
pGlxScreen->visuals[i] = config;
initGlxVisual(&visuals[i], config);
}
}
static int glxVisualConfig = GLX_ALL_VISUALS;
void GlxSetVisualConfig(int config)
{
glxVisualConfig = config;
}
void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
{ {
static int glxGeneration; static int glxGeneration;
__GLcontextModes *m; __GLcontextModes *m;
@ -457,28 +501,44 @@ void __glXScreenInit(__GLXscreen *glxScreen, ScreenPtr pScreen)
} }
i = 0; i = 0;
for (m = glxScreen->fbconfigs; m != NULL; m = m->next) { for (m = pGlxScreen->fbconfigs; m != NULL; m = m->next) {
m->fbconfigID = FakeClientID(0); m->fbconfigID = FakeClientID(0);
m->visualID = findVisualForConfig(pScreen, m); m->visualID = findVisualForConfig(pScreen, m);
i++; i++;
} }
glxScreen->numFBConfigs = i; pGlxScreen->numFBConfigs = i;
addGlxVisuals(glxScreen); /* Select a subset of fbconfigs that we send to the client when it
* asks for the glx visuals. All the fbconfigs here have a valid
* value for visual ID and each visual ID is only present once.
* This runs before composite adds its extra visual so we have to
* remember the number of visuals here.*/
glxScreen->pScreen = pScreen; switch (glxVisualConfig) {
glxScreen->GLextensions = xstrdup(GLServerExtensions); case GLX_MINIMAL_VISUALS:
glxScreen->GLXvendor = xstrdup(GLXServerVendorName); addMinimalSet(pGlxScreen);
glxScreen->GLXversion = xstrdup(GLXServerVersion); break;
glxScreen->GLXextensions = xstrdup(GLXServerExtensions); case GLX_TYPICAL_VISUALS:
addTypicalSet(pGlxScreen);
break;
case GLX_ALL_VISUALS:
addFullSet(pGlxScreen);
break;
}
glxScreen->PositionWindow = pScreen->PositionWindow; pGlxScreen->pScreen = pScreen;
pGlxScreen->GLextensions = xstrdup(GLServerExtensions);
pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName);
pGlxScreen->GLXversion = xstrdup(GLXServerVersion);
pGlxScreen->GLXextensions = xstrdup(GLXServerExtensions);
pGlxScreen->PositionWindow = pScreen->PositionWindow;
pScreen->PositionWindow = glxPositionWindow; pScreen->PositionWindow = glxPositionWindow;
glxScreen->CloseScreen = pScreen->CloseScreen; pGlxScreen->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = glxCloseScreen; pScreen->CloseScreen = glxCloseScreen;
pScreen->devPrivates[glxScreenPrivateIndex].ptr = (pointer) glxScreen; pScreen->devPrivates[glxScreenPrivateIndex].ptr = (pointer) pGlxScreen;
} }
void __glXScreenDestroy(__GLXscreen *screen) void __glXScreenDestroy(__GLXscreen *screen)

View File

@ -95,6 +95,8 @@ extern __GLXclientState *glxGetClient(ClientPtr pClient);
/************************************************************************/ /************************************************************************/
void GlxExtensionInit(void);
void GlxSetVisualConfigs(int nconfigs, void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs, void **privates); __GLXvisualConfig *configs, void **privates);
@ -132,6 +134,14 @@ struct __GLXprovider {
void GlxPushProvider(__GLXprovider *provider); void GlxPushProvider(__GLXprovider *provider);
enum {
GLX_MINIMAL_VISUALS,
GLX_TYPICAL_VISUALS,
GLX_ALL_VISUALS
};
void GlxSetVisualConfig(int config);
void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean), void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
void (*leave)(GLboolean)); void (*leave)(GLboolean));
void __glXenterServer(GLboolean rendering); void __glXenterServer(GLboolean rendering);

View File

@ -792,6 +792,7 @@ typedef enum {
FLAG_USE_DEFAULT_FONT_PATH, FLAG_USE_DEFAULT_FONT_PATH,
FLAG_AUTO_ADD_DEVICES, FLAG_AUTO_ADD_DEVICES,
FLAG_AUTO_ENABLE_DEVICES, FLAG_AUTO_ENABLE_DEVICES,
FLAG_GLX_VISUALS,
} FlagValues; } FlagValues;
static OptionInfoRec FlagOptions[] = { static OptionInfoRec FlagOptions[] = {
@ -873,6 +874,8 @@ static OptionInfoRec FlagOptions[] = {
{0}, TRUE }, {0}, TRUE },
{ FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN, { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
{0}, TRUE }, {0}, TRUE },
{ FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
{0}, FALSE },
{ -1, NULL, OPTV_NONE, { -1, NULL, OPTV_NONE,
{0}, FALSE }, {0}, FALSE },
}; };
@ -904,6 +907,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
Pix24Flags pix24 = Pix24DontCare; Pix24Flags pix24 = Pix24DontCare;
Bool value; Bool value;
MessageType from; MessageType from;
const char *s;
/* /*
* Merge the ServerLayout and ServerFlags options. The former have * Merge the ServerLayout and ServerFlags options. The former have
@ -1021,7 +1025,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value)) if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
xf86Info.pmFlag = !value; xf86Info.pmFlag = !value;
{ {
const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) { if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
if (!xf86NameCmp(s,"flush")) { if (!xf86NameCmp(s,"flush")) {
xf86Msg(X_CONFIG, "Flushing logfile enabled\n"); xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
@ -1040,8 +1043,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
#ifdef RENDER #ifdef RENDER
{ {
const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){ if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
int policy = PictureParseCmapPolicy (s); int policy = PictureParseCmapPolicy (s);
if (policy == PictureCmapPolicyInvalid) if (policy == PictureCmapPolicyInvalid)
@ -1055,7 +1056,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
} }
#endif #endif
{ {
const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) { if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
if (!xf86NameCmp(s,"always")) { if (!xf86NameCmp(s,"always")) {
xf86Msg(X_CONFIG, "Always handling special keys in DDX\n"); xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
@ -1093,6 +1093,27 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.aiglxFrom = X_CONFIG; xf86Info.aiglxFrom = X_CONFIG;
} }
#ifdef GLXEXT
xf86Info.glxVisuals = XF86_GlxVisualsAll;
xf86Info.glxVisualsFrom = X_DEFAULT;
if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
if (!xf86NameCmp(s, "minimal")) {
xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
} else if (!xf86NameCmp(s, "typical")) {
xf86Info.glxVisuals = XF86_GlxVisualsTypical;
} else if (!xf86NameCmp(s, "all")) {
xf86Info.glxVisuals = XF86_GlxVisualsAll;
} else {
xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
}
}
if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
xf86Info.aiglx = value;
xf86Info.aiglxFrom = X_CONFIG;
}
#endif
xf86Info.allowEmptyInput = FALSE; xf86Info.allowEmptyInput = FALSE;
if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value)) if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value))
xf86Info.allowEmptyInput = TRUE; xf86Info.allowEmptyInput = TRUE;

View File

@ -60,6 +60,12 @@ typedef enum {
SKAlways SKAlways
} SpecialKeysInDDX; } SpecialKeysInDDX;
typedef enum {
XF86_GlxVisualsMinimal,
XF86_GlxVisualsTypical,
XF86_GlxVisualsAll,
} XF86_GlxVisuals;
/* /*
* xf86InfoRec contains global parameters which the video drivers never * xf86InfoRec contains global parameters which the video drivers never
* need to access. Global parameters which the video drivers do need * need to access. Global parameters which the video drivers do need
@ -120,6 +126,9 @@ typedef struct {
MessageType randRFrom; MessageType randRFrom;
Bool aiglx; Bool aiglx;
MessageType aiglxFrom; MessageType aiglxFrom;
XF86_GlxVisuals glxVisuals;
MessageType glxVisualsFrom;
Bool useDefaultFontPath; Bool useDefaultFontPath;
MessageType useDefaultFontPathFrom; MessageType useDefaultFontPathFrom;
Bool ignoreABI; Bool ignoreABI;

View File

@ -41,17 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "colormap.h" #include "colormap.h"
#include "micmap.h" #include "micmap.h"
#include "globals.h" #include "globals.h"
#include "glxserver.h"
typedef struct __GLXscreen __GLXscreen;
typedef struct __GLXprovider __GLXprovider;
struct __GLXprovider {
__GLXscreen *(*screenProbe)(ScreenPtr pScreen);
const char *name;
__GLXprovider *next;
};
extern void GlxPushProvider(__GLXprovider *provider);
extern void GlxExtensionInit(void);
static MODULESETUPPROTO(glxSetup); static MODULESETUPPROTO(glxSetup);
@ -113,7 +103,6 @@ static __GLXprovider __glXMesaProxyProvider = {
NULL NULL
}; };
static pointer static pointer
glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{ {
@ -138,8 +127,22 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
GlxPushProvider(provider); GlxPushProvider(provider);
} }
switch (xf86Info.glxVisuals) {
case XF86_GlxVisualsMinimal:
GlxSetVisualConfig(GLX_MINIMAL_VISUALS);
xf86Msg(xf86Info.aiglxFrom, "Exporting only minimal set of GLX visuals\n");
break;
case XF86_GlxVisualsTypical:
GlxSetVisualConfig(GLX_TYPICAL_VISUALS);
xf86Msg(xf86Info.aiglxFrom, "Exporting typical set of GLX visuals\n");
break;
case XF86_GlxVisualsAll:
GlxSetVisualConfig(GLX_ALL_VISUALS);
xf86Msg(xf86Info.aiglxFrom, "Exporting all GLX visuals\n");
break;
}
LoadExtension(&GLXExt, FALSE); LoadExtension(&GLXExt, FALSE);
bail:
return module; return module;
} }

View File

@ -700,6 +700,17 @@ the builtin handler will be used.
.BI "Option \*qAIGLX\*q \*q" boolean \*q .BI "Option \*qAIGLX\*q \*q" boolean \*q
enable or disable AIGLX. AIGLX is enabled by default. enable or disable AIGLX. AIGLX is enabled by default.
.TP 7 .TP 7
.BI "Option \*qGlxVisuals\*q \*q" string \*q
This option controls how many GLX visuals the GLX modules sets up.
The default value is
.BR "typical" ,
which will setup up a typical subset of
the GLXFBConfigs provided by the driver as GLX visuals. Other options are
.BR "minimal" ,
which will set up the minimal set allowed by the GLX specification and
.BR "all"
which will setup GLX visuals for all GLXFBConfigs.
.TP 7
.BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q .BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q
Include the default font path even if other paths are specified in Include the default font path even if other paths are specified in
xorg.conf. If enabled, other font paths are included as well. Enabled by xorg.conf. If enabled, other font paths are included as well. Enabled by