glx: make xf86vidmode mandatory for direct rendering
[mesa.git] / src / glx / glxext.c
index 9cbe334772391cc98ef5210b7b26bcd410aef1cc..cef81920356e8a69f7a27ef9239fb915611cbe42 100644 (file)
@@ -38,6 +38,8 @@
  */
 
 #include <assert.h>
+#include <stdbool.h>
+
 #include "glxclient.h"
 #include <X11/extensions/Xext.h>
 #include <X11/extensions/extutil.h>
@@ -47,6 +49,8 @@
 #endif
 #include "glxextensions.h"
 
+#include "util/debug.h"
+
 #include <X11/Xlib-xcb.h>
 #include <xcb/xcb.h>
 #include <xcb/glx.h>
@@ -339,9 +343,12 @@ static GLint
 convert_from_x_visual_type(int visualType)
 {
    static const int glx_visual_types[] = {
-      GLX_STATIC_GRAY, GLX_GRAY_SCALE,
-      GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
-      GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+      [StaticGray]  = GLX_STATIC_GRAY,
+      [GrayScale]   = GLX_GRAY_SCALE,
+      [StaticColor] = GLX_STATIC_COLOR,
+      [PseudoColor] = GLX_PSEUDO_COLOR,
+      [TrueColor]   = GLX_TRUE_COLOR,
+      [DirectColor] = GLX_DIRECT_COLOR,
    };
 
    if (visualType < ARRAY_SIZE(glx_visual_types))
@@ -398,8 +405,6 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
 #endif
    }
 
-   config->sRGBCapable = GL_FALSE;
-
    /*
     ** Additional properties may be in a list at the end
     ** of the reply.  They are in pairs of property type
@@ -577,7 +582,7 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
          i = count;
          break;
       default:
-         if(getenv("LIBGL_DIAGNOSTIC")) {
+         if(env_var_as_boolean("LIBGL_DIAGNOSTIC", false)) {
              long int tagvalue = *bp++;
              fprintf(stderr, "WARNING: unknown GLX tag from server: "
                      "tag 0x%lx value 0x%lx\n", tag, tagvalue);
@@ -656,6 +661,8 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
        */
       m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
 #endif
+      /* Older X servers don't send this so we default it here. */
+      m->sRGBCapable = GL_FALSE;
        __glXInitializeVisualConfigFromTags(m, nprops, props,
                                           tagged_only, GL_TRUE);
       m->screen = screen;
@@ -903,8 +910,8 @@ __glXInitialize(Display * dpy)
    dpyPriv->glXDrawHash = __glxHashCreate();
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-   glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
-   glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
+   glx_direct = !env_var_as_boolean("LIBGL_ALWAYS_INDIRECT", false);
+   glx_accel = !env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
 
    dpyPriv->drawHash = __glxHashCreate();
 
@@ -916,7 +923,7 @@ __glXInitialize(Display * dpy)
 #if defined(GLX_USE_DRM)
    if (glx_direct && glx_accel) {
 #if defined(HAVE_DRI3)
-      if (!getenv("LIBGL_DRI3_DISABLE"))
+      if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
          dpyPriv->dri3Display = dri3_create_display(dpy);
 #endif /* HAVE_DRI3 */
       dpyPriv->dri2Display = dri2CreateDisplay(dpy);