Drop createContext and destroyContext from DRIinterfaceMethods.
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.
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index 229da5a..b6c0c76 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -382,6 +382,7 @@
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 @@
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 @@
gc->fbconfigID = mode->fbconfigID;
gc->mode = mode;
}
+ else {
+ XF86DRIDestroyContext(dpy, psc->scr, gc->hwContextID);
+ }
}
}
#endif
@@ -524,6 +537,7 @@
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);