Commit 8e3c1dfc authored by Kristian Høgsberg's avatar Kristian Høgsberg

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.
parent 9e3cfd95
......@@ -42,10 +42,6 @@
#include <damage.h>
#ifdef XF86DRI
#include <GL/internal/dri_interface.h>
#endif
/* We just need to avoid clashing with DRAWABLE_{WINDOW,PIXMAP} */
enum {
GLX_DRAWABLE_WINDOW,
......
......@@ -393,10 +393,7 @@ findFirstSet(unsigned int v)
static void
initGlxVisual(VisualPtr visual, __GLcontextModes *config)
{
ErrorF("Adding visual 0x%02lx for fbconfig %d\n",
visual->vid, config->fbconfigID);
config->visualID = visual[0].vid;
config->visualID = visual->vid;
visual->class = _gl_convert_to_x_visual_type(config->visualType);
visual->bitsPerRGBValue = config->redBits;
visual->ColormapEntries = 1 << config->redBits;
......@@ -411,37 +408,84 @@ initGlxVisual(VisualPtr visual, __GLcontextModes *config)
}
static void
addGlxVisuals(__GLXscreen *pGlxScreen)
addMinimalSet(__GLXscreen *pGlxScreen)
{
__GLcontextModes *config;
VisualPtr visual;
VisualPtr visuals;
int depth;
/* 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.*/
/* For now, just add the first double buffer fbconfig. */
for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next)
if (config->doubleBufferMode)
for (config = pGlxScreen->fbconfigs; config != NULL; config = config->next) {
if (config->visualRating != GLX_NONE)
continue;
if (config->doubleBufferMode && config->depthBits > 0)
break;
}
if (config == NULL)
config = pGlxScreen->fbconfigs;
pGlxScreen->visuals = xcalloc(1, sizeof (__GLcontextModes *));
visual = AddScreenVisuals(pGlxScreen->pScreen, 1, config->rgbBits);
if (visual == NULL) {
if (pGlxScreen->visuals == 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);
return;
}
pGlxScreen->numVisuals = 1;
pGlxScreen->visuals[0] = config;
initGlxVisual(&visual[0], config);
initGlxVisual(&visuals[0], config);
}
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);
}
}
void __glXScreenInit(__GLXscreen *glxScreen, ScreenPtr pScreen)
static int glxVisualConfig = GLX_ALL_VISUALS;
void GlxSetVisualConfig(int config)
{
glxVisualConfig = config;
}
void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
{
static int glxGeneration;
__GLcontextModes *m;
......@@ -457,28 +501,44 @@ void __glXScreenInit(__GLXscreen *glxScreen, ScreenPtr pScreen)
}
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->visualID = findVisualForConfig(pScreen, m);
i++;
}
glxScreen->numFBConfigs = i;
pGlxScreen->numFBConfigs = i;
/* 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.*/
addGlxVisuals(glxScreen);
switch (glxVisualConfig) {
case GLX_MINIMAL_VISUALS:
addMinimalSet(pGlxScreen);
break;
case GLX_TYPICAL_VISUALS:
addTypicalSet(pGlxScreen);
break;
case GLX_ALL_VISUALS:
addFullSet(pGlxScreen);
break;
}
glxScreen->pScreen = pScreen;
glxScreen->GLextensions = xstrdup(GLServerExtensions);
glxScreen->GLXvendor = xstrdup(GLXServerVendorName);
glxScreen->GLXversion = xstrdup(GLXServerVersion);
glxScreen->GLXextensions = xstrdup(GLXServerExtensions);
pGlxScreen->pScreen = pScreen;
pGlxScreen->GLextensions = xstrdup(GLServerExtensions);
pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName);
pGlxScreen->GLXversion = xstrdup(GLXServerVersion);
pGlxScreen->GLXextensions = xstrdup(GLXServerExtensions);
glxScreen->PositionWindow = pScreen->PositionWindow;
pGlxScreen->PositionWindow = pScreen->PositionWindow;
pScreen->PositionWindow = glxPositionWindow;
glxScreen->CloseScreen = pScreen->CloseScreen;
pGlxScreen->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = glxCloseScreen;
pScreen->devPrivates[glxScreenPrivateIndex].ptr = (pointer) glxScreen;
pScreen->devPrivates[glxScreenPrivateIndex].ptr = (pointer) pGlxScreen;
}
void __glXScreenDestroy(__GLXscreen *screen)
......
......@@ -95,6 +95,8 @@ extern __GLXclientState *glxGetClient(ClientPtr pClient);
/************************************************************************/
void GlxExtensionInit(void);
void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs, void **privates);
......@@ -132,6 +134,14 @@ struct __GLXprovider {
void GlxPushProvider(__GLXprovider *provider);
enum {
GLX_MINIMAL_VISUALS,
GLX_TYPICAL_VISUALS,
GLX_ALL_VISUALS
};
void GlxSetVisualConfig(int config);
void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
void (*leave)(GLboolean));
void __glXenterServer(GLboolean rendering);
......
......@@ -792,6 +792,7 @@ typedef enum {
FLAG_USE_DEFAULT_FONT_PATH,
FLAG_AUTO_ADD_DEVICES,
FLAG_AUTO_ENABLE_DEVICES,
FLAG_GLX_VISUALS,
} FlagValues;
static OptionInfoRec FlagOptions[] = {
......@@ -873,6 +874,8 @@ static OptionInfoRec FlagOptions[] = {
{0}, TRUE },
{ FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
{0}, TRUE },
{ FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
{0}, FALSE },
{ -1, NULL, OPTV_NONE,
{0}, FALSE },
};
......@@ -904,6 +907,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
Pix24Flags pix24 = Pix24DontCare;
Bool value;
MessageType from;
const char *s;
/*
* Merge the ServerLayout and ServerFlags options. The former have
......@@ -1021,7 +1025,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
xf86Info.pmFlag = !value;
{
const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
if (!xf86NameCmp(s,"flush")) {
xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
......@@ -1040,8 +1043,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
#ifdef RENDER
{
const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
int policy = PictureParseCmapPolicy (s);
if (policy == PictureCmapPolicyInvalid)
......@@ -1055,7 +1056,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
}
#endif
{
const char *s;
if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
if (!xf86NameCmp(s,"always")) {
xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
......@@ -1093,6 +1093,27 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
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;
if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value))
xf86Info.allowEmptyInput = TRUE;
......
......@@ -60,6 +60,12 @@ typedef enum {
SKAlways
} SpecialKeysInDDX;
typedef enum {
XF86_GlxVisualsMinimal,
XF86_GlxVisualsTypical,
XF86_GlxVisualsAll,
} XF86_GlxVisuals;
/*
* xf86InfoRec contains global parameters which the video drivers never
* need to access. Global parameters which the video drivers do need
......@@ -120,6 +126,9 @@ typedef struct {
MessageType randRFrom;
Bool aiglx;
MessageType aiglxFrom;
XF86_GlxVisuals glxVisuals;
MessageType glxVisualsFrom;
Bool useDefaultFontPath;
MessageType useDefaultFontPathFrom;
Bool ignoreABI;
......
......@@ -41,17 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "colormap.h"
#include "micmap.h"
#include "globals.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);
#include "glxserver.h"
static MODULESETUPPROTO(glxSetup);
......@@ -113,7 +103,6 @@ static __GLXprovider __glXMesaProxyProvider = {
NULL
};
static pointer
glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
......@@ -138,8 +127,22 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
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);
bail:
return module;
}
......@@ -700,6 +700,17 @@ the builtin handler will be used.
.BI "Option \*qAIGLX\*q \*q" boolean \*q
enable or disable AIGLX. AIGLX is enabled by default.
.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
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
......
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