#endif
typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
+typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
+
struct __GLXDRIdisplayPrivateRec {
__GLXDRIdisplay base;
int driPatch;
};
+struct __GLXDRIcontextPrivateRec {
+ __GLXDRIcontext base;
+ __DRIcontext driContext;
+ XID hwContextID;
+};
+
#ifndef DEFAULT_DRIVER_DIR
/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
/* Attempt to make sure libGL symbols will be visible to the driver */
glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
- libPaths = DEFAULT_DRIVER_DIR;
+ libPaths = NULL;
if (geteuid() == getuid()) {
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
libPaths = getenv("LIBGL_DRIVERS_PATH");
if (!libPaths)
libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */
}
+ if (libPaths == NULL)
+ libPaths = DEFAULT_DRIVER_DIR;
handle = NULL;
for (p = libPaths; *p; p = next) {
return psp;
}
+static void driDestroyContext(__GLXDRIcontext *context,
+ __GLXscreenConfigs *psc, Display *dpy)
+{
+ __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+
+ (*pcp->driContext.destroyContext)(&pcp->driContext);
+
+ XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+}
-static void driCreateContext(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
- GLXContext gc,
- GLXContext shareList, int renderType)
+static Bool driBindContext(__GLXDRIcontext *context,
+ __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
{
+ __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+
+ return (*pcp->driContext.bindContext)(&pcp->driContext,
+ &draw->driDrawable,
+ &read->driDrawable);
+}
+
+static void driUnbindContext(__GLXDRIcontext *context)
+{
+ __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+
+ (*pcp->driContext.unbindContext)(&pcp->driContext);
+}
+
+static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
+ const __GLcontextModes *mode,
+ GLXContext gc,
+ GLXContext shareList, int renderType)
+{
+ __GLXDRIcontextPrivate *pcp, *pcp_shared;
drm_context_t hwContext;
- __DRIcontext *shared;
+ __DRIcontext *shared = NULL;
if (psc && psc->driScreen) {
- shared = (shareList != NULL) ? &shareList->driContext : NULL;
+ if (shareList) {
+ pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+ shared = &pcp_shared->driContext;
+ }
+
+ pcp = Xmalloc(sizeof *pcp);
+ if (pcp == NULL)
+ return 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;
+ &pcp->hwContextID, &hwContext)) {
+ Xfree(pcp);
+ return NULL;
}
- else {
- XF86DRIDestroyContext(psc->dpy, psc->scr, gc->hwContextID);
+
+ pcp->driContext.private =
+ (*psc->__driScreen.createNewContext)(&psc->__driScreen,
+ mode, renderType,
+ shared,
+ hwContext,
+ &pcp->driContext);
+ if (pcp->driContext.private == NULL) {
+ XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+ Xfree(pcp);
+ return NULL;
}
+
+ pcp->base.destroyContext = driDestroyContext;
+ pcp->base.bindContext = driBindContext;
+ pcp->base.unbindContext = driUnbindContext;
+
+ return &pcp->base;
}
+
+ return NULL;
}
&pdraw->driDrawable,
hwDrawable,
GLX_WINDOW_BIT,
+ 0,
empty_attribute_list);
if (!pdraw->driDrawable.private) {
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
-__GLXDRIdisplay *driCreateDisplay(Display *dpy)
+_X_HIDDEN __GLXDRIdisplay *driCreateDisplay(Display *dpy)
{
__GLXDRIdisplayPrivate *pdpyp;
int eventBase, errorBase;
pdpyp->base.destroyDisplay = driDestroyDisplay;
pdpyp->base.createScreen = driCreateScreen;
- return (void *)pdpyp;
+ return &pdpyp->base;
}
#endif /* GLX_DIRECT_RENDERING */