glsl: Fold implementation of ir_dereference_array::constant_referenced into wrapper
[mesa.git] / src / glx / glxext.c
index e55c1c17841c6ddf701ab2ef7e1d4987475b80b9..4a195bd40ba272da5125d22a037e52826b434e37 100644 (file)
@@ -269,7 +269,8 @@ __glXCloseDisplay(Display * dpy, XExtCodes * codes)
    }
    _XUnlockMutex(_Xglobal_lock);
 
-   glx_display_free(priv);
+   if (priv != NULL)
+      glx_display_free(priv);
 
    return 1;
 }
@@ -337,6 +338,7 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
                                     Bool fbconfig_style_tags)
 {
    int i;
+   GLint renderType = 0;
 
    if (!tagged_only) {
       /* Copy in the first set of properties */
@@ -374,6 +376,8 @@ __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
@@ -469,8 +473,8 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
          config->drawableType |= GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;              
 #endif
          break;
-      case GLX_RENDER_TYPE:
-         config->renderType = *bp++;
+      case GLX_RENDER_TYPE: /* fbconfig render type bits */
+         renderType = *bp++;
          break;
       case GLX_X_RENDERABLE:
          config->xRenderable = *bp++;
@@ -553,8 +557,27 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
       }
    }
 
-   config->renderType =
-      (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+   if (renderType != 0 && renderType != GLX_DONT_CARE) {
+      config->renderType = renderType;
+      config->floatMode = (renderType &
+         (GLX_RGBA_FLOAT_BIT_ARB|GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT)) != 0;
+   } else {
+      /* If there wasn't GLX_RENDER_TYPE property, set it based on
+       * config->rgbMode.  The only way to communicate that the config is
+       * floating-point is via GLX_RENDER_TYPE, so this cannot be a float
+       * config.
+       */
+      config->renderType =
+         (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+   }
+
+   /* The GLX_ARB_fbconfig_float spec says:
+    *
+    *     "Note that floating point rendering is only supported for
+    *     GLXPbuffer drawables."
+    */
+   if (config->floatMode)
+      config->drawableType &= ~(GLX_WINDOW_BIT|GLX_PIXMAP_BIT);
 }
 
 static struct glx_config *
@@ -748,7 +771,11 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
    for (i = 0; i < screens; i++, psc++) {
       psc = NULL;
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-      if (priv->dri2Display)
+#if defined(HAVE_DRI3)
+      if (priv->dri3Display)
+         psc = (*priv->dri3Display->createScreen) (i, priv);
+#endif
+      if (psc == NULL && priv->dri2Display)
         psc = (*priv->dri2Display->createScreen) (i, priv);
       if (psc == NULL && priv->driDisplay)
         psc = (*priv->driDisplay->createScreen) (i, priv);
@@ -841,6 +868,10 @@ __glXInitialize(Display * dpy)
     ** (e.g., those called in AllocAndFetchScreenConfigs).
     */
    if (glx_direct && glx_accel) {
+#if defined(HAVE_DRI3)
+      if (!getenv("LIBGL_DRI3_DISABLE"))
+         dpyPriv->dri3Display = dri3_create_display(dpy);
+#endif
       dpyPriv->dri2Display = dri2CreateDisplay(dpy);
       dpyPriv->driDisplay = driCreateDisplay(dpy);
    }