Drop createContext and destroyContext from DRIinterfaceMethods.
authorKristian Høgsberg <krh@hinata.boston.redhat.com>
Thu, 10 May 2007 22:38:49 +0000 (18:38 -0400)
committerKristian Høgsberg <krh@redhat.com>
Wed, 10 Oct 2007 21:09:16 +0000 (17:09 -0400)
As for createDrawable and destroyDrawable, these functions immediately
upon entry to driCreateNewContext and immediately before exit from
driDestroyContext.  Instead of passing function pointers back and forth
just obtain the drm_context_t prior to calling DRIscreen::createNewContext
and pass it as a parameter.

This change also lets us keep the DRI context XID in the libGL loader only.

include/GL/internal/dri_interface.h
src/glx/x11/glxclient.h
src/glx/x11/glxcmds.c
src/glx/x11/glxext.c
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h

index 0f90f49507a968fe00b693d8f1b6f6a724885204..98271ad0aff9d8f318d154fdbc7acb1a2ca933d7 100644 (file)
@@ -183,17 +183,6 @@ struct __DRIinterfaceMethodsRec {
      */
     /*@{*/
 
-    /**
-     * Create the server-side portion of the GL context.
-     */
-    GLboolean (* createContext)( __DRIscreen *screen,
-        int configID, void * contextID, drm_context_t * hw_context );
-
-    /**
-     * Destroy the server-side portion of the GL context.
-     */
-    GLboolean (* destroyContext)( __DRIscreen *screen, __DRIid context );
-
     /**
      * This function is used to get information about the position, size, and
      * clip rects of a drawable.
@@ -345,7 +334,8 @@ struct __DRIscreenRec {
     void * (*createNewContext)(__DRIscreen *screen,
                               const __GLcontextModes *modes,
                               int render_type,
-                              void *sharedPrivate, __DRIcontext *pctx);
+                              void *sharedPrivate,
+                              drm_context_t hwContext, __DRIcontext *pctx);
 
     /**
      * Method to override base texture image with a driver specific 'offset'.
index 7ed45496581fd598b60a13d53cac5be38279bac6..56973251758579fda6091c2a8fe047dca5c7d83b 100644 (file)
@@ -361,6 +361,11 @@ struct __GLXcontextRec {
      * Pointer to the mode used to create this context.
      */
     const __GLcontextModes * mode;
+
+    /**
+     * XID for the server side drm_context_t
+     */
+    XID hwContextID;
 #endif
     
     /**
index 229da5a584ed6e414d9c869a76c50a2af473a4af..b6c0c763e3bff61c97678f828786c8c4786e718c 100644 (file)
@@ -382,6 +382,7 @@ CreateContext(Display *dpy, XVisualInfo *vis,
            int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
            __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
            const __GLcontextModes * mode;
+           drm_context_t hwContext;
 
            /* The value of fbconfig cannot change because it is tested
             * later in the function.
@@ -402,10 +403,19 @@ CreateContext(Display *dpy, XVisualInfo *vis,
            if (psc && psc->driScreen.private) {
                void * const shared = (shareList != NULL)
                    ? shareList->driContext.private : NULL;
+
+
+               if (!XF86DRICreateContextWithConfig(dpy, psc->scr,
+                                                   mode->fbconfigID,
+                                                   &gc->hwContextID, &hwContext))
+                   /* gah, handle this better */
+                   return NULL;
+
                gc->driContext.private = 
                  (*psc->driScreen.createNewContext)( &psc->driScreen,
                                                      mode, renderType,
                                                      shared,
+                                                     hwContext,
                                                      &gc->driContext );
                if (gc->driContext.private) {
                    gc->isDirect = GL_TRUE;
@@ -415,6 +425,9 @@ CreateContext(Display *dpy, XVisualInfo *vis,
                    gc->fbconfigID = mode->fbconfigID;
                    gc->mode = mode;
                }
+               else {
+                   XF86DRIDestroyContext(dpy, psc->scr, gc->hwContextID);
+               }
            }
        }
 #endif
@@ -524,6 +537,7 @@ DestroyContext(Display *dpy, GLXContext gc)
     if (gc->isDirect) {
        if (gc->driContext.private) {
            (*gc->driContext.destroyContext)(gc->driContext.private);
+           XF86DRIDestroyContext(dpy, gc->psc->scr, gc->hwContextID);
            gc->driContext.private = NULL;
        }
        GarbageCollectDRIDrawables(dpy, gc->screen);
index dce01d5528df3254675384384862002e42ad4287..85c990d4fc1a612ef417cc15cb35681c8d24d9c9 100644 (file)
@@ -773,28 +773,6 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
 #endif
 }
 
