Also drop isDirect flag; if gc->driContext is non-NULL, it's direct.
#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"
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;
}
pdpyp->base.destroyDisplay = driDestroyDisplay;
pdpyp->base.createScreen = driCreateScreen;
- return (void *)pdpyp;
+ return &pdpyp->base;
}
#endif /* GLX_DIRECT_RENDERING */
typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
typedef struct __GLXDRIscreenRec __GLXDRIscreen;
typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
+typedef struct __GLXDRIcontextRec __GLXDRIcontext;
struct __GLXDRIdisplayRec {
/**
void (*destroyScreen)(__GLXscreenConfigs *psc);
- void (*createContext)(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
- GLXContext gc, GLXContext shareList, int renderType);
-
+ __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
+ const __GLcontextModes *mode,
+ GLXContext gc,
+ GLXContext shareList, int renderType);
+
__GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
GLXDrawable drawable,
GLXContext gc);
};
+struct __GLXDRIcontextRec {
+ void (*destroyContext)(__GLXDRIcontext *context, __GLXscreenConfigs *psc,
+ Display *dpy);
+ Bool (*bindContext)(__GLXDRIcontext *context,
+ __GLXDRIdrawable *pdraw,
+ __GLXDRIdrawable *pread);
+
+ void (*unbindContext)(__GLXDRIcontext *context);
+};
+
struct __GLXDRIdrawableRec {
XID drawable;
__GLXscreenConfigs *psc;
*/
GLenum error;
- /**
- * Whether this context does direct rendering.
- */
- Bool isDirect;
-
/**
* \c dpy of current display for this context. Will be \c NULL if not
* current to any display, or if this is the "dummy context".
const __GLcontextModes * mode;
#ifdef GLX_DIRECT_RENDERING
- /**
- * Per context direct rendering interface functions and data.
- */
- __DRIcontext driContext;
-
- /**
- * XID for the server side drm_context_t
- */
- XID hwContextID;
+ __GLXDRIcontext *driContext;
#endif
/**
*/
gc->fastImageUnpack = GL_FALSE;
gc->fillImage = __glFillImage;
- gc->isDirect = GL_FALSE;
gc->pc = gc->buf;
gc->bufEnd = gc->buf + bufSize;
if (__glXDebug) {
mode = fbconfig;
}
- psc->driScreen->createContext(psc, mode, gc, shareList, renderType);
+ gc->driContext = psc->driScreen->createContext(psc, mode, gc,
+ shareList,
+ renderType);
+ if (gc->driContext != NULL) {
+ gc->screen = mode->screen;
+ gc->psc = psc;
+ gc->mode = mode;
+ }
}
#endif
req->visual = vis->visualid;
req->screen = vis->screen;
req->shareList = shareList ? shareList->xid : None;
- req->isDirect = gc->isDirect;
+ req->isDirect = gc->driContext != NULL;
}
else if ( use_glx_1_3 ) {
xGLXCreateNewContextReq *req;
req->screen = fbconfig->screen;
req->renderType = renderType;
req->shareList = shareList ? shareList->xid : None;
- req->isDirect = gc->isDirect;
+ req->isDirect = gc->driContext != NULL;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
req->screen = fbconfig->screen;
req->renderType = renderType;
req->shareList = shareList ? shareList->xid : None;
- req->isDirect = gc->isDirect;
+ req->isDirect = gc->driContext != NULL;
}
UnlockDisplay(dpy);
#ifdef GLX_DIRECT_RENDERING
/* Destroy the direct rendering context */
- if (gc->isDirect) {
- if (gc->driContext.private) {
- (*gc->driContext.destroyContext)(&gc->driContext);
- XF86DRIDestroyContext(dpy, gc->psc->scr, gc->hwContextID);
- gc->driContext.private = NULL;
- }
+ if (gc->driContext) {
+ (*gc->driContext->destroyContext)(gc->driContext, gc->psc, dpy);
+ gc->driContext = NULL;
GarbageCollectDRIDrawables(dpy, gc->psc);
}
#endif
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_DIRECT_RENDERING
- if (gc->isDirect) {
+ if (gc->driContext) {
/* This bit of ugliness unwraps the glFinish function */
#ifdef glFinish
#undef glFinish
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_DIRECT_RENDERING
- if (gc->isDirect) {
+ if (gc->driContext) {
XSync(dpy, False);
return;
}
(void) __glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_DIRECT_RENDERING
- if (gc->isDirect) {
+ if (gc->driContext) {
DRI_glXUseXFont(font, first, count, listBase);
return;
}
}
#ifdef GLX_DIRECT_RENDERING
- if (gc->isDirect) {
+ if (gc->driContext) {
/* NOT_DONE: This does not work yet */
}
#endif
if (!gc) {
return GL_FALSE;
#ifdef GLX_DIRECT_RENDERING
- } else if (gc->isDirect) {
+ } else if (gc->driContext) {
return GL_TRUE;
#endif
}
int retVal;
/* get the information from the server if we don't have it already */
- if (!ctx->isDirect && (ctx->mode == NULL)) {
+ if (!ctx->driContext && (ctx->mode == NULL)) {
retVal = __glXQueryContextInfo(dpy, ctx);
if (Success != retVal) return retVal;
}
}
#ifdef __DRI_SWAP_CONTROL
- if ( gc->isDirect ) {
+ if (gc->driContext) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
__DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy,
return GLX_BAD_VALUE;
}
- if ( (gc != NULL) && gc->isDirect ) {
+ if (gc != NULL && gc->driContext) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
#ifdef __DRI_SWAP_CONTROL
GLXContext gc = __glXGetCurrentContext();
- if ( (gc != NULL) && gc->isDirect ) {
+ if (gc != NULL && gc->driContext) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
GLXContext gc = __glXGetCurrentContext();
- if ( (gc != NULL) && gc->isDirect ) {
+ if (gc != NULL && gc->driContext) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
if ( psc->msc && psc->driScreen ) {
if ( divisor <= 0 || remainder < 0 )
return GLX_BAD_VALUE;
- if ( (gc != NULL) && gc->isDirect ) {
+ if (gc != NULL && gc->driContext) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
if (psc->msc != NULL && psc->driScreen ) {
}
#ifdef GLX_DIRECT_RENDERING
- if (gc->isDirect)
+ if (gc->driContext)
return;
#endif
return;
#ifdef GLX_DIRECT_RENDERING
- if (gc->isDirect)
+ if (gc->driContext)
return;
#endif
#ifdef GLX_DIRECT_RENDERING
-static __DRIdrawable *
+static __GLXDRIdrawable *
FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
{
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
psc = &priv->screenConfigs[gc->screen];
if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0)
- return &pdraw->driDrawable;
+ return pdraw;
- pdraw = psc->driScreen->createDrawable(psc, drawable, gc);
-
- return &pdraw->driDrawable;
-}
-
-static Bool BindContextWrapper( Display *dpy, GLXContext gc,
- GLXDrawable draw, GLXDrawable read )
-{
- __DRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
- __DRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
-
- return (*gc->driContext.bindContext)(&gc->driContext, pdraw, pread);
-}
-
-
-static Bool UnbindContextWrapper( GLXContext gc )
-{
- return (*gc->driContext.unbindContext)(&gc->driContext);
+ return psc->driScreen->createDrawable(psc, drawable, gc);
}
#endif /* GLX_DIRECT_RENDERING */
return GL_FALSE;
}
-#ifndef GLX_DIRECT_RENDERING
- if (gc && gc->isDirect) {
- return GL_FALSE;
- }
-#endif
-
_glapi_check_multithread();
#ifdef GLX_DIRECT_RENDERING
/* Bind the direct rendering context to the drawable */
- if (gc && gc->isDirect) {
- bindReturnValue = (gc->driContext.private)
- ? BindContextWrapper(dpy, gc, draw, read)
- : False;
+ if (gc && gc->driContext) {
+ __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
+ __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
+
+ bindReturnValue =
+ (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
} else
#endif
{
/* Send a glXMakeCurrent request to bind the new context. */
bindReturnValue =
SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
- ((dpy != oldGC->currentDpy) || oldGC->isDirect)
+ ((dpy != oldGC->currentDpy) || oldGC->driContext)
? None : oldGC->currentContextTag,
draw, read, &reply);
}
return False;
}
- if ((dpy != oldGC->currentDpy || (gc && gc->isDirect)) &&
- !oldGC->isDirect && oldGC != &dummyContext) {
+ if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
+ !oldGC->driContext && oldGC != &dummyContext) {
xGLXMakeCurrentReply dummy_reply;
/* We are either switching from one dpy to another and have to
& dummy_reply);
}
#ifdef GLX_DIRECT_RENDERING
- else if (oldGC->isDirect && oldGC->driContext.private) {
- (void) UnbindContextWrapper(oldGC);
+ else if (oldGC->driContext) {
+ oldGC->driContext->unbindContext(oldGC->driContext);
}
#endif
*/
#ifdef GLX_DIRECT_RENDERING
/* Destroy the old direct rendering context */
- if (oldGC->isDirect) {
- if (oldGC->driContext.private) {
- (*oldGC->driContext.destroyContext)
- (&oldGC->driContext);
- XF86DRIDestroyContext(oldGC->createDpy,
- oldGC->psc->scr,
- gc->hwContextID);
- oldGC->driContext.private = NULL;
- }
+ if (oldGC->driContext) {
+ oldGC->driContext->destroyContext(oldGC->driContext,
+ oldGC->psc,
+ oldGC->createDpy);
+ oldGC->driContext = NULL;
}
#endif
__glXFreeContext(oldGC);
gc->currentDrawable = draw;
gc->currentReadable = read;
- if (!gc->isDirect) {
+ if (!gc->driContext) {
if (!IndirectAPI)
IndirectAPI = __glXNewIndirectAPI();
_glapi_set_dispatch(IndirectAPI);
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
return CALL_AreTexturesResident(GET_DISPATCH(),
(n, textures, residences));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_DeleteTextures(GET_DISPATCH(), (n, textures));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GenTextures(GET_DISPATCH(), (n, textures));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
return CALL_IsTexture(GET_DISPATCH(), (texture));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetColorTableParameterfv(GET_DISPATCH(),
(target, pname, params));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetColorTableParameteriv(GET_DISPATCH(),
(target, pname, params));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetConvolutionFilter(GET_DISPATCH(),
(target, format, type, image));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetConvolutionParameterfv(GET_DISPATCH(),
(target, pname, params));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetConvolutionParameteriv(GET_DISPATCH(),
(target, pname, params));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetHistogram(GET_DISPATCH(),
(target, reset, format, type, values));
} else {
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext *const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params));
} else {
__GLXcontext *const gc = __glXGetCurrentContext();
{
__GLXcontext * const gc = __glXGetCurrentContext();
- if (gc->isDirect) {
+ if (gc->driContext) {
CALL_GetSeparableFilter(GET_DISPATCH(),
(target, format, type, row, column, span));
return;
print '{'
print ' __GLXcontext * const gc = __glXGetCurrentContext();'
print ''
- print ' if (gc->isDirect) {'
+ print ' if (gc->driContext) {'
print ' %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())
print ' } else {'
footer = '}\n}\n'