Move DRI specific parts of CreateContext into dri_glx.c.
authorKristian Høgsberg <krh@redhat.com>
Sun, 9 Mar 2008 01:02:22 +0000 (20:02 -0500)
committerKristian Høgsberg <krh@redhat.com>
Sun, 9 Mar 2008 01:02:22 +0000 (20:02 -0500)
src/glx/x11/dri_glx.c
src/glx/x11/glxclient.h
src/glx/x11/glxcmds.c

index 194517a65773d1270169b959415de3db5c901f7a..2b43a74e66a1eaf4ec705913f083813b229f268f 100644 (file)
@@ -657,6 +657,42 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
     return psp;
 }
 
+
+static void driCreateContext(__GLXscreenConfigs *psc,
+                            const __GLcontextModes *mode,
+                            GLXContext gc,
+                            GLXContext shareList, int renderType)
+{
+    drm_context_t hwContext;
+    __DRIcontext *shared;
+
+    if (psc && psc->driScreen.private) {
+       shared = (shareList != NULL) ? &shareList->driContext : NULL;
+
+       if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr,
+                                           mode->visualID,
+                                           &gc->hwContextID, &hwContext))
+           /* gah, handle this better */
+           return;
+
+       gc->driContext.private = 
+           (*psc->driScreen.createNewContext)( &psc->driScreen,
+                                               mode, renderType,
+                                               shared,
+                                               hwContext,
+                                               &gc->driContext );
+       if (gc->driContext.private) {
+           gc->isDirect = GL_TRUE;
+           gc->screen = mode->screen;
+           gc->psc = psc;
+           gc->mode = mode;
+       }
+       else {
+           XF86DRIDestroyContext(psc->dpy, psc->scr, gc->hwContextID);
+       }
+    }
+}
+
 static void driDestroyScreen(__GLXscreenConfigs *psc)
 {
     /* Free the direct rendering per screen data */
@@ -698,6 +734,7 @@ static void driCreateScreen(__GLXscreenConfigs *psc, int screen,
        __glXScrEnableDRIExtension(psc);
 
     psc->driDestroyScreen = driDestroyScreen;
+    psc->driCreateContext = driCreateContext;
 }
 
 /* Called from __glXFreeDisplayPrivate.
index 99dbb597a685df4e33d3efaee3fb268a87cde5a4..6ac92cf850afbb45e987bf90d5e4262e62874602 100644 (file)
@@ -438,6 +438,11 @@ struct __GLXscreenConfigsRec {
 
     void (*driDestroyScreen)(__GLXscreenConfigs *psc);
 
+    void (*driCreateContext)(__GLXscreenConfigs *psc,
+                            const __GLcontextModes *mode,
+                            GLXContext gc,
+                            GLXContext shareList, int renderType);
+
 #ifdef __DRI_COPY_SUB_BUFFER
     __DRIcopySubBufferExtension *copySubBuffer;
 #endif
index d194301dd7a72f6a43aeac1c0b6709a755bef8d6..e8cb7b96f57dd4eef2a1438caa312bfda9a4fd44 100644 (file)
@@ -378,8 +378,6 @@ 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;
-
 
            if (fbconfig == NULL) {
                mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
@@ -400,33 +398,7 @@ CreateContext(Display *dpy, XVisualInfo *vis,
                mode = fbconfig;
            }
 
-           if (psc && psc->driScreen.private) {
-               __DRIcontext *shared = (shareList != NULL)
-                   ? &shareList->driContext : NULL;
-
-
-               if (!XF86DRICreateContextWithConfig(dpy, psc->scr,
-                                                   mode->visualID,
-                                                   &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;
-                   gc->screen = mode->screen;
-                   gc->psc = psc;
-                   gc->mode = mode;
-               }
-               else {
-                   XF86DRIDestroyContext(dpy, psc->scr, gc->hwContextID);
-               }
-           }
+           psc->driCreateContext(psc, mode, gc, shareList, renderType);
        }
 #endif