-static GLboolean
-__glXDRICreateContext(__DRIscreen *screen, int configID,
-                     void *pid, drm_context_t *hHWContext)
-{
-    __GLXscreenConfigs *psc =
-       containerOf(screen, __GLXscreenConfigs, driScreen);
-    Display *dpy = psc->dpy;
-
-    return XF86DRICreateContextWithConfig(dpy, psc->scr,
-                                         configID, pid, hHWContext);
-}
-
-static GLboolean
-__glXDRIDestroyContext(__DRIscreen  *screen, __DRIid context_id)
-{
-    __GLXscreenConfigs *psc =
-       containerOf(screen, __GLXscreenConfigs, driScreen);
-    Display *dpy = psc->dpy;
-
-    return XF86DRIDestroyContext(dpy, psc->scr, context_id);
-}
-
 static GLboolean
 __glXDRIGetDrawableInfo(__DRIdrawable *drawable,
                        unsigned int *index, unsigned int *stamp, 
@@ -824,9 +802,6 @@ static const __DRIinterfaceMethods interface_methods = {
 
     _gl_context_modes_create,
     _gl_context_modes_destroy,
-      
-    __glXDRICreateContext,
-    __glXDRIDestroyContext,
 
     __glXDRIGetDrawableInfo,
 
@@ -1816,6 +1791,9 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
                    if (oldGC->driContext.private) {
                        (*oldGC->driContext.destroyContext)
                            (oldGC->driContext.private);
+                       XF86DRIDestroyContext(oldGC->createDpy,
+                                             oldGC->psc->scr,
+                                             gc->hwContextID);
                        oldGC->driContext.private = NULL;
                    }
                }
index dd7068ad1035ae3c6b4431276905b15a4ac9ff3d..31438b827107ea9cc062c918e44e495e7f7a19da 100644 (file)
@@ -552,8 +552,6 @@ driDestroyContext(void *contextPrivate)
 
     if (pcp) {
        (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
-       (void) (*dri_interface->destroyContext)(pcp->driScreenPriv->psc,
-                                               pcp->contextID);
        _mesa_free(pcp);
     }
 }
@@ -582,7 +580,8 @@ driDestroyContext(void *contextPrivate)
  */
 static void *
 driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes,
-                   int render_type, void *sharedPrivate, __DRIcontext *pctx)
+                   int render_type, void *sharedPrivate, 
+                   drm_context_t hwContext, __DRIcontext *pctx)
 {
     __DRIcontextPrivate *pcp;
     __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate;
@@ -596,12 +595,7 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes,
        return NULL;
     }
 
-    if (! (*dri_interface->createContext)(screen, modes->fbconfigID,
-                                         &pcp->contextID, &pcp->hHWContext)) {
-       _mesa_free(pcp);
-       return NULL;
-    }
-
+    pcp->hHWContext = hwContext;
     pcp->driScreenPriv = psp;
     pcp->driDrawablePriv = NULL;
 
@@ -610,7 +604,6 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes,
      */
 
     if (!psp->dummyContextPriv.driScreenPriv) {
-        psp->dummyContextPriv.contextID = 0;
         psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context;
         psp->dummyContextPriv.driScreenPriv = psp;
         psp->dummyContextPriv.driDrawablePriv = NULL;
@@ -623,7 +616,6 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes,
     pctx->unbindContext  = driUnbindContext;
 
     if ( !(*psp->DriverAPI.CreateContext)(modes, pcp, shareCtx) ) {
-        (void) (*dri_interface->destroyContext)(screen, pcp->contextID);
         _mesa_free(pcp);
         return NULL;
     }
index cb9bb260512d9186eeb229fab1b6c7db75e2390c..612e24acb2d7540bad0087ae30b3651c02928d44 100644 (file)
@@ -326,11 +326,6 @@ struct __DRIdrawablePrivateRec {
  * Per-context private driver information.
  */
 struct __DRIcontextPrivateRec {
-    /**
-     * Kernel context handle used to access the device lock.
-     */
-    __DRIid contextID;
-
     /**
      * Kernel context handle used to access the device lock.
      */