Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / drivers / dri / common / dri_util.c
index c3d1f2c4542bc227664742ec495b18580a9a2ade..a5b71bd40adb51c683b65a1fefa9e6acfd99c17f 100644 (file)
@@ -32,6 +32,7 @@
 #include "drm_sarea.h"
 #include "utils.h"
 #include "xmlpool.h"
+#include "../glsl/glsl_parser_extras.h"
 
 PUBLIC const char __dri2ConfigOptions[] =
    DRI_CONF_BEGIN
@@ -423,6 +424,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
        return NULL;
     }
 
+    pdp->driContextPriv = NULL;
     pdp->loaderPrivate = data;
     pdp->hHWDrawable = hwDrawable;
     pdp->refcount = 1;
@@ -442,8 +444,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
 
     pdp->driScreenPriv = psp;
 
-    if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes,
-                                       renderType == GLX_PIXMAP_BIT)) {
+    if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes, 0)) {
        free(pdp);
        return NULL;
     }
@@ -633,6 +634,7 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
                           __DRIcontext *shared, void *data)
 {
     __DRIcontext *context;
+    const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
     void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
     gl_api mesa_api;
 
@@ -649,6 +651,8 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
     case __DRI_API_GLES2:
            mesa_api = API_OPENGLES2;
            break;
+    default:
+           return NULL;
     }
 
     context = malloc(sizeof *context);
@@ -659,7 +663,7 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
     context->driDrawablePriv = NULL;
     context->loaderPrivate = data;
     
-    if (!(*screen->DriverAPI.CreateContext)(api, &config->modes,
+    if (!(*screen->DriverAPI.CreateContext)(mesa_api, modes,
                                            context, shareCtx) ) {
         free(context);
         return NULL;
@@ -706,6 +710,8 @@ static void driDestroyScreen(__DRIscreen *psp)
         * stream open to the X-server anymore.
         */
 
+       _mesa_destroy_shader_compiler();
+
        if (psp->DriverAPI.DestroyScreen)
            (*psp->DriverAPI.DestroyScreen)(psp);
 
@@ -713,6 +719,9 @@ static void driDestroyScreen(__DRIscreen *psp)
           (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
           (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
           (void)drmCloseOnce(psp->fd);
+       } else {
+          driDestroyOptionCache(&psp->optionCache);
+          driDestroyOptionInfo(&psp->optionInfo);
        }
 
        free(psp);
@@ -745,7 +754,7 @@ setupLoaderExtensions(__DRIscreen *psp,
  * This is the bootstrap function for the driver.  libGL supplies all of the
  * requisite information about the system, and the driver initializes itself.
  * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
+ * with the \c struct gl_config that the driver can support for windows or
  * pbuffers.
  *
  * For legacy DRI.
@@ -838,7 +847,6 @@ dri2CreateNewScreen(int scrn, int fd,
     static const __DRIextension *emptyExtensionList[] = { NULL };
     __DRIscreen *psp;
     drmVersionPtr version;
-    driOptionCache options;
 
     if (driDriverAPI.InitScreen2 == NULL)
         return NULL;
@@ -871,9 +879,12 @@ dri2CreateNewScreen(int scrn, int fd,
     }
 
     psp->DriverAPI = driDriverAPI;
+    psp->loaderPrivate = data;
 
-    driParseOptionInfo(&options, __dri2ConfigOptions, __dri2NConfigOptions);
-    driParseConfigFiles(&psp->optionCache, &options, psp->myNum, "dri2");
+    driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions,
+                      __dri2NConfigOptions);
+    driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum,
+                       "dri2");
 
     return psp;
 }
@@ -926,41 +937,6 @@ const __DRI2configQueryExtension dri2ConfigQueryExtension = {
    dri2ConfigQueryf,
 };
 
-static int
-driFrameTracking(__DRIdrawable *drawable, GLboolean enable)
-{
-    return GLX_BAD_CONTEXT;
-}
-
-static int
-driQueryFrameTracking(__DRIdrawable *dpriv,
-                     int64_t * sbc, int64_t * missedFrames,
-                     float * lastMissedUsage, float * usage)
-{
-   __DRIswapInfo   sInfo;
-   int             status;
-   int64_t         ust;
-   __DRIscreen *psp = dpriv->driScreenPriv;
-
-   status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo );
-   if ( status == 0 ) {
-      *sbc = sInfo.swap_count;
-      *missedFrames = sInfo.swap_missed_count;
-      *lastMissedUsage = sInfo.swap_missed_usage;
-
-      (*psp->systemTime->getUST)( & ust );
-      *usage = driCalculateSwapUsage( dpriv, sInfo.swap_ust, ust );
-   }
-
-   return status;
-}
-
-const __DRIframeTrackingExtension driFrameTrackingExtension = {
-    { __DRI_FRAME_TRACKING, __DRI_FRAME_TRACKING_VERSION },
-    driFrameTracking,
-    driQueryFrameTracking    
-};
-
 /**
  * Calculate amount of swap interval used between GLX buffer swaps.
  *