glx: Move bind and unbind to context vtable

This commit is contained in:
Kristian Høgsberg
2010-07-28 15:33:09 -04:00
parent c356f5867f
commit c491e585e4
12 changed files with 206 additions and 276 deletions

View File

@@ -95,7 +95,6 @@ struct dri2_screen {
struct dri2_context struct dri2_context
{ {
struct glx_context base; struct glx_context base;
__GLXDRIcontext dri_vtable;
__DRIcontext *driContext; __DRIcontext *driContext;
}; };
@@ -133,20 +132,28 @@ dri2_destroy_context(struct glx_context *context)
} }
static Bool static Bool
dri2BindContext(struct glx_context *context, dri2_bind_context(struct glx_context *context, struct glx_context *old,
__GLXDRIdrawable *draw, __GLXDRIdrawable *read) GLXDrawable draw, GLXDrawable read)
{ {
struct dri2_context *pcp = (struct dri2_context *) context; struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
struct dri2_drawable *pdr = (struct dri2_drawable *) draw; struct dri2_drawable *pdraw, *pread;
struct dri2_drawable *prd = (struct dri2_drawable *) read;
return (*psc->core->bindContext) (pcp->driContext, pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
pdr->driDrawable, prd->driDrawable); pread = (struct dri2_drawable *) driFetchDrawable(context, read);
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
if ((*psc->core->bindContext) (pcp->driContext,
pdraw->driDrawable, pread->driDrawable))
return Success;
return GLXBadContext;
} }
static void static void
dri2UnbindContext(struct glx_context *context) dri2_unbind_context(struct glx_context *context, struct glx_context *new)
{ {
struct dri2_context *pcp = (struct dri2_context *) context; struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
@@ -189,9 +196,6 @@ dri2_create_context(struct glx_screen *base,
} }
pcp->base.vtable = &dri2_context_vtable; pcp->base.vtable = &dri2_context_vtable;
pcp->base.driContext = &pcp->dri_vtable;
pcp->dri_vtable.bindContext = dri2BindContext;
pcp->dri_vtable.unbindContext = dri2UnbindContext;
return &pcp->base; return &pcp->base;
} }
@@ -684,6 +688,8 @@ dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
static const struct glx_context_vtable dri2_context_vtable = { static const struct glx_context_vtable dri2_context_vtable = {
dri2_destroy_context, dri2_destroy_context,
dri2_bind_context,
dri2_unbind_context,
dri2_wait_gl, dri2_wait_gl,
dri2_wait_x, dri2_wait_x,
DRI_glXUseXFont, DRI_glXUseXFont,

View File

@@ -353,4 +353,31 @@ driDestroyConfigs(const __DRIconfig **configs)
free(configs); free(configs);
} }
_X_HIDDEN __GLXDRIdrawable *
driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
{
struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
if (priv == NULL)
return NULL;
psc = priv->screens[gc->screen];
if (priv->drawHash == NULL)
return NULL;
if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
return pdraw;
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
glxDrawable, gc->config);
if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return NULL;
}
return pdraw;
}
#endif /* GLX_DIRECT_RENDERING */ #endif /* GLX_DIRECT_RENDERING */

View File

@@ -52,6 +52,9 @@ extern struct glx_config *driConvertConfigs(const __DRIcoreExtension * core,
extern void driDestroyConfigs(const __DRIconfig **configs); extern void driDestroyConfigs(const __DRIconfig **configs);
extern __GLXDRIdrawable *
driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable);
extern const __DRIsystemTimeExtension systemTimeExtension; extern const __DRIsystemTimeExtension systemTimeExtension;
extern void InfoMessageF(const char *f, ...); extern void InfoMessageF(const char *f, ...);

View File

@@ -79,7 +79,6 @@ struct dri_screen
struct dri_context struct dri_context
{ {
struct glx_context base; struct glx_context base;
__GLXDRIcontext dri_vtable;
__DRIcontext *driContext; __DRIcontext *driContext;
XID hwContextID; XID hwContextID;
}; };
@@ -518,21 +517,29 @@ dri_destroy_context(struct glx_context * context)
Xfree(pcp); Xfree(pcp);
} }
static Bool static int
driBindContext(struct glx_context *context, dri_bind_context(struct glx_context *context, struct glx_context *old,
__GLXDRIdrawable *draw, __GLXDRIdrawable *read) GLXDrawable draw, GLXDrawable read)
{ {
struct dri_context *pcp = (struct dri_context *) context; struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) pcp->base.psc; struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
struct dri_drawable *pdr = (struct dri_drawable *) draw; struct dri_drawable *pdraw, *pread;
struct dri_drawable *prd = (struct dri_drawable *) read;
return (*psc->core->bindContext) (pcp->driContext, pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
pdr->driDrawable, prd->driDrawable); pread = (struct dri_drawable *) driFetchDrawable(context, read);
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
if ((*psc->core->bindContext) (pcp->driContext,
pdraw->driDrawable, pread->driDrawable))
return Success;
return GLXBadContext;
} }
static void static void
driUnbindContext(struct glx_context * context) dri_unbind_context(struct glx_context *context, struct glx_context *new)
{ {
struct dri_context *pcp = (struct dri_context *) context; struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) pcp->base.psc; struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
@@ -542,6 +549,8 @@ driUnbindContext(struct glx_context * context)
static const struct glx_context_vtable dri_context_vtable = { static const struct glx_context_vtable dri_context_vtable = {
dri_destroy_context, dri_destroy_context,
dri_bind_context,
dri_unbind_context,
NULL, NULL,
NULL, NULL,
DRI_glXUseXFont, DRI_glXUseXFont,
@@ -564,7 +573,7 @@ dri_create_context(struct glx_screen *base,
return NULL; return NULL;
if (shareList) { if (shareList) {
pcp_shared = (struct dri_context *) shareList->driContext; pcp_shared = (struct dri_context *) shareList;
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
@@ -596,9 +605,6 @@ dri_create_context(struct glx_screen *base,
} }
pcp->base.vtable = &dri_context_vtable; pcp->base.vtable = &dri_context_vtable;
pcp->base.driContext = &pcp->dri_vtable;
pcp->dri_vtable.bindContext = driBindContext;
pcp->dri_vtable.unbindContext = driUnbindContext;
return &pcp->base; return &pcp->base;
} }
@@ -756,17 +762,12 @@ driWaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
static int static int
driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval) driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{ {
struct glx_context *gc = __glXGetCurrentContext();
struct dri_drawable *pdp = (struct dri_drawable *) pdraw; struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc; struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
if (gc->driContext) { if (psc->swapControl != NULL && pdraw != NULL) {
psc = (struct dri_screen *) pdraw->psc; psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
return 0;
if (psc->swapControl != NULL && pdraw != NULL) {
psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
return 0;
}
} }
return GLX_BAD_CONTEXT; return GLX_BAD_CONTEXT;
@@ -775,17 +776,11 @@ driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
static int static int
driGetSwapInterval(__GLXDRIdrawable *pdraw) driGetSwapInterval(__GLXDRIdrawable *pdraw)
{ {
struct glx_context *gc = __glXGetCurrentContext();
struct dri_drawable *pdp = (struct dri_drawable *) pdraw; struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc; struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
if (gc != NULL && gc->driContext) { if (psc->swapControl != NULL && pdraw != NULL)
psc = (struct dri_screen *) pdraw->psc; return psc->swapControl->getSwapInterval(pdp->driDrawable);
if (psc->swapControl != NULL && pdraw != NULL) {
return psc->swapControl->getSwapInterval(pdp->driDrawable);
}
}
return 0; return 0;
} }

View File

@@ -36,7 +36,6 @@ struct drisw_display
struct drisw_context struct drisw_context
{ {
struct glx_context base; struct glx_context base;
__GLXDRIcontext dri_vtable;
__DRIcontext *driContext; __DRIcontext *driContext;
}; };
@@ -258,21 +257,29 @@ drisw_destroy_context(struct glx_context *context)
Xfree(pcp); Xfree(pcp);
} }
static Bool static int
driBindContext(struct glx_context * context, drisw_bind_context(struct glx_context *context, struct glx_context *old,
__GLXDRIdrawable * draw, __GLXDRIdrawable * read) GLXDrawable draw, GLXDrawable read)
{ {
struct drisw_context *pcp = (struct drisw_context *) context; struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc; struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
struct drisw_drawable *pdr = (struct drisw_drawable *) draw; struct drisw_drawable *pdraw, *pread;
struct drisw_drawable *prd = (struct drisw_drawable *) read;
return (*psc->core->bindContext) (pcp->driContext, pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
pdr->driDrawable, prd->driDrawable); pread = (struct drisw_drawable *) driFetchDrawable(context, read);
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
if ((*psc->core->bindContext) (pcp->driContext,
pdraw->driDrawable, pread->driDrawable))
return Success;
return GLXBadContext;
} }
static void static void
driUnbindContext(struct glx_context * context) drisw_unbind_context(struct glx_context *context, struct glx_context *new)
{ {
struct drisw_context *pcp = (struct drisw_context *) context; struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc; struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
@@ -282,6 +289,8 @@ driUnbindContext(struct glx_context * context)
static const struct glx_context_vtable drisw_context_vtable = { static const struct glx_context_vtable drisw_context_vtable = {
drisw_destroy_context, drisw_destroy_context,
drisw_bind_context,
drisw_unbind_context,
NULL, NULL,
NULL, NULL,
DRI_glXUseXFont, DRI_glXUseXFont,
@@ -303,7 +312,7 @@ drisw_create_context(struct glx_screen *base,
return NULL; return NULL;
if (shareList) { if (shareList) {
pcp_shared = (struct drisw_context *) shareList->driContext; pcp_shared = (struct drisw_context *) shareList;
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
@@ -326,9 +335,6 @@ drisw_create_context(struct glx_screen *base,
} }
pcp->base.vtable = &drisw_context_vtable; pcp->base.vtable = &drisw_context_vtable;
pcp->base.driContext = &pcp->dri_vtable;
pcp->dri_vtable.bindContext = driBindContext;
pcp->dri_vtable.unbindContext = driUnbindContext;
return &pcp->base; return &pcp->base;
} }

View File

@@ -88,7 +88,6 @@ extern void DRI_glXUseXFont(struct glx_context *ctx,
typedef struct __GLXDRIdisplayRec __GLXDRIdisplay; typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
typedef struct __GLXDRIscreenRec __GLXDRIscreen; typedef struct __GLXDRIscreenRec __GLXDRIscreen;
typedef struct __GLXDRIdrawableRec __GLXDRIdrawable; typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
typedef struct __GLXDRIcontextRec __GLXDRIcontext;
#include "glxextensions.h" #include "glxextensions.h"
@@ -131,13 +130,6 @@ struct __GLXDRIscreenRec {
int (*getSwapInterval)(__GLXDRIdrawable *pdraw); int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
}; };
struct __GLXDRIcontextRec
{
Bool(*bindContext) (struct glx_context *context, __GLXDRIdrawable *pdraw,
__GLXDRIdrawable *pread);
void (*unbindContext) (struct glx_context *context);
};
struct __GLXDRIdrawableRec struct __GLXDRIdrawableRec
{ {
void (*destroyDrawable) (__GLXDRIdrawable * drawable); void (*destroyDrawable) (__GLXDRIdrawable * drawable);
@@ -221,6 +213,9 @@ typedef struct __GLXattributeMachineRec
struct glx_context_vtable { struct glx_context_vtable {
void (*destroy)(struct glx_context *ctx); void (*destroy)(struct glx_context *ctx);
int (*bind)(struct glx_context *context, struct glx_context *old,
GLXDrawable draw, GLXDrawable read);
void (*unbind)(struct glx_context *context, struct glx_context *new);
void (*wait_gl)(struct glx_context *ctx); void (*wait_gl)(struct glx_context *ctx);
void (*wait_x)(struct glx_context *ctx); void (*wait_x)(struct glx_context *ctx);
void (*use_x_font)(struct glx_context *ctx, void (*use_x_font)(struct glx_context *ctx,
@@ -388,15 +383,6 @@ struct glx_context
*/ */
struct glx_config *config; struct glx_config *config;
#ifdef GLX_DIRECT_RENDERING
#ifdef GLX_USE_APPLEGL
void *driContext;
Bool do_destroy;
#else
__GLXDRIcontext *driContext;
#endif
#endif
/** /**
* The current read-drawable for this context. Will be None if this * The current read-drawable for this context. Will be None if this
* context is not current to any drawable. * context is not current to any drawable.
@@ -790,5 +776,10 @@ GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable);
extern struct glx_screen * extern struct glx_screen *
indirect_create_screen(int screen, struct glx_display * priv); indirect_create_screen(int screen, struct glx_display * priv);
extern int
indirect_bind_context(struct glx_context *gc, struct glx_context *old,
GLXDrawable draw, GLXDrawable read);
extern void
indirect_unbind_context(struct glx_context *gc, struct glx_context *new);
#endif /* !__GLX_client_h__ */ #endif /* !__GLX_client_h__ */

View File

@@ -42,15 +42,12 @@
#include "apple_glx_context.h" #include "apple_glx_context.h"
#include "apple_glx.h" #include "apple_glx.h"
#include "glx_error.h" #include "glx_error.h"
#define GC_IS_DIRECT(gc) ((gc)->isDirect)
#else #else
#include <sys/time.h> #include <sys/time.h>
#include <X11/extensions/xf86vmode.h> #include <X11/extensions/xf86vmode.h>
#include "xf86dri.h" #include "xf86dri.h"
#define GC_IS_DIRECT(gc) ((gc)->driContext != NULL)
#endif #endif
#else #else
#define GC_IS_DIRECT(gc) (0)
#endif #endif
#if defined(USE_XCB) #if defined(USE_XCB)
@@ -424,6 +421,7 @@ glx_context_init(struct glx_context *gc,
gc->psc = psc; gc->psc = psc;
gc->config = config; gc->config = config;
gc->isDirect = GL_TRUE; gc->isDirect = GL_TRUE;
gc->currentContextTag = -1;
return GL_TRUE; return GL_TRUE;
} }
@@ -475,7 +473,7 @@ CreateContext(Display * dpy, int generic_id,
req->visual = generic_id; req->visual = generic_id;
req->screen = screen; req->screen = screen;
req->shareList = shareList ? shareList->xid : None; req->shareList = shareList ? shareList->xid : None;
req->isDirect = GC_IS_DIRECT(gc); req->isDirect = gc->isDirect;
break; break;
} }
@@ -491,7 +489,7 @@ CreateContext(Display * dpy, int generic_id,
req->screen = screen; req->screen = screen;
req->renderType = renderType; req->renderType = renderType;
req->shareList = shareList ? shareList->xid : None; req->shareList = shareList ? shareList->xid : None;
req->isDirect = GC_IS_DIRECT(gc); req->isDirect = gc->isDirect;
break; break;
} }
@@ -512,7 +510,7 @@ CreateContext(Display * dpy, int generic_id,
req->screen = screen; req->screen = screen;
req->renderType = renderType; req->renderType = renderType;
req->shareList = shareList ? shareList->xid : None; req->shareList = shareList ? shareList->xid : None;
req->isDirect = GC_IS_DIRECT(gc); req->isDirect = gc->isDirect;
break; break;
} }
@@ -836,7 +834,7 @@ glXCopyContext(Display * dpy, GLXContext source_user,
} }
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
/* NOT_DONE: This does not work yet */ /* NOT_DONE: This does not work yet */
} }
#endif #endif
@@ -929,7 +927,7 @@ glXIsDirect(Display * dpy, GLXContext gc_user)
if (!gc) { if (!gc) {
return GL_FALSE; return GL_FALSE;
} }
else if (GC_IS_DIRECT(gc)) { else if (gc->isDirect) {
return GL_TRUE; return GL_TRUE;
} }
#ifdef GLX_USE_APPLEGL /* TODO: indirect on darwin */ #ifdef GLX_USE_APPLEGL /* TODO: indirect on darwin */
@@ -1962,7 +1960,7 @@ __glXSwapIntervalSGI(int interval)
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
if (gc->driContext && psc->driScreen && psc->driScreen->setSwapInterval) { if (gc->isDirect && psc->driScreen && psc->driScreen->setSwapInterval) {
__GLXDRIdrawable *pdraw = __GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
psc->driScreen->setSwapInterval(pdraw, interval); psc->driScreen->setSwapInterval(pdraw, interval);
@@ -2004,7 +2002,7 @@ __glXSwapIntervalMESA(unsigned int interval)
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext(); struct glx_context *gc = __glXGetCurrentContext();
if (gc != NULL && gc->driContext) { if (gc != NULL && gc->isDirect) {
struct glx_screen *psc; struct glx_screen *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
@@ -2026,7 +2024,7 @@ __glXGetSwapIntervalMESA(void)
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext(); struct glx_context *gc = __glXGetCurrentContext();
if (gc != NULL && gc->driContext) { if (gc != NULL && gc->isDirect) {
struct glx_screen *psc; struct glx_screen *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
@@ -2060,7 +2058,7 @@ __glXGetVideoSyncSGI(unsigned int *count)
return GLX_BAD_CONTEXT; return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
if (!gc->driContext) if (!gc->isDirect)
return GLX_BAD_CONTEXT; return GLX_BAD_CONTEXT;
#endif #endif
@@ -2102,7 +2100,7 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
return GLX_BAD_CONTEXT; return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
if (!gc->driContext) if (!gc->isDirect)
return GLX_BAD_CONTEXT; return GLX_BAD_CONTEXT;
#endif #endif
@@ -2423,7 +2421,7 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
return -1; return -1;
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
if (!pdraw || !gc->driContext) if (!pdraw || !gc->isDirect)
return -1; return -1;
#endif #endif
@@ -2721,6 +2719,8 @@ indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
static const struct glx_context_vtable indirect_context_vtable = { static const struct glx_context_vtable indirect_context_vtable = {
indirect_destroy_context, indirect_destroy_context,
indirect_bind_context,
indirect_unbind_context,
indirect_wait_gl, indirect_wait_gl,
indirect_wait_x, indirect_wait_x,
indirect_use_x_font, indirect_use_x_font,

View File

@@ -283,37 +283,6 @@ SendMakeCurrentRequest(Display * dpy, CARD8 opcode,
return ret; return ret;
} }
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
static __GLXDRIdrawable *
FetchDRIDrawable(Display * dpy,
GLXDrawable glxDrawable, struct glx_context *gc)
{
struct glx_display *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
if (priv == NULL)
return NULL;
psc = priv->screens[gc->screen];
if (priv->drawHash == NULL)
return NULL;
if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
return pdraw;
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
glxDrawable, gc->config);
if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return NULL;
}
return pdraw;
}
#endif /* GLX_DIRECT_RENDERING */
static void static void
__glXGenerateError(Display * dpy, struct glx_context *gc, XID resource, __glXGenerateError(Display * dpy, struct glx_context *gc, XID resource,
BYTE errorCode, CARD16 minorCode) BYTE errorCode, CARD16 minorCode)
@@ -331,6 +300,55 @@ __glXGenerateError(Display * dpy, struct glx_context *gc, XID resource,
#endif /* GLX_USE_APPLEGL */ #endif /* GLX_USE_APPLEGL */
_X_HIDDEN int
indirect_bind_context(struct glx_context *gc, struct glx_context *old,
GLXDrawable draw, GLXDrawable read)
{
xGLXMakeCurrentReply reply;
GLXContextTag tag;
__GLXattribute *state;
Display *dpy = gc->psc->dpy;
int opcode = __glXSetupForCommand(dpy);
if (old && !old->isDirect && old->psc->dpy == dpy)
tag = old->currentContextTag;
else
tag = None;
SendMakeCurrentRequest(dpy, opcode, gc->xid, tag, draw, read, &reply);
if (!IndirectAPI)
IndirectAPI = __glXNewIndirectAPI();
_glapi_set_dispatch(IndirectAPI);
gc->currentContextTag = reply.contextTag;
state = gc->client_state_private;
if (state->array_state == NULL) {
glGetString(GL_EXTENSIONS);
glGetString(GL_VERSION);
__glXInitVertexArrayState(gc);
}
return Success;
}
_X_HIDDEN void
indirect_unbind_context(struct glx_context *gc, struct glx_context *new)
{
Display *dpy = gc->psc->dpy;
int opcode = __glXSetupForCommand(dpy);
xGLXMakeCurrentReply reply;
/* We are either switching to no context, away from a indirect
* context to a direct context or from one dpy to another and have
* to send a request to the dpy to unbind the previous context.
*/
if (!new || new->isDirect || new->psc->dpy != dpy)
SendMakeCurrentRequest(dpy, opcode, None,
gc->currentContextTag, None, None, &reply);
gc->currentContextTag = 0;
}
/** /**
* Make a particular context current. * Make a particular context current.
* *
@@ -342,25 +360,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
{ {
struct glx_context *gc = (struct glx_context *) gc_user; struct glx_context *gc = (struct glx_context *) gc_user;
struct glx_context *oldGC = __glXGetCurrentContext(); struct glx_context *oldGC = __glXGetCurrentContext();
#ifdef GLX_USE_APPLEGL int ret = Success;
bool error = apple_glx_make_current_context(dpy,
(oldGC && oldGC != &dummyContext) ? oldGC->driContext : NULL,
gc ? gc->driContext : NULL, draw);
apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
if(error)
return GL_FALSE;
#else
xGLXMakeCurrentReply reply;
const CARD8 opcode = __glXSetupForCommand(dpy);
const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
? opcode : __glXSetupForCommand(oldGC->currentDpy);
Bool bindReturnValue;
__GLXattribute *state;
if (!opcode || !oldOpcode) {
return GL_FALSE;
}
/* Make sure that the new context has a nonzero ID. In the request, /* Make sure that the new context has a nonzero ID. In the request,
* a zero context ID is used only to mean that we bind to no current * a zero context ID is used only to mean that we bind to no current
@@ -388,134 +388,36 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
return False; return False;
} }
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) if (oldGC != &dummyContext && oldGC != gc) {
/* Bind the direct rendering context to the drawable */ oldGC->vtable->unbind(oldGC, gc);
if (gc && gc->driContext) { oldGC->currentDpy = 0;
__GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); oldGC->currentDrawable = None;
__GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); oldGC->currentReadable = None;
oldGC->thread_id = 0;
if ((pdraw == NULL) || (pread == NULL)) { if (oldGC->xid == None)
__glXGenerateError(dpy, gc, (pdraw == NULL) ? draw : read, /* We are switching away from a context that was
GLXBadDrawable, X_GLXMakeContextCurrent); * previously destroyed, so we need to free the memory
return False; * for the old handle.
} */
oldGC->vtable->destroy(oldGC);
bindReturnValue =
(gc->driContext->bindContext) (gc, pdraw, pread);
}
else if (!gc && oldGC && oldGC->driContext) {
bindReturnValue = True;
}
else
#endif
{
/* Send a glXMakeCurrent request to bind the new context. */
bindReturnValue =
SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
((dpy != oldGC->currentDpy)
|| oldGC->isDirect)
? None : oldGC->currentContextTag, draw, read,
&reply);
} }
if (gc) {
if (!bindReturnValue) { ret = gc->vtable->bind(gc, oldGC, draw, read);
return False; gc->currentDpy = dpy;
gc->currentDrawable = draw;
gc->currentReadable = read;
gc->thread_id = _glthread_GetID();
__glXSetCurrentContext(gc);
} else {
__glXSetCurrentContextNull();
} }
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) if (ret) {
if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) && __glXGenerateError(dpy, gc, None, ret, X_GLXMakeContextCurrent);
!oldGC->isDirect && oldGC != &dummyContext) { return GL_FALSE;
#else
if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
#endif
xGLXMakeCurrentReply dummy_reply;
/* We are either switching from one dpy to another and have to
* send a request to the previous dpy to unbind the previous
* context, or we are switching away from a indirect context to
* a direct context and have to send a request to the dpy to
* unbind the previous context.
*/
(void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
oldGC->currentContextTag, None, None,
&dummy_reply);
} }
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
else if (oldGC->driContext && oldGC != gc) {
oldGC->driContext->unbindContext(oldGC);
}
#endif
#endif /* GLX_USE_APPLEGL */
/* Update our notion of what is current */
__glXLock();
if (gc == oldGC) {
/* Even though the contexts are the same the drawable might have
* changed. Note that gc cannot be the dummy, and that oldGC
* cannot be NULL, therefore if they are the same, gc is not
* NULL and not the dummy.
*/
if(gc) {
gc->currentDrawable = draw;
gc->currentReadable = read;
}
}
else {
if (oldGC != &dummyContext) {
/* Old current context is no longer current to anybody */
oldGC->currentDpy = 0;
oldGC->currentDrawable = None;
oldGC->currentReadable = None;
oldGC->currentContextTag = 0;
oldGC->thread_id = 0;
if (oldGC->xid == None) {
/* We are switching away from a context that was
* previously destroyed, so we need to free the memory
* for the old handle.
*/
oldGC->vtable->destroy(oldGC);
}
}
if (gc) {
__glXSetCurrentContext(gc);
gc->currentDpy = dpy;
gc->currentDrawable = draw;
gc->currentReadable = read;
#ifndef GLX_USE_APPLEGL
gc->thread_id = _glthread_GetID();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (!gc->driContext) {
#endif
if (!IndirectAPI)
IndirectAPI = __glXNewIndirectAPI();
_glapi_set_dispatch(IndirectAPI);
state = (__GLXattribute *) (gc->client_state_private);
gc->currentContextTag = reply.contextTag;
if (state->array_state == NULL) {
(void) glGetString(GL_EXTENSIONS);
(void) glGetString(GL_VERSION);
__glXInitVertexArrayState(gc);
}
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
}
else {
gc->currentContextTag = -1;
}
#endif
#endif /* GLX_USE_APPLEGL */
}
else {
__glXSetCurrentContextNull();
}
}
__glXUnlock();
return GL_TRUE; return GL_TRUE;
} }

View File

@@ -742,7 +742,7 @@ glx_screen_init(struct glx_screen *psc,
** If that works then fetch the per screen configs data. ** If that works then fetch the per screen configs data.
*/ */
static Bool static Bool
AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv) AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
{ {
struct glx_screen *psc; struct glx_screen *psc;
GLint i, screens; GLint i, screens;

View File

@@ -5199,7 +5199,7 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_DeleteTextures(GET_DISPATCH(), (n, textures)); CALL_DeleteTextures(GET_DISPATCH(), (n, textures));
} else } else
#endif #endif
@@ -5270,7 +5270,7 @@ glGenTexturesEXT(GLsizei n, GLuint * textures)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GenTextures(GET_DISPATCH(), (n, textures)); CALL_GenTextures(GET_DISPATCH(), (n, textures));
} else } else
#endif #endif
@@ -5335,7 +5335,7 @@ glIsTextureEXT(GLuint texture)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
return CALL_IsTexture(GET_DISPATCH(), (texture)); return CALL_IsTexture(GET_DISPATCH(), (texture));
} else } else
#endif #endif
@@ -5651,7 +5651,7 @@ glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table)); CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table));
} else } else
#endif #endif
@@ -5727,7 +5727,7 @@ glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetColorTableParameterfv(GET_DISPATCH(), CALL_GetColorTableParameterfv(GET_DISPATCH(),
(target, pname, params)); (target, pname, params));
} else } else
@@ -5800,7 +5800,7 @@ glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetColorTableParameteriv(GET_DISPATCH(), CALL_GetColorTableParameteriv(GET_DISPATCH(),
(target, pname, params)); (target, pname, params));
} else } else
@@ -6126,7 +6126,7 @@ gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type,
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetConvolutionFilter(GET_DISPATCH(), CALL_GetConvolutionFilter(GET_DISPATCH(),
(target, format, type, image)); (target, format, type, image));
} else } else
@@ -6204,7 +6204,7 @@ gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetConvolutionParameterfv(GET_DISPATCH(), CALL_GetConvolutionParameterfv(GET_DISPATCH(),
(target, pname, params)); (target, pname, params));
} else } else
@@ -6277,7 +6277,7 @@ gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetConvolutionParameteriv(GET_DISPATCH(), CALL_GetConvolutionParameteriv(GET_DISPATCH(),
(target, pname, params)); (target, pname, params));
} else } else
@@ -6357,7 +6357,7 @@ gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format,
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetHistogram(GET_DISPATCH(), CALL_GetHistogram(GET_DISPATCH(),
(target, reset, format, type, values)); (target, reset, format, type, values));
} else } else
@@ -6434,7 +6434,7 @@ gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params)); CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params));
} else } else
#endif #endif
@@ -6505,7 +6505,7 @@ gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params)); CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params));
} else } else
#endif #endif
@@ -6580,7 +6580,7 @@ gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format,
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values)); CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values));
} else } else
#endif #endif
@@ -6654,7 +6654,7 @@ gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params)); CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params));
} else } else
#endif #endif
@@ -6722,7 +6722,7 @@ gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params)
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params)); CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params));
} else } else
#endif #endif

View File

@@ -120,7 +120,7 @@ void NAME(_gloffset_GetSeparableFilter) (GLenum target, GLenum format,
struct glx_context *const gc = __glXGetCurrentContext(); struct glx_context *const gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) { if (gc->isDirect) {
CALL_GetSeparableFilter(GET_DISPATCH(), CALL_GetSeparableFilter(GET_DISPATCH(),
(target, format, type, row, column, span)); (target, format, type, row, column, span));
return; return;

View File

@@ -374,7 +374,7 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
print ' struct glx_context * const gc = __glXGetCurrentContext();' print ' struct glx_context * const gc = __glXGetCurrentContext();'
print '' print ''
print '#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)' print '#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)'
print ' if (gc->driContext) {' print ' if (gc->isDirect) {'
print ' %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string()) print ' %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())
print ' } else' print ' } else'
print '#endif' print '#endif'