summaryrefslogtreecommitdiffstats
path: root/src/glx/x11/glxext.c
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2008-03-26 19:26:59 -0400
committerKristian Høgsberg <[email protected]>2008-03-31 16:51:26 -0400
commite82dd8c6e1fa2fff5b960de26961080ba5e9651d (patch)
tree1bd230661a032b1ab539998f947573de1acaf80d /src/glx/x11/glxext.c
parent63d8a8417d68365cd10c11178516378411c09f87 (diff)
DRI interface changes and DRI2 direct rendering support.
Add DRI2 direct rendering support to libGL and add DRI2 client side protocol code. Extend the GLX 1.3 create drawable functions in glx_pbuffer.c to call into the DRI driver when possible. Introduce __DRIconfig, opaque struct that represents a DRI driver configuration. Get's rid of the open coded __GLcontextModes in the DRI driver interface and the context modes create and destroy functions that the loader was requires to provide. glcore.h is no longer part of the DRI driver interface. The DRI config is GL binding agnostic, that is, not specific to GLX, EGL or other bindings. The core API is now also an extension, and the driver exports a list of extensions as the symbol __driDriverExtensions, which the loader must dlsym() for. The list of extension will always include the DRI core extension, which allows creating and manipulating DRI screens, drawables and contexts. The DRI legacy extension, when available, provides alternative entry points for creating the DRI objects that work with the XF86DRI infrastructure. Change DRI2 client code to not use drm drawables or contexts. We never used drm_drawable_t's and the only use for drm_context_t was as a unique identifier when taking the lock. We now just allocate a unique lock ID out of the DRILock sarea block. Once we get rid of the lock entirely, we can drop this hack. Change the interface between dri_util.c and the drivers, so that the drivers now export the DriverAPI struct as driDriverAPI instead of the InitScreen entry point. This lets us avoid dlsym()'ing for the DRI2 init screen function to see if DRI2 is supported by the driver.
Diffstat (limited to 'src/glx/x11/glxext.c')
-rw-r--r--src/glx/x11/glxext.c66
1 files changed, 42 insertions, 24 deletions
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index 525faab10e9..cd5c3196e36 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -107,9 +107,6 @@ static int _mesa_sparc_needs_init = 1;
#define INIT_MESA_SPARC
#endif
-static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext gc);
-
/*
** We setup some dummy structures here so that the API can be used
** even if no context is current.
@@ -348,10 +345,10 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
Xfree((char*) psc->serverGLXexts);
#ifdef GLX_DIRECT_RENDERING
- if (psc->driScreen)
+ if (psc->driScreen) {
psc->driScreen->destroyScreen(psc);
- if (psc->drawHash)
__glxHashDestroy(psc->drawHash);
+ }
#endif
}
XFree((char*) priv->screenConfigs);
@@ -381,6 +378,9 @@ static int __glXFreeDisplayPrivate(XExtData *extension)
if (priv->driDisplay)
(*priv->driDisplay->destroyDisplay)(priv->driDisplay);
priv->driDisplay = NULL;
+ if (priv->dri2Display)
+ (*priv->dri2Display->destroyDisplay)(priv->dri2Display);
+ priv->dri2Display = NULL;
#endif
Xfree((char*) priv);
@@ -774,14 +774,16 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
psc->scr = i;
psc->dpy = dpy;
#ifdef GLX_DIRECT_RENDERING
- if (priv->driDisplay) {
- /* Create drawable hash */
- psc->drawHash = __glxHashCreate();
- if (psc->drawHash == NULL)
- continue;
+ psc->drawHash = __glxHashCreate();
+ if (psc->drawHash == NULL)
+ continue;
+ if (priv->dri2Display)
+ psc->driScreen = (*priv->dri2Display->createScreen)(psc, i, priv);
+ if (psc->driScreen == NULL && priv->driDisplay)
psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv);
- if (psc->driScreen == NULL)
- __glxHashDestroy(psc->drawHash);
+ if (psc->driScreen == NULL) {
+ __glxHashDestroy(psc->drawHash);
+ psc->drawHash = NULL;
}
#endif
}
@@ -872,7 +874,8 @@ _X_HIDDEN __GLXdisplayPrivate *__glXInitialize(Display* dpy)
** (e.g., those called in AllocAndFetchScreenConfigs).
*/
if (getenv("LIBGL_ALWAYS_INDIRECT") == NULL) {
- dpyPriv->driDisplay = driCreateDisplay(dpy);
+ dpyPriv->dri2Display = dri2CreateDisplay(dpy);
+ dpyPriv->driDisplay = driCreateDisplay(dpy);
}
#endif
@@ -1188,21 +1191,35 @@ static Bool SendMakeCurrentRequest(Display *dpy, CARD8 opcode,
#ifdef GLX_DIRECT_RENDERING
static __GLXDRIdrawable *
-FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
+FetchDRIDrawable(Display *dpy,
+ GLXDrawable glxDrawable, GLXContext gc, Bool pre13)
{
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
__GLXscreenConfigs *psc;
+ XID drawable;
- if (priv == NULL || priv->driDisplay == NULL)
+ if (priv == NULL)
return NULL;
psc = &priv->screenConfigs[gc->screen];
- if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0)
+ if (psc->drawHash == NULL)
+ return NULL;
+
+ if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
return pdraw;
- pdraw = psc->driScreen->createDrawable(psc, drawable, gc);
- if (__glxHashInsert(psc->drawHash, drawable, pdraw)) {
+ /* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the
+ * GLX drawable on the fly. Otherwise we pass None as the X
+ * drawable */
+ if (pre13)
+ drawable = glxDrawable;
+ else
+ drawable = None;
+
+ pdraw = psc->driScreen->createDrawable(psc, drawable,
+ glxDrawable, gc->mode);
+ if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable)(pdraw);
return NULL;
}
@@ -1218,7 +1235,8 @@ FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
* \note This is in this file so that it can access dummyContext.
*/
static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext gc)
+ GLXDrawable read, GLXContext gc,
+ Bool pre13)
{
xGLXMakeCurrentReply reply;
const GLXContext oldGC = __glXGetCurrentContext();
@@ -1245,8 +1263,8 @@ static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
#ifdef GLX_DIRECT_RENDERING
/* Bind the direct rendering context to the drawable */
if (gc && gc->driContext) {
- __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
- __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
+ __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13);
+ __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13);
bindReturnValue =
(gc->driContext->bindContext) (gc->driContext, pdraw, pread);
@@ -1368,16 +1386,16 @@ static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
{
- return MakeContextCurrent( dpy, draw, draw, gc );
+ return MakeContextCurrent(dpy, draw, draw, gc, True);
}
PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
(Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
- (dpy, d, r, ctx), MakeContextCurrent)
+ (dpy, d, r, ctx, False), MakeContextCurrent)
PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
(Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
- (dpy, d, r, ctx), MakeContextCurrent)
+ (dpy, d, r, ctx, False), MakeContextCurrent)
#ifdef DEBUG