summaryrefslogtreecommitdiffstats
path: root/src/glx
diff options
context:
space:
mode:
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/XF86dri.c1
-rw-r--r--src/glx/apple/appledri.c2
-rw-r--r--src/glx/apple/gen_exports.tcl3
-rw-r--r--src/glx/apple/glx_empty.c94
-rw-r--r--src/glx/dri2.c12
-rw-r--r--src/glx/dri2_glx.c475
-rw-r--r--src/glx/dri_common.c126
-rw-r--r--src/glx/dri_common.h8
-rw-r--r--src/glx/dri_glx.c381
-rw-r--r--src/glx/drisw_glx.c226
-rw-r--r--src/glx/glx_pbuffer.c27
-rw-r--r--src/glx/glxclient.h139
-rw-r--r--src/glx/glxcmds.c1033
-rw-r--r--src/glx/glxcurrent.c37
-rw-r--r--src/glx/glxext.c294
-rw-r--r--src/glx/glxextensions.c4
-rw-r--r--src/glx/glxextensions.h1
-rw-r--r--src/glx/xfont.c4
18 files changed, 1300 insertions, 1567 deletions
diff --git a/src/glx/XF86dri.c b/src/glx/XF86dri.c
index d0e88805bcc..36b43f0f84a 100644
--- a/src/glx/XF86dri.c
+++ b/src/glx/XF86dri.c
@@ -38,7 +38,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
diff --git a/src/glx/apple/appledri.c b/src/glx/apple/appledri.c
index 4f2e8f99149..46c84f3ab77 100644
--- a/src/glx/apple/appledri.c
+++ b/src/glx/apple/appledri.c
@@ -38,8 +38,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* THIS IS NOT AN X CONSORTIUM STANDARD */
-#define NEED_EVENTS
-#define NEED_REPLIES
#include <X11/Xlibint.h>
#include "appledristr.h"
#include <X11/extensions/Xext.h>
diff --git a/src/glx/apple/gen_exports.tcl b/src/glx/apple/gen_exports.tcl
index acfe6e6a9e6..ed76929d8aa 100644
--- a/src/glx/apple/gen_exports.tcl
+++ b/src/glx/apple/gen_exports.tcl
@@ -82,8 +82,7 @@ proc main {argc argv} {
glXBindSwapBarrierSGIX glXQueryMaxSwapBarriersSGIX \
glXGetSyncValuesOML glXSwapBuffersMscOML \
glXWaitForMscOML glXWaitForSbcOML \
- glXAllocateMemoryMESA glXFreeMemoryMESA \
- glXGetMemoryOffsetMESA glXReleaseBuffersMESA \
+ glXReleaseBuffersMESA \
glXCreateGLXPixmapMESA glXCopySubBufferMESA \
glXQueryGLXPbufferSGIX glXCreateGLXPbufferSGIX \
glXDestroyGLXPbufferSGIX glXSelectEventSGIX \
diff --git a/src/glx/apple/glx_empty.c b/src/glx/apple/glx_empty.c
index 44c5a256f20..1569679c713 100644
--- a/src/glx/apple/glx_empty.c
+++ b/src/glx/apple/glx_empty.c
@@ -32,54 +32,6 @@ glXGetSwapIntervalMESA(void)
/*
-** GLX_MESA_swap_frame_usage
-*/
-
-int
-glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
-{
- int status = GLX_BAD_CONTEXT;
- (void) dpy;
- (void) drawable;
- return status;
-}
-
-
-int
-glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
-{
- int status = GLX_BAD_CONTEXT;
- (void) dpy;
- (void) drawable;
- return status;
-}
-
-
-int
-glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage)
-{
- int status = GLX_BAD_CONTEXT;
- (void) dpy;
- (void) drawable;
- (void) usage;
- return status;
-}
-
-int
-glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable,
- int64_t * sbc, int64_t * missedFrames,
- GLfloat * lastMissedUsage)
-{
- int status = GLX_BAD_CONTEXT;
- (void) dpy;
- (void) drawable;
- (void) sbc;
- (void) missedFrames;
- (void) lastMissedUsage;
- return status;
-}
-
-/*
** GLX_SGI_video_sync
*/
int
@@ -191,52 +143,6 @@ glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
}
-/**
- * GLX_MESA_allocate_memory
- */
-/*@{*/
-
-PUBLIC void *
-glXAllocateMemoryMESA(Display * dpy, int scrn,
- size_t size, float readFreq,
- float writeFreq, float priority)
-{
- (void) dpy;
- (void) scrn;
- (void) size;
- (void) readFreq;
- (void) writeFreq;
- (void) priority;
- return NULL;
-}
-
-
-PUBLIC void
-glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- (*psc->allocate->freeMemory) (psc->__driScreen, pointer);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) pointer;
-#endif /* __DRI_ALLOCATE */
-}
-
-
-PUBLIC GLuint
-glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer)
-{
- (void) dpy;
- (void) scrn;
- (void) pointer;
- return ~0L;
-}
-
Bool
glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
{
diff --git a/src/glx/dri2.c b/src/glx/dri2.c
index 6afa4149651..d53431c19a6 100644
--- a/src/glx/dri2.c
+++ b/src/glx/dri2.c
@@ -33,7 +33,6 @@
#ifdef GLX_DIRECT_RENDERING
-#define NEED_REPLIES
#include <stdio.h>
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
@@ -89,7 +88,7 @@ static Bool
DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- XExtDisplayInfo *glx_info = __glXFindDisplay(dpy);
+ __GLXdisplayPrivate *glx_dpy = __glXInitialize(dpy);
XextCheckExtension(dpy, info, dri2ExtensionName, False);
@@ -100,8 +99,15 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
+ __GLXDRIdrawable *pdraw;
+
+ /* Ignore swap events if we're not looking for them */
+ pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
+ if (!(pdraw->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
+ return False;
+
aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
- aevent->type = glx_info->codes->first_event + GLX_BufferSwapComplete;
+ aevent->type = glx_dpy->codes->first_event + GLX_BufferSwapComplete;
aevent->send_event = (awire->type & 0x80) != 0;
aevent->display = dpy;
aevent->drawable = awire->drawable;
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index d4747388e30..49c7ce75024 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -57,11 +57,7 @@
#undef DRI2_MINOR
#define DRI2_MINOR 1
-typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
-typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
-typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
-
-struct __GLXDRIdisplayPrivateRec
+struct dri2_display
{
__GLXDRIdisplay base;
@@ -74,19 +70,39 @@ struct __GLXDRIdisplayPrivateRec
int swapAvailable;
int invalidateAvailable;
+ __glxHashTable *dri2Hash;
+
const __DRIextension *loader_extensions[4];
};
-struct __GLXDRIcontextPrivateRec
+struct dri2_screen {
+ __GLXscreenConfigs base;
+
+ __DRIscreen *driScreen;
+ __GLXDRIscreen vtable;
+ const __DRIdri2Extension *dri2;
+ const __DRIcoreExtension *core;
+
+ const __DRI2flushExtension *f;
+ const __DRI2configQueryExtension *config;
+ const __DRItexBufferExtension *texBuffer;
+ const __DRIconfig **driver_configs;
+
+ void *driver;
+ int fd;
+};
+
+struct dri2_context
{
- __GLXDRIcontext base;
+ __GLXcontext base;
+ __GLXDRIcontext dri_vtable;
__DRIcontext *driContext;
- __GLXscreenConfigs *psc;
};
-struct __GLXDRIdrawablePrivateRec
+struct dri2_drawable
{
__GLXDRIdrawable base;
+ __DRIdrawable *driDrawable;
__DRIbuffer buffers[5];
int bufferCount;
int width, height;
@@ -95,51 +111,61 @@ struct __GLXDRIdrawablePrivateRec
int swap_interval;
};
-static void dri2WaitX(__GLXDRIdrawable * pdraw);
+static const struct glx_context_vtable dri2_context_vtable;
static void
-dri2DestroyContext(__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy)
+dri2_destroy_context(__GLXcontext *context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri2_context *pcp = (struct dri2_context *) context;
+ struct dri2_screen *psc = (struct dri2_screen *) context->psc;
+
+ if (context->xid)
+ glx_send_destroy_context(psc->base.dpy, context->xid);
+
+ if (context->extensions)
+ XFree((char *) context->extensions);
- (*core->destroyContext) (pcp->driContext);
+ GarbageCollectDRIDrawables(context->psc);
+
+ (*psc->core->destroyContext) (pcp->driContext);
Xfree(pcp);
}
static Bool
-dri2BindContext(__GLXDRIcontext * context,
- __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
+dri2BindContext(__GLXcontext *context,
+ __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri2_context *pcp = (struct dri2_context *) context;
+ struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
+ struct dri2_drawable *pdr = (struct dri2_drawable *) draw;
+ struct dri2_drawable *prd = (struct dri2_drawable *) read;
- return (*core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ return (*psc->core->bindContext) (pcp->driContext,
+ pdr->driDrawable, prd->driDrawable);
}
static void
-dri2UnbindContext(__GLXDRIcontext * context)
+dri2UnbindContext(__GLXcontext *context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri2_context *pcp = (struct dri2_context *) context;
+ struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
- (*core->unbindContext) (pcp->driContext);
+ (*psc->core->unbindContext) (pcp->driContext);
}
-static __GLXDRIcontext *
-dri2CreateContext(__GLXscreenConfigs * psc,
- const __GLcontextModes * mode,
- GLXContext gc, GLXContext shareList, int renderType)
+static __GLXcontext *
+dri2_create_context(__GLXscreenConfigs *base,
+ const __GLcontextModes * mode,
+ GLXContext shareList, int renderType)
{
- __GLXDRIcontextPrivate *pcp, *pcp_shared;
+ struct dri2_context *pcp, *pcp_shared;
+ struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
__DRIcontext *shared = NULL;
if (shareList) {
- pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+ pcp_shared = (struct dri2_context *) shareList;
shared = pcp_shared->driContext;
}
@@ -147,59 +173,70 @@ dri2CreateContext(__GLXscreenConfigs * psc,
if (pcp == NULL)
return NULL;
- pcp->psc = psc;
+ memset(pcp, 0, sizeof *pcp);
+ if (!glx_context_init(&pcp->base, &psc->base, mode)) {
+ Xfree(pcp);
+ return NULL;
+ }
+
pcp->driContext =
- (*psc->dri2->createNewContext) (psc->__driScreen,
+ (*psc->dri2->createNewContext) (psc->driScreen,
config->driConfig, shared, pcp);
- gc->__driContext = pcp->driContext;
if (pcp->driContext == NULL) {
Xfree(pcp);
return NULL;
}
- pcp->base.destroyContext = dri2DestroyContext;
- pcp->base.bindContext = dri2BindContext;
- pcp->base.unbindContext = dri2UnbindContext;
+ 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;
}
static void
-dri2DestroyDrawable(__GLXDRIdrawable * pdraw)
+dri2DestroyDrawable(__GLXDRIdrawable *base)
{
- const __DRIcoreExtension *core = pdraw->psc->core;
-
- (*core->destroyDrawable) (pdraw->driDrawable);
- DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->xDrawable);
+ struct dri2_screen *psc = (struct dri2_screen *) base->psc;
+ struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
+ __GLXdisplayPrivate *dpyPriv = psc->base.display;
+ struct dri2_display *pdp = (struct dri2_display *)dpyPriv->dri2Display;
+
+ __glxHashDelete(pdp->dri2Hash, pdraw->base.xDrawable);
+ (*psc->core->destroyDrawable) (pdraw->driDrawable);
+ DRI2DestroyDrawable(psc->base.dpy, pdraw->base.xDrawable);
Xfree(pdraw);
}
static __GLXDRIdrawable *
-dri2CreateDrawable(__GLXscreenConfigs * psc,
- XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+dri2CreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
+ GLXDrawable drawable, const __GLcontextModes * modes)
{
- __GLXDRIdrawablePrivate *pdraw;
+ struct dri2_drawable *pdraw;
+ struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
__GLXdisplayPrivate *dpyPriv;
- __GLXDRIdisplayPrivate *pdp;
+ struct dri2_display *pdp;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
pdraw = Xmalloc(sizeof(*pdraw));
if (!pdraw)
return NULL;
+ memset(pdraw, 0, sizeof *pdraw);
pdraw->base.destroyDrawable = dri2DestroyDrawable;
pdraw->base.xDrawable = xDrawable;
pdraw->base.drawable = drawable;
- pdraw->base.psc = psc;
+ pdraw->base.psc = &psc->base;
pdraw->bufferCount = 0;
pdraw->swap_interval = 1; /* default may be overridden below */
pdraw->have_back = 0;
if (psc->config)
- psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode);
+ psc->config->configQueryi(psc->driScreen,
+ "vblank_mode", &vblank_mode);
switch (vblank_mode) {
case DRI_CONF_VBLANK_NEVER:
@@ -213,28 +250,36 @@ dri2CreateDrawable(__GLXscreenConfigs * psc,
break;
}
- DRI2CreateDrawable(psc->dpy, xDrawable);
+ DRI2CreateDrawable(psc->base.dpy, xDrawable);
- dpyPriv = __glXInitialize(psc->dpy);
- pdp = (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;;
+ dpyPriv = __glXInitialize(psc->base.dpy);
+ pdp = (struct dri2_display *)dpyPriv->dri2Display;;
/* Create a new drawable */
- pdraw->base.driDrawable =
- (*psc->dri2->createNewDrawable) (psc->__driScreen,
+ pdraw->driDrawable =
+ (*psc->dri2->createNewDrawable) (psc->driScreen,
config->driConfig, pdraw);
- if (!pdraw->base.driDrawable) {
- DRI2DestroyDrawable(psc->dpy, xDrawable);
+ if (!pdraw->driDrawable) {
+ DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw);
return NULL;
}
+ if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) {
+ (*psc->core->destroyDrawable) (pdraw->driDrawable);
+ DRI2DestroyDrawable(psc->base.dpy, xDrawable);
+ Xfree(pdraw);
+ return None;
+ }
+
+
#ifdef X_DRI2SwapInterval
/*
* Make sure server has the same swap interval we do for the new
* drawable.
*/
if (pdp->swapAvailable)
- DRI2SwapInterval(psc->dpy, xDrawable, pdraw->swap_interval);
+ DRI2SwapInterval(psc->base.dpy, xDrawable, pdraw->swap_interval);
#endif
return &pdraw->base;
@@ -246,7 +291,16 @@ static int
dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
int64_t *ust, int64_t *msc, int64_t *sbc)
{
- return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc);
+ CARD64 dri2_ust, dri2_msc, dri2_sbc;
+ int ret;
+
+ ret = DRI2GetMSC(psc->dpy, pdraw->xDrawable,
+ &dri2_ust, &dri2_msc, &dri2_sbc);
+ *ust = dri2_ust;
+ *msc = dri2_msc;
+ *sbc = dri2_sbc;
+
+ return ret;
}
#endif
@@ -258,16 +312,32 @@ static int
dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
{
- return DRI2WaitMSC(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor,
- remainder, ust, msc, sbc);
+ CARD64 dri2_ust, dri2_msc, dri2_sbc;
+ int ret;
+
+ ret = DRI2WaitMSC(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor,
+ remainder, &dri2_ust, &dri2_msc, &dri2_sbc);
+ *ust = dri2_ust;
+ *msc = dri2_msc;
+ *sbc = dri2_sbc;
+
+ return ret;
}
static int
dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
- return DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable, target_sbc, ust, msc,
- sbc);
+ CARD64 dri2_ust, dri2_msc, dri2_sbc;
+ int ret;
+
+ ret = DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable,
+ target_sbc, &dri2_ust, &dri2_msc, &dri2_sbc);
+ *ust = dri2_ust;
+ *msc = dri2_msc;
+ *sbc = dri2_sbc;
+
+ return ret;
}
#endif /* X_DRI2WaitMSC */
@@ -275,7 +345,8 @@ dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
static void
dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height)
{
- __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+ struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
+ struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
XRectangle xrect;
XserverRegion region;
@@ -289,32 +360,30 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height)
xrect.height = height;
#ifdef __DRI2_FLUSH
- if (pdraw->psc->f)
- (*pdraw->psc->f->flush) (pdraw->driDrawable);
+ if (psc->f)
+ (*psc->f->flush) (priv->driDrawable);
#endif
- region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
- /* should get a fence ID back from here at some point */
- DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region,
+ region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
+ DRI2CopyRegion(psc->base.dpy, pdraw->xDrawable, region,
DRI2BufferFrontLeft, DRI2BufferBackLeft);
- XFixesDestroyRegion(pdraw->psc->dpy, region);
/* Refresh the fake front (if present) after we just damaged the real
* front.
*/
- dri2WaitX(pdraw);
+ if (priv->have_fake_front)
+ DRI2CopyRegion(psc->base.dpy, pdraw->xDrawable, region,
+ DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
+
+ XFixesDestroyRegion(psc->base.dpy, region);
}
static void
-dri2WaitX(__GLXDRIdrawable *pdraw)
+dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src)
{
- __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
XRectangle xrect;
XserverRegion region;
-
- /* Check we have the right attachments */
- if (!priv->have_fake_front)
- return;
+ struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
xrect.x = 0;
xrect.y = 0;
@@ -322,64 +391,66 @@ dri2WaitX(__GLXDRIdrawable *pdraw)
xrect.height = priv->height;
#ifdef __DRI2_FLUSH
- if (pdraw->psc->f)
- (*pdraw->psc->f->flush) (pdraw->driDrawable);
+ if (psc->f)
+ (*psc->f->flush) (priv->driDrawable);
#endif
- region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
- DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region,
- DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
- XFixesDestroyRegion(pdraw->psc->dpy, region);
+ region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
+ DRI2CopyRegion(psc->base.dpy, priv->base.xDrawable, region, dest, src);
+ XFixesDestroyRegion(psc->base.dpy, region);
+
}
static void
-dri2WaitGL(__GLXDRIdrawable * pdraw)
+dri2_wait_x(__GLXcontext *gc)
{
- __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
- XRectangle xrect;
- XserverRegion region;
+ struct dri2_drawable *priv = (struct dri2_drawable *)
+ GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
- if (!priv->have_fake_front)
+ if (priv == NULL || !priv->have_fake_front)
return;
- xrect.x = 0;
- xrect.y = 0;
- xrect.width = priv->width;
- xrect.height = priv->height;
+ dri2_copy_drawable(priv, DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
+}
-#ifdef __DRI2_FLUSH
- if (pdraw->psc->f)
- (*pdraw->psc->f->flush) (pdraw->driDrawable);
-#endif
+static void
+dri2_wait_gl(__GLXcontext *gc)
+{
+ struct dri2_drawable *priv = (struct dri2_drawable *)
+ GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
- region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
- DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region,
- DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
- XFixesDestroyRegion(pdraw->psc->dpy, region);
+ if (priv == NULL || !priv->have_fake_front)
+ return;
+
+ dri2_copy_drawable(priv, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
}
static void
dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
+ struct dri2_drawable *pdraw = loaderPrivate;
__GLXdisplayPrivate *priv = __glXInitialize(pdraw->base.psc->dpy);
- __GLXDRIdisplayPrivate *pdp = (__GLXDRIdisplayPrivate *)priv->dri2Display;
+ struct dri2_display *pdp = (struct dri2_display *)priv->dri2Display;
+ GLXContext gc = __glXGetCurrentContext();
/* Old servers don't send invalidate events */
if (!pdp->invalidateAvailable)
dri2InvalidateBuffers(priv->dpy, pdraw->base.drawable);
- dri2WaitGL(loaderPrivate);
+ dri2_wait_gl(gc);
}
static void
-dri2DestroyScreen(__GLXscreenConfigs * psc)
+dri2DestroyScreen(__GLXscreenConfigs *base)
{
+ struct dri2_screen *psc = (struct dri2_screen *) base;
+
/* Free the direct rendering per screen data */
- (*psc->core->destroyScreen) (psc->__driScreen);
+ (*psc->core->destroyScreen) (psc->driScreen);
+ driDestroyConfigs(psc->driver_configs);
close(psc->fd);
- psc->__driScreen = NULL;
+ Xfree(psc);
}
/**
@@ -389,7 +460,7 @@ dri2DestroyScreen(__GLXscreenConfigs * psc)
* \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat.
*/
static void
-process_buffers(__GLXDRIdrawablePrivate * pdraw, DRI2Buffer * buffers,
+process_buffers(struct dri2_drawable * pdraw, DRI2Buffer * buffers,
unsigned count)
{
int i;
@@ -418,15 +489,16 @@ static int64_t
dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder)
{
- __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+ struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
__GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy);
- __GLXDRIdisplayPrivate *pdp =
- (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;
- int64_t ret;
+ struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
+ struct dri2_display *pdp =
+ (struct dri2_display *)dpyPriv->dri2Display;
+ CARD64 ret;
#ifdef __DRI2_FLUSH
- if (pdraw->psc->f)
- (*pdraw->psc->f->flush)(pdraw->driDrawable);
+ if (psc->f)
+ (*psc->f->flush)(priv->driDrawable);
#endif
/* Old servers don't send invalidate events */
@@ -440,7 +512,7 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
}
#ifdef X_DRI2SwapBuffers
- DRI2SwapBuffers(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor,
+ DRI2SwapBuffers(psc->base.dpy, pdraw->xDrawable, target_msc, divisor,
remainder, &ret);
#endif
@@ -453,7 +525,7 @@ dri2GetBuffers(__DRIdrawable * driDrawable,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
+ struct dri2_drawable *pdraw = loaderPrivate;
DRI2Buffer *buffers;
buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
@@ -476,7 +548,7 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
+ struct dri2_drawable *pdraw = loaderPrivate;
DRI2Buffer *buffers;
buffers = DRI2GetBuffersWithFormat(pdraw->base.psc->dpy,
@@ -497,35 +569,38 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
#ifdef X_DRI2SwapInterval
-static void
+static int
dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{
- __GLXscreenConfigs *psc = pdraw->psc;
- __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+ struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+ struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
if (psc->config)
- psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode);
+ psc->config->configQueryi(psc->driScreen,
+ "vblank_mode", &vblank_mode);
switch (vblank_mode) {
case DRI_CONF_VBLANK_NEVER:
- return;
+ return GLX_BAD_VALUE;
case DRI_CONF_VBLANK_ALWAYS_SYNC:
if (interval <= 0)
- return;
+ return GLX_BAD_VALUE;
break;
default:
break;
}
- DRI2SwapInterval(priv->base.psc->dpy, pdraw->xDrawable, interval);
+ DRI2SwapInterval(priv->base.psc->dpy, priv->base.xDrawable, interval);
priv->swap_interval = interval;
+
+ return 0;
}
-static unsigned int
+static int
dri2GetSwapInterval(__GLXDRIdrawable *pdraw)
{
- __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+ struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
return priv->swap_interval;
}
@@ -555,11 +630,14 @@ static const __DRIuseInvalidateExtension dri2UseInvalidate = {
_X_HIDDEN void
dri2InvalidateBuffers(Display *dpy, XID drawable)
{
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+ __GLXDRIdrawable *pdraw =
+ dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
+ struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
+ struct dri2_drawable *pdp = (struct dri2_drawable *) pdraw;
#if __DRI2_FLUSH_VERSION >= 3
- if (pdraw && pdraw->psc->f)
- pdraw->psc->f->invalidate(pdraw->driDrawable);
+ if (pdraw && psc->f)
+ psc->f->invalidate(pdp->driDrawable);
#endif
}
@@ -569,29 +647,32 @@ dri2_bind_tex_image(Display * dpy,
int buffer, const int *attrib_list)
{
GLXContext gc = __glXGetCurrentContext();
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
- __GLXdisplayPrivate *dpyPriv = __glXInitialize(dpy);
- __GLXDRIdisplayPrivate *pdp =
- (__GLXDRIdisplayPrivate *) dpyPriv->dri2Display;
+ struct dri2_context *pcp = (struct dri2_context *) gc;
+ __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
+ __GLXdisplayPrivate *dpyPriv = __glXInitialize(dpy);
+ struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
+ struct dri2_display *pdp =
+ (struct dri2_display *) dpyPriv->dri2Display;
+ struct dri2_screen *psc = (struct dri2_screen *) base->psc;
if (pdraw != NULL) {
#if __DRI2_FLUSH_VERSION >= 3
- if (!pdp->invalidateAvailable && pdraw->psc->f)
- pdraw->psc->f->invalidate(pdraw->driDrawable);
+ if (!pdp->invalidateAvailable && psc->f)
+ psc->f->invalidate(pdraw->driDrawable);
#endif
- if (pdraw->psc->texBuffer->base.version >= 2 &&
- pdraw->psc->texBuffer->setTexBuffer2 != NULL) {
- (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext,
- pdraw->textureTarget,
- pdraw->textureFormat,
- pdraw->driDrawable);
+ if (psc->texBuffer->base.version >= 2 &&
+ psc->texBuffer->setTexBuffer2 != NULL) {
+ (*psc->texBuffer->setTexBuffer2) (pcp->driContext,
+ pdraw->base.textureTarget,
+ pdraw->base.textureFormat,
+ pdraw->driDrawable);
}
else {
- (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext,
- pdraw->textureTarget,
- pdraw->driDrawable);
+ (*psc->texBuffer->setTexBuffer) (pcp->driContext,
+ pdraw->base.textureTarget,
+ pdraw->driDrawable);
}
}
}
@@ -602,30 +683,71 @@ dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
}
static const struct glx_context_vtable dri2_context_vtable = {
+ dri2_destroy_context,
+ dri2_wait_gl,
+ dri2_wait_x,
+ DRI_glXUseXFont,
dri2_bind_tex_image,
dri2_release_tex_image,
};
-static __GLXDRIscreen *
-dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv)
+static void
+dri2BindExtensions(struct dri2_screen *psc, const __DRIextension **extensions)
+{
+ int i;
+
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control");
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control");
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
+
+ /* FIXME: if DRI2 version supports it... */
+ __glXEnableDirectExtension(&psc->base, "INTEL_swap_event");
+
+ for (i = 0; extensions[i]; i++) {
+ if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
+ psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap");
+ }
+
+ if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) {
+ psc->f = (__DRI2flushExtension *) extensions[i];
+ /* internal driver extension, no GL extension exposed */
+ }
+
+ if ((strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0))
+ psc->config = (__DRI2configQueryExtension *) extensions[i];
+ }
+}
+
+static const struct glx_screen_vtable dri2_screen_vtable = {
+ dri2_create_context
+};
+
+static __GLXscreenConfigs *
+dri2CreateScreen(int screen, __GLXdisplayPrivate * priv)
{
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
- const __GLXDRIdisplayPrivate *const pdp = (__GLXDRIdisplayPrivate *)
+ const struct dri2_display *const pdp = (struct dri2_display *)
priv->dri2Display;
+ struct dri2_screen *psc;
__GLXDRIscreen *psp;
char *driverName, *deviceName;
drm_magic_t magic;
int i;
- psp = Xmalloc(sizeof *psp);
- if (psp == NULL)
+ psc = Xmalloc(sizeof *psc);
+ if (psc == NULL)
return NULL;
- if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen),
+ memset(psc, 0, sizeof *psc);
+ if (!glx_screen_init(&psc->base, screen, priv))
+ return NULL;
+
+ if (!DRI2Connect(priv->dpy, RootWindow(priv->dpy, screen),
&driverName, &deviceName)) {
- XFree(psp);
+ XFree(psc);
return NULL;
}
@@ -664,7 +786,7 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
goto handle_error;
}
- if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) {
+ if (!DRI2Authenticate(priv->dpy, RootWindow(priv->dpy, screen), magic)) {
ErrorMessageF("failed to authenticate magic %d\n", magic);
goto handle_error;
}
@@ -673,31 +795,33 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
/* If the server does not support the protocol for
* DRI2GetBuffersWithFormat, don't supply that interface to the driver.
*/
- psc->__driScreen =
+ psc->driScreen =
psc->dri2->createNewScreen(screen, psc->fd,
(const __DRIextension **)
&pdp->loader_extensions[0],
&driver_configs, psc);
- if (psc->__driScreen == NULL) {
+ if (psc->driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
- driBindCommonExtensions(psc);
- dri2BindExtensions(psc);
+ extensions = psc->core->getExtensions(psc->driScreen);
+ dri2BindExtensions(psc, extensions);
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+ psc->base.configs =
+ driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ psc->base.visuals =
+ driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
psc->driver_configs = driver_configs;
+ psc->base.vtable = &dri2_screen_vtable;
+ psp = &psc->vtable;
+ psc->base.driScreen = psp;
psp->destroyScreen = dri2DestroyScreen;
- psp->createContext = dri2CreateContext;
psp->createDrawable = dri2CreateDrawable;
psp->swapBuffers = dri2SwapBuffers;
- psp->waitGL = dri2WaitGL;
- psp->waitX = dri2WaitX;
psp->getDrawableMSC = NULL;
psp->waitForMSC = NULL;
psp->waitForSBC = NULL;
@@ -717,26 +841,24 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
psp->getSwapInterval = dri2GetSwapInterval;
#endif
#if defined(X_DRI2GetMSC) && defined(X_DRI2WaitMSC) && defined(X_DRI2SwapInterval)
- __glXEnableDirectExtension(psc, "GLX_OML_sync_control");
+ __glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control");
#endif
}
/* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always
* available.*/
psp->copySubBuffer = dri2CopySubBuffer;
- __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer");
-
- psc->direct_context_vtable = &dri2_context_vtable;
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
Xfree(driverName);
Xfree(deviceName);
- return psp;
+ return &psc->base;
handle_error:
Xfree(driverName);
Xfree(deviceName);
- XFree(psp);
+ XFree(psc);
/* FIXME: clean up here */
@@ -751,6 +873,19 @@ dri2DestroyDisplay(__GLXDRIdisplay * dpy)
Xfree(dpy);
}
+_X_HIDDEN __GLXDRIdrawable *
+dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id)
+{
+ __GLXdisplayPrivate *d = __glXInitialize(dpy);
+ struct dri2_display *pdp = (struct dri2_display *) d->dri2Display;
+ __GLXDRIdrawable *pdraw;
+
+ if (__glxHashLookup(pdp->dri2Hash, id, (void *) &pdraw) == 0)
+ return pdraw;
+
+ return NULL;
+}
+
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
@@ -759,7 +894,7 @@ dri2DestroyDisplay(__GLXDRIdisplay * dpy)
_X_HIDDEN __GLXDRIdisplay *
dri2CreateDisplay(Display * dpy)
{
- __GLXDRIdisplayPrivate *pdp;
+ struct dri2_display *pdp;
int eventBase, errorBase, i;
if (!DRI2QueryExtension(dpy, &eventBase, &errorBase))
@@ -794,6 +929,12 @@ dri2CreateDisplay(Display * dpy)
#endif
pdp->loader_extensions[i++] = NULL;
+ pdp->dri2Hash = __glxHashCreate();
+ if (pdp->dri2Hash == NULL) {
+ Xfree(pdp);
+ return NULL;
+ }
+
return &pdp->base;
}
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 429fc6d8912..9b7da3e7df5 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -159,10 +159,20 @@ driOpenDriver(const char *driverName)
return handle;
}
+static GLboolean
+__driGetMSCRate(__DRIdrawable *draw,
+ int32_t * numerator, int32_t * denominator,
+ void *loaderPrivate)
+{
+ __GLXDRIdrawable *glxDraw = loaderPrivate;
+
+ return __glxGetMscRate(glxDraw, numerator, denominator);
+}
+
_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
{__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION},
__glXGetUST,
- __driGetMscRateOML
+ __driGetMSCRate
};
#define __ATTRIB(attrib, field) \
@@ -336,120 +346,14 @@ driConvertConfigs(const __DRIcoreExtension * core,
return head.next;
}
-/* Bind DRI1 specific extensions */
-_X_HIDDEN void
-driBindExtensions(__GLXscreenConfigs *psc)
-{
- const __DRIextension **extensions;
- int i;
-
- extensions = psc->core->getExtensions(psc->__driScreen);
-
- for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_SWAP_CONTROL
- /* No DRI2 support for swap_control at the moment, since SwapBuffers
- * is done by the X server */
- if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
- psc->swapControl = (__DRIswapControlExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
- __glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
- }
-#endif
-
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
- psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_SGI_video_sync");
- }
-#endif
-
-#ifdef __DRI_SWAP_BUFFER_COUNTER
- /* No driver supports this at this time and the extension is
- * not defined in dri_interface.h. Will enable
- * GLX_OML_sync_control if implemented. */
-#endif
-
- /* Ignore unknown extensions */
- }
-}
-
-/* Bind DRI2 specific extensions */
_X_HIDDEN void
-dri2BindExtensions(__GLXscreenConfigs *psc)
+driDestroyConfigs(const __DRIconfig **configs)
{
- const __DRIextension **extensions;
int i;
- extensions = psc->core->getExtensions(psc->__driScreen);
-
- for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_TEX_BUFFER
- if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
- psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap");
- }
-#endif
-
- __glXEnableDirectExtension(psc, "GLX_SGI_video_sync");
- __glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
- __glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
-
- /* FIXME: if DRI2 version supports it... */
- __glXEnableDirectExtension(psc, "INTEL_swap_event");
-
-#ifdef __DRI2_FLUSH
- if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) {
- psc->f = (__DRI2flushExtension *) extensions[i];
- /* internal driver extension, no GL extension exposed */
- }
-#endif
-
-#ifdef __DRI2_CONFIG_QUERY
- if ((strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0))
- psc->config = (__DRI2configQueryExtension *) extensions[i];
-#endif
- }
-}
-
-/* Bind extensions common to DRI1 and DRI2 */
-_X_HIDDEN void
-driBindCommonExtensions(__GLXscreenConfigs *psc)
-{
- const __DRIextension **extensions;
- int i;
-
- extensions = psc->core->getExtensions(psc->__driScreen);
-
- for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_COPY_SUB_BUFFER
- if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
- psc->driCopySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer");
- }
-#endif
-
-#ifdef __DRI_ALLOCATE
- if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) {
- psc->allocate = (__DRIallocateExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_MESA_allocate_memory");
- }
-#endif
-
-#ifdef __DRI_FRAME_TRACKING
- if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) {
- psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_MESA_swap_frame_usage");
- }
-#endif
-
-#ifdef __DRI_READ_DRAWABLE
- if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
- __glXEnableDirectExtension(psc, "GLX_SGI_make_current_read");
- }
-#endif
-
- /* Ignore unknown extensions */
- }
+ for (i = 0; configs[i]; i++)
+ free((__DRIconfig *) configs[i]);
+ free(configs);
}
#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h
index bb178db7875..f3da50ecf09 100644
--- a/src/glx/dri_common.h
+++ b/src/glx/dri_common.h
@@ -36,6 +36,8 @@
#ifndef _DRI_COMMON_H
#define _DRI_COMMON_H
+#include <GL/internal/dri_interface.h>
+
typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
struct __GLXDRIconfigPrivateRec
@@ -48,6 +50,8 @@ extern __GLcontextModes *driConvertConfigs(const __DRIcoreExtension * core,
__GLcontextModes * modes,
const __DRIconfig ** configs);
+extern void driDestroyConfigs(const __DRIconfig **configs);
+
extern const __DRIsystemTimeExtension systemTimeExtension;
extern void InfoMessageF(const char *f, ...);
@@ -56,8 +60,4 @@ extern void ErrorMessageF(const char *f, ...);
extern void *driOpenDriver(const char *driverName);
-extern void driBindExtensions(__GLXscreenConfigs * psc);
-extern void dri2BindExtensions(__GLXscreenConfigs * psc);
-extern void driBindCommonExtensions(__GLXscreenConfigs * psc);
-
#endif /* _DRI_COMMON_H */
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index 12a2cf3af24..fd14285a481 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -47,10 +47,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86drm.h"
#include "dri_common.h"
-typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
-typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
-
-struct __GLXDRIdisplayPrivateRec
+struct dri_display
{
__GLXDRIdisplay base;
@@ -62,14 +59,40 @@ struct __GLXDRIdisplayPrivateRec
int driPatch;
};
-struct __GLXDRIcontextPrivateRec
+struct dri_screen
+{
+ __GLXscreenConfigs base;
+
+ __DRIscreen *driScreen;
+ __GLXDRIscreen vtable;
+ const __DRIlegacyExtension *legacy;
+ const __DRIcoreExtension *core;
+ const __DRIswapControlExtension *swapControl;
+ const __DRImediaStreamCounterExtension *msc;
+ const __DRIconfig **driver_configs;
+ const __DRIcopySubBufferExtension *driCopySubBuffer;
+
+ void *driver;
+ int fd;
+};
+
+struct dri_context
{
- __GLXDRIcontext base;
+ __GLXcontext base;
+ __GLXDRIcontext dri_vtable;
__DRIcontext *driContext;
XID hwContextID;
- __GLXscreenConfigs *psc;
};
+struct dri_drawable
+{
+ __GLXDRIdrawable base;
+
+ __DRIdrawable *driDrawable;
+};
+
+static const struct glx_context_vtable dri_context_vtable;
+
/*
* Given a display pointer and screen number, determine the name of
* the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
@@ -293,8 +316,8 @@ static const __DRIextension *loader_extensions[] = {
* the client-side driver on success, or \c NULL on failure.
*/
static void *
-CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
- __GLXDRIdisplayPrivate * driDpy)
+CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
+ struct dri_display * driDpy)
{
void *psp = NULL;
drm_handle_t hSAREA;
@@ -424,8 +447,10 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
goto handle_error;
}
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+ psc->base.configs =
+ driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ psc->base.visuals =
+ driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
psc->driver_configs = driver_configs;
@@ -433,7 +458,7 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
* in the X server, so DRI1 can't render to them properly. Mark them as
* non-conformant to prevent apps from picking them up accidentally.
*/
- for (visual = psc->visuals; visual; visual = visual->next) {
+ for (visual = psc->base.visuals; visual; visual = visual->next) {
XVisualInfo template;
XVisualInfo *visuals;
int num_visuals;
@@ -474,52 +499,72 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
}
static void
-driDestroyContext(__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy)
+dri_destroy_context(__GLXcontext * context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+ struct dri_context *pcp = (struct dri_context *) context;
+ struct dri_screen *psc = (struct dri_screen *) context->psc;
+
+ if (context->xid)
+ glx_send_destroy_context(psc->base.dpy, context->xid);
+
+ if (context->extensions)
+ XFree((char *) context->extensions);
+
+ GarbageCollectDRIDrawables(context->psc);
(*psc->core->destroyContext) (pcp->driContext);
- XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+ XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
Xfree(pcp);
}
static Bool
-driBindContext(__GLXDRIcontext * context,
- __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
+driBindContext(__GLXcontext *context,
+ __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri_context *pcp = (struct dri_context *) context;
+ struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
+ struct dri_drawable *pdr = (struct dri_drawable *) draw;
+ struct dri_drawable *prd = (struct dri_drawable *) read;
- return (*core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ return (*psc->core->bindContext) (pcp->driContext,
+ pdr->driDrawable, prd->driDrawable);
}
static void
-driUnbindContext(__GLXDRIcontext * context)
+driUnbindContext(__GLXcontext * context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct dri_context *pcp = (struct dri_context *) context;
+ struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
- (*core->unbindContext) (pcp->driContext);
+ (*psc->core->unbindContext) (pcp->driContext);
}
-static __GLXDRIcontext *
-driCreateContext(__GLXscreenConfigs * psc,
- const __GLcontextModes * mode,
- GLXContext gc, GLXContext shareList, int renderType)
+static const struct glx_context_vtable dri_context_vtable = {
+ dri_destroy_context,
+ NULL,
+ NULL,
+ DRI_glXUseXFont,
+ NULL,
+ NULL,
+};
+
+static __GLXcontext *
+dri_create_context(__GLXscreenConfigs *base,
+ const __GLcontextModes *mode,
+ GLXContext shareList, int renderType)
{
- __GLXDRIcontextPrivate *pcp, *pcp_shared;
+ struct dri_context *pcp, *pcp_shared;
+ struct dri_screen *psc = (struct dri_screen *) base;
drm_context_t hwContext;
__DRIcontext *shared = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
- if (!psc || !psc->driScreen)
+ if (!psc->base.driScreen)
return NULL;
if (shareList) {
- pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+ pcp_shared = (struct dri_context *) shareList->driContext;
shared = pcp_shared->driContext;
}
@@ -527,8 +572,13 @@ driCreateContext(__GLXscreenConfigs * psc,
if (pcp == NULL)
return NULL;
- pcp->psc = psc;
- if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr,
+ memset(pcp, 0, sizeof *pcp);
+ if (!glx_context_init(&pcp->base, &psc->base, mode)) {
+ Xfree(pcp);
+ return NULL;
+ }
+
+ if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr,
mode->visualID,
&pcp->hwContextID, &hwContext)) {
Xfree(pcp);
@@ -536,18 +586,19 @@ driCreateContext(__GLXscreenConfigs * psc,
}
pcp->driContext =
- (*psc->legacy->createNewContext) (psc->__driScreen,
+ (*psc->legacy->createNewContext) (psc->driScreen,
config->driConfig,
renderType, shared, hwContext, pcp);
if (pcp->driContext == NULL) {
- XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+ XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
Xfree(pcp);
return NULL;
}
- pcp->base.destroyContext = driDestroyContext;
- pcp->base.bindContext = driBindContext;
- pcp->base.unbindContext = driUnbindContext;
+ 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;
}
@@ -555,63 +606,70 @@ driCreateContext(__GLXscreenConfigs * psc,
static void
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
- __GLXscreenConfigs *psc = pdraw->psc;
+ struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
- (*psc->core->destroyDrawable) (pdraw->driDrawable);
- XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);
+ (*psc->core->destroyDrawable) (pdp->driDrawable);
+ XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, pdraw->drawable);
Xfree(pdraw);
}
static __GLXDRIdrawable *
-driCreateDrawable(__GLXscreenConfigs * psc,
+driCreateDrawable(__GLXscreenConfigs *base,
XID xDrawable,
GLXDrawable drawable, const __GLcontextModes * modes)
{
- __GLXDRIdrawable *pdraw;
drm_drawable_t hwDrawable;
void *empty_attribute_list = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ struct dri_screen *psc = (struct dri_screen *) base;
+ struct dri_drawable *pdp;
/* Old dri can't handle GLX 1.3+ drawable constructors. */
if (xDrawable != drawable)
return NULL;
- pdraw = Xmalloc(sizeof(*pdraw));
- if (!pdraw)
+ pdp = Xmalloc(sizeof *pdp);
+ if (!pdp)
return NULL;
- pdraw->drawable = drawable;
- pdraw->psc = psc;
+ memset(pdp, 0, sizeof *pdp);
+ pdp->base.drawable = drawable;
+ pdp->base.psc = &psc->base;
- if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable)) {
- Xfree(pdraw);
+ if (!XF86DRICreateDrawable(psc->base.dpy, psc->base.scr,
+ drawable, &hwDrawable)) {
+ Xfree(pdp);
return NULL;
}
/* Create a new drawable */
- pdraw->driDrawable =
- (*psc->legacy->createNewDrawable) (psc->__driScreen,
+ pdp->driDrawable =
+ (*psc->legacy->createNewDrawable) (psc->driScreen,
config->driConfig,
hwDrawable,
GLX_WINDOW_BIT,
- empty_attribute_list, pdraw);
+ empty_attribute_list, pdp);
- if (!pdraw->driDrawable) {
- XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
- Xfree(pdraw);
+ if (!pdp->driDrawable) {
+ XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, drawable);
+ Xfree(pdp);
return NULL;
}
- pdraw->destroyDrawable = driDestroyDrawable;
+ pdp->base.destroyDrawable = driDestroyDrawable;
- return pdraw;
+ return &pdp->base;
}
static int64_t
driSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2,
int64_t unused3)
{
- (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
+ struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+
+ (*psc->core->swapBuffers) (pdp->driDrawable);
return 0;
}
@@ -619,56 +677,189 @@ static void
driCopySubBuffer(__GLXDRIdrawable * pdraw,
int x, int y, int width, int height)
{
- (*pdraw->psc->driCopySubBuffer->copySubBuffer) (pdraw->driDrawable,
- x, y, width, height);
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+ struct dri_screen *psc = (struct dri_screen *) pdp->base.psc;
+
+ (*psc->driCopySubBuffer->copySubBuffer) (pdp->driDrawable,
+ x, y, width, height);
}
static void
-driDestroyScreen(__GLXscreenConfigs * psc)
+driDestroyScreen(__GLXscreenConfigs *base)
{
+ struct dri_screen *psc = (struct dri_screen *) base;
+
/* Free the direct rendering per screen data */
- if (psc->__driScreen)
- (*psc->core->destroyScreen) (psc->__driScreen);
- psc->__driScreen = NULL;
+ if (psc->driScreen)
+ (*psc->core->destroyScreen) (psc->driScreen);
+ driDestroyConfigs(psc->driver_configs);
+ psc->driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
-static const struct glx_context_vtable dri_context_vtable = {
- NULL,
- NULL,
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+
+static int
+driDrawableGetMSC(__GLXscreenConfigs *base, __GLXDRIdrawable *pdraw,
+ int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+ struct dri_screen *psc = (struct dri_screen *) base;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+
+ if (pdp && psc->sbc && psc->msc)
+ return ( (*psc->msc->getMSC)(psc->driScreen, msc) == 0 &&
+ (*psc->sbc->getSBC)(pdp->driDrawable, sbc) == 0 &&
+ __glXGetUST(ust) == 0 );
+}
+
+static int
+driWaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
+ int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+ struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+
+ if (pdp != NULL && psc->msc != NULL) {
+ ret = (*psc->msc->waitForMSC) (pdp->driDrawable, target_msc,
+ divisor, remainder, msc, sbc);
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return ret == 0 && __glXGetUST(ust) == 0;
+ }
+}
+
+static int
+driWaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
+ int64_t *msc, int64_t *sbc)
+{
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+
+ if (pdp != NULL && psc->sbc != NULL) {
+ ret =
+ (*psc->sbc->waitForSBC) (pdp->driDrawable, target_sbc, msc, sbc);
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return ((ret == 0) && (__glXGetUST(ust) == 0));
+ }
+
+ return DRI2WaitSBC(pdp->base.psc->dpy,
+ pdp->base.xDrawable, target_sbc, ust, msc, sbc);
+}
+
+#endif
+
+static int
+driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+ struct dri_screen *psc;
+
+ if (gc->driContext) {
+ psc = (struct dri_screen *) pdraw->psc;
+
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
+ return 0;
+ }
+ }
+
+ return GLX_BAD_CONTEXT;
+}
+
+static int
+driGetSwapInterval(__GLXDRIdrawable *pdraw)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+ struct dri_screen *psc;
+
+ if (gc != NULL && gc->driContext) {
+ psc = (struct dri_screen *) pdraw->psc;
+
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ return psc->swapControl->getSwapInterval(pdp->driDrawable);
+ }
+ }
+
+ return 0;
+}
+
+/* Bind DRI1 specific extensions */
+static void
+driBindExtensions(struct dri_screen *psc, const __DRIextension **extensions)
+{
+ int i;
+
+ for (i = 0; extensions[i]; i++) {
+ /* No DRI2 support for swap_control at the moment, since SwapBuffers
+ * is done by the X server */
+ if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
+ psc->swapControl = (__DRIswapControlExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control");
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control");
+ }
+
+ if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
+ psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");
+ }
+
+ if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
+ psc->driCopySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
+ }
+
+ if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
+ }
+ /* Ignore unknown extensions */
+ }
+}
+
+static const struct glx_screen_vtable dri_screen_vtable = {
+ dri_create_context
};
-static __GLXDRIscreen *
-driCreateScreen(__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv)
+static __GLXscreenConfigs *
+driCreateScreen(int screen, __GLXdisplayPrivate *priv)
{
- __GLXDRIdisplayPrivate *pdp;
+ struct dri_display *pdp;
__GLXDRIscreen *psp;
const __DRIextension **extensions;
+ struct dri_screen *psc;
char *driverName;
int i;
- psp = Xcalloc(1, sizeof *psp);
- if (psp == NULL)
+ psc = Xcalloc(1, sizeof *psc);
+ if (psc == NULL)
return NULL;
+ memset(psc, 0, sizeof *psc);
+ if (!glx_screen_init(&psc->base, screen, priv))
+ return NULL;
+
if (!driGetDriverName(priv->dpy, screen, &driverName)) {
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
psc->driver = driOpenDriver(driverName);
Xfree(driverName);
if (psc->driver == NULL) {
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
@@ -680,34 +871,42 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
}
if (psc->core == NULL || psc->legacy == NULL) {
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
- pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay;
- psc->__driScreen = CallCreateNewScreen(psc->dpy, screen, psc, pdp);
- if (psc->__driScreen == NULL) {
+ pdp = (struct dri_display *) priv->driDisplay;
+ psc->driScreen =
+ CallCreateNewScreen(psc->base.dpy, screen, psc, pdp);
+ if (psc->driScreen == NULL) {
dlclose(psc->driver);
- Xfree(psp);
+ Xfree(psc);
return NULL;
}
- driBindExtensions(psc);
- driBindCommonExtensions(psc);
+ extensions = psc->core->getExtensions(psc->driScreen);
+ driBindExtensions(psc, extensions);
+ psc->base.vtable = &dri_screen_vtable;
+ psp = &psc->vtable;
+ psc->base.driScreen = psp;
if (psc->driCopySubBuffer)
psp->copySubBuffer = driCopySubBuffer;
psp->destroyScreen = driDestroyScreen;
- psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
psp->swapBuffers = driSwapBuffers;
- psp->waitX = NULL;
- psp->waitGL = NULL;
- psc->direct_context_vtable = &dri_context_vtable;
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+ psp->getDrawableMSC = driDrawableGetMSC;
+ psp->waitForMSC = driWaitForMSC;
+ psp->waitForSBC = driWaitForSBC;
+#endif
- return psp;
+ psp->setSwapInterval = driSetSwapInterval;
+ psp->getSwapInterval = driGetSwapInterval;
+
+ return &psc->base;
}
/* Called from __glXFreeDisplayPrivate.
@@ -726,7 +925,7 @@ driDestroyDisplay(__GLXDRIdisplay * dpy)
_X_HIDDEN __GLXDRIdisplay *
driCreateDisplay(Display * dpy)
{
- __GLXDRIdisplayPrivate *pdpyp;
+ struct dri_display *pdpyp;
int eventBase, errorBase;
int major, minor, patch;
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index cdb1d9f4dc3..5f7185de4c8 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -28,35 +28,46 @@
#include <dlfcn.h>
#include "dri_common.h"
-typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
-typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
-typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
-
-struct __GLXDRIdisplayPrivateRec
+struct drisw_display
{
__GLXDRIdisplay base;
};
-struct __GLXDRIcontextPrivateRec
+struct drisw_context
{
- __GLXDRIcontext base;
+ __GLXcontext base;
+ __GLXDRIcontext dri_vtable;
__DRIcontext *driContext;
- __GLXscreenConfigs *psc;
+
};
-struct __GLXDRIdrawablePrivateRec
+struct drisw_screen
+{
+ __GLXscreenConfigs base;
+
+ __DRIscreen *driScreen;
+ __GLXDRIscreen vtable;
+ const __DRIcoreExtension *core;
+ const __DRIswrastExtension *swrast;
+ const __DRIconfig **driver_configs;
+
+ void *driver;
+};
+
+struct drisw_drawable
{
__GLXDRIdrawable base;
GC gc;
GC swapgc;
+ __DRIdrawable *driDrawable;
XVisualInfo *visinfo;
XImage *ximage;
};
static Bool
-XCreateDrawable(__GLXDRIdrawablePrivate * pdp,
+XCreateDrawable(struct drisw_drawable * pdp,
Display * dpy, XID drawable, int visualid)
{
XGCValues gcvalues;
@@ -94,7 +105,7 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp,
}
static void
-XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable)
+XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable)
{
XDestroyImage(pdp->ximage);
XFree(pdp->visinfo);
@@ -112,7 +123,7 @@ swrastGetDrawableInfo(__DRIdrawable * draw,
int *x, int *y, int *w, int *h,
void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+ struct drisw_drawable *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
@@ -156,7 +167,7 @@ swrastPutImage(__DRIdrawable * draw, int op,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+ struct drisw_drawable *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
@@ -192,7 +203,7 @@ swrastGetImage(__DRIdrawable * read,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *prp = loaderPrivate;
+ struct drisw_drawable *prp = loaderPrivate;
__GLXDRIdrawable *pread = &(prp->base);
Display *dpy = pread->psc->dpy;
Drawable readable;
@@ -229,54 +240,70 @@ static const __DRIextension *loader_extensions[] = {
*/
static void
-driDestroyContext(__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy)
+drisw_destroy_context(__GLXcontext *context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct drisw_context *pcp = (struct drisw_context *) context;
+ struct drisw_screen *psc = (struct drisw_screen *) context->psc;
+
+ if (context->xid)
+ glx_send_destroy_context(psc->base.dpy, context->xid);
- (*core->destroyContext) (pcp->driContext);
+ if (context->extensions)
+ XFree((char *) context->extensions);
+
+ GarbageCollectDRIDrawables(context->psc);
+
+ (*psc->core->destroyContext) (pcp->driContext);
Xfree(pcp);
}
static Bool
-driBindContext(__GLXDRIcontext * context,
- __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
+driBindContext(__GLXcontext * context,
+ __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct drisw_context *pcp = (struct drisw_context *) context;
+ struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
+ struct drisw_drawable *pdr = (struct drisw_drawable *) draw;
+ struct drisw_drawable *prd = (struct drisw_drawable *) read;
- return (*core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ return (*psc->core->bindContext) (pcp->driContext,
+ pdr->driDrawable, prd->driDrawable);
}
static void
-driUnbindContext(__GLXDRIcontext * context)
+driUnbindContext(__GLXcontext * context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ struct drisw_context *pcp = (struct drisw_context *) context;
+ struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
- (*core->unbindContext) (pcp->driContext);
+ (*psc->core->unbindContext) (pcp->driContext);
}
-static __GLXDRIcontext *
-driCreateContext(__GLXscreenConfigs * psc,
- const __GLcontextModes * mode,
- GLXContext gc, GLXContext shareList, int renderType)
+static const struct glx_context_vtable drisw_context_vtable = {
+ drisw_destroy_context,
+ NULL,
+ NULL,
+ DRI_glXUseXFont,
+ NULL,
+ NULL,
+};
+
+static __GLXcontext *
+drisw_create_context(__GLXscreenConfigs *base,
+ const __GLcontextModes *mode,
+ GLXContext shareList, int renderType)
{
- __GLXDRIcontextPrivate *pcp, *pcp_shared;
+ struct drisw_context *pcp, *pcp_shared;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
- const __DRIcoreExtension *core;
+ struct drisw_screen *psc = (struct drisw_screen *) base;
__DRIcontext *shared = NULL;
- if (!psc || !psc->driScreen)
+ if (!psc->base.driScreen)
return NULL;
- core = psc->core;
-
if (shareList) {
- pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+ pcp_shared = (struct drisw_context *) shareList->driContext;
shared = pcp_shared->driContext;
}
@@ -284,18 +311,24 @@ driCreateContext(__GLXscreenConfigs * psc,
if (pcp == NULL)
return NULL;
- pcp->psc = psc;
+ memset(pcp, 0, sizeof *pcp);
+ if (!glx_context_init(&pcp->base, &psc->base, mode)) {
+ Xfree(pcp);
+ return NULL;
+ }
+
pcp->driContext =
- (*core->createNewContext) (psc->__driScreen,
- config->driConfig, shared, pcp);
+ (*psc->core->createNewContext) (psc->driScreen,
+ config->driConfig, shared, pcp);
if (pcp->driContext == NULL) {
Xfree(pcp);
return NULL;
}
- pcp->base.destroyContext = driDestroyContext;
- pcp->base.bindContext = driBindContext;
- pcp->base.unbindContext = driUnbindContext;
+ 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;
}
@@ -303,23 +336,23 @@ driCreateContext(__GLXscreenConfigs * psc,
static void
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
- __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw;
- const __DRIcoreExtension *core = pdraw->psc->core;
+ struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
+ struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
- (*core->destroyDrawable) (pdraw->driDrawable);
+ (*psc->core->destroyDrawable) (pdp->driDrawable);
XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
Xfree(pdp);
}
static __GLXDRIdrawable *
-driCreateDrawable(__GLXscreenConfigs * psc,
- XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
+ GLXDrawable drawable, const __GLcontextModes * modes)
{
- __GLXDRIdrawable *pdraw;
- __GLXDRIdrawablePrivate *pdp;
+ struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ struct drisw_screen *psc = (struct drisw_screen *) base;
+
const __DRIswrastExtension *swrast = psc->swrast;
/* Old dri can't handle GLX 1.3+ drawable constructors. */
@@ -330,47 +363,53 @@ driCreateDrawable(__GLXscreenConfigs * psc,
if (!pdp)
return NULL;
- pdraw = &(pdp->base);
- pdraw->xDrawable = xDrawable;
- pdraw->drawable = drawable;
- pdraw->psc = psc;
+ memset(pdp, 0, sizeof *pdp);
+ pdp->base.xDrawable = xDrawable;
+ pdp->base.drawable = drawable;
+ pdp->base.psc = &psc->base;
- XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);
+ XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
/* Create a new drawable */
- pdraw->driDrawable =
- (*swrast->createNewDrawable) (psc->__driScreen, config->driConfig, pdp);
+ pdp->driDrawable =
+ (*swrast->createNewDrawable) (psc->driScreen, config->driConfig, pdp);
- if (!pdraw->driDrawable) {
- XDestroyDrawable(pdp, psc->dpy, xDrawable);
+ if (!pdp->driDrawable) {
+ XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
Xfree(pdp);
return NULL;
}
- pdraw->destroyDrawable = driDestroyDrawable;
+ pdp->base.destroyDrawable = driDestroyDrawable;
- return pdraw;
+ return &pdp->base;
}
static int64_t
driSwapBuffers(__GLXDRIdrawable * pdraw,
int64_t target_msc, int64_t divisor, int64_t remainder)
{
+ struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
+ struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
+
(void) target_msc;
(void) divisor;
(void) remainder;
- (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
+ (*psc->core->swapBuffers) (pdp->driDrawable);
return 0;
}
static void
-driDestroyScreen(__GLXscreenConfigs * psc)
+driDestroyScreen(__GLXscreenConfigs *base)
{
+ struct drisw_screen *psc = (struct drisw_screen *) base;
+
/* Free the direct rendering per screen data */
- (*psc->core->destroyScreen) (psc->__driScreen);
- psc->__driScreen = NULL;
+ (*psc->core->destroyScreen) (psc->driScreen);
+ driDestroyConfigs(psc->driver_configs);
+ psc->driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
@@ -389,19 +428,27 @@ driOpenSwrast(void)
return driver;
}
-static __GLXDRIscreen *
-driCreateScreen(__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv)
+static const struct glx_screen_vtable drisw_screen_vtable = {
+ drisw_create_context
+};
+
+static __GLXscreenConfigs *
+driCreateScreen(int screen, __GLXdisplayPrivate *priv)
{
__GLXDRIscreen *psp;
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
+ struct drisw_screen *psc;
int i;
- psp = Xcalloc(1, sizeof *psp);
- if (psp == NULL)
+ psc = Xcalloc(1, sizeof *psc);
+ if (psc == NULL)
return NULL;
+ memset(psc, 0, sizeof *psc);
+ if (!glx_screen_init(&psc->base, screen, priv))
+ return NULL;
+
psc->driver = driOpenSwrast();
if (psc->driver == NULL)
goto handle_error;
@@ -414,9 +461,9 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
- psc->core = (__DRIcoreExtension *) extensions[i];
+ psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
- psc->swrast = (__DRIswrastExtension *) extensions[i];
+ psc->swrast = (__DRIswrastExtension *) extensions[i];
}
if (psc->core == NULL || psc->swrast == NULL) {
@@ -424,33 +471,34 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
goto handle_error;
}
- psc->__driScreen =
- psc->swrast->createNewScreen(screen,
- loader_extensions, &driver_configs, psc);
- if (psc->__driScreen == NULL) {
+ psc->driScreen =
+ psc->swrast->createNewScreen(screen, loader_extensions,
+ &driver_configs, psc);
+ if (psc->driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
- driBindExtensions(psc);
- driBindCommonExtensions(psc);
+ extensions = psc->core->getExtensions(psc->driScreen);
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+ psc->base.configs =
+ driConvertConfigs(psc->core, psc->base.configs, driver_configs);
+ psc->base.visuals =
+ driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
psc->driver_configs = driver_configs;
+ psc->base.vtable = &drisw_screen_vtable;
+ psp = &psc->vtable;
+ psc->base.driScreen = psp;
psp->destroyScreen = driDestroyScreen;
- psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
psp->swapBuffers = driSwapBuffers;
- psp->waitX = NULL;
- psp->waitGL = NULL;
- return psp;
+ return &psc->base;
handle_error:
- Xfree(psp);
+ Xfree(psc);
if (psc->driver)
dlclose(psc->driver);
@@ -476,7 +524,7 @@ driDestroyDisplay(__GLXDRIdisplay * dpy)
_X_HIDDEN __GLXDRIdisplay *
driswCreateDisplay(Display * dpy)
{
- __GLXDRIdisplayPrivate *pdpyp;
+ struct drisw_display *pdpyp;
pdpyp = Xmalloc(sizeof *pdpyp);
if (pdpyp == NULL)
diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index b8d0f21bf06..02809aacfa5 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -86,13 +86,17 @@ ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
const CARD32 * attribs, size_t num_attribs)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ __GLXDRIdrawable *pdraw;
CARD32 *output;
CARD8 opcode;
+ int i;
if ((dpy == NULL) || (drawable == 0)) {
return;
}
+ pdraw = GetGLXDRIDrawable(dpy, drawable);
+
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
@@ -129,6 +133,15 @@ ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
UnlockDisplay(dpy);
SyncHandle();
+ for (i = 0; i < num_attribs; i++) {
+ switch(attribs[i * 2]) {
+ case GLX_EVENT_MASK:
+ /* Keep a local copy for masking out DRI2 proto events as needed */
+ pdraw->eventMask = attribs[i * 2 + 1];
+ break;
+ }
+ }
+
return;
}
@@ -178,7 +191,7 @@ CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig,
__GLXDRIdrawable *pdraw;
__GLXscreenConfigs *psc;
- psc = &priv->screenConfigs[fbconfig->screen];
+ psc = priv->screenConfigs[fbconfig->screen];
if (psc->driScreen == NULL)
return;
@@ -189,7 +202,7 @@ CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig,
return;
}
- if (__glxHashInsert(psc->drawHash, glxdrawable, pdraw)) {
+ if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return; /* FIXME: Check what we're supposed to do here... */
}
@@ -201,16 +214,14 @@ CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig,
static void
DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
{
- int screen;
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
if (destroy_xdrawable)
- XFreePixmap(psc->dpy, pdraw->xDrawable);
+ XFreePixmap(pdraw->psc->dpy, pdraw->xDrawable);
(*pdraw->destroyDrawable) (pdraw);
- __glxHashDelete(psc->drawHash, drawable);
+ __glxHashDelete(priv->drawHash, drawable);
}
}
@@ -328,7 +339,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL && !pdraw->textureTarget)
pdraw->textureTarget =
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 78c5f33d4d5..48b5501fe9e 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -37,8 +37,6 @@
#ifndef _GLX_client_h_
#define _GLX_client_h_
-#define NEED_REPLIES
-#define NEED_EVENTS
#include <X11/Xproto.h>
#include <X11/Xlibint.h>
#include <X11/extensions/extutil.h>
@@ -97,14 +95,13 @@ typedef struct _glapi_table __GLapi;
#define containerOf(ptr, type, member) \
(type *)( (char *)ptr - offsetof(type,member) )
-extern void DRI_glXUseXFont(Font font, int first, int count, int listbase);
+extern void DRI_glXUseXFont(GLXContext CC,
+ Font font, int first, int count, int listbase);
#endif
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-#include <GL/internal/dri_interface.h>
-
/**
* Display dependent methods. This structure is initialized during the
* \c driCreateDisplay call.
@@ -123,18 +120,16 @@ struct __GLXDRIdisplayRec
*/
void (*destroyDisplay) (__GLXDRIdisplay * display);
- __GLXDRIscreen *(*createScreen) (__GLXscreenConfigs * psc, int screen,
- __GLXdisplayPrivate * priv);
+ __GLXscreenConfigs *(*createScreen)(int screen, __GLXdisplayPrivate * priv);
};
struct __GLXDRIscreenRec {
void (*destroyScreen)(__GLXscreenConfigs *psc);
- __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
- GLXContext gc,
- GLXContext shareList, int renderType);
+ __GLXcontext *(*createContext)(__GLXscreenConfigs *psc,
+ const __GLcontextModes *mode,
+ GLXContext shareList, int renderType);
__GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
XID drawable,
@@ -145,8 +140,6 @@ struct __GLXDRIscreenRec {
int64_t divisor, int64_t remainder);
void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
int x, int y, int width, int height);
- void (*waitX)(__GLXDRIdrawable *pdraw);
- void (*waitGL)(__GLXDRIdrawable *pdraw);
int (*getDrawableMSC)(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
int64_t *ust, int64_t *msc, int64_t *sbc);
int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc,
@@ -154,18 +147,15 @@ struct __GLXDRIscreenRec {
int64_t *msc, int64_t *sbc);
int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc);
- void (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
+ int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
};
struct __GLXDRIcontextRec
{
- void (*destroyContext) (__GLXDRIcontext * context,
- __GLXscreenConfigs * psc, Display * dpy);
- Bool(*bindContext) (__GLXDRIcontext * context, __GLXDRIdrawable * pdraw,
- __GLXDRIdrawable * pread);
-
- void (*unbindContext) (__GLXDRIcontext * context);
+ Bool(*bindContext) (__GLXcontext *context, __GLXDRIdrawable *pdraw,
+ __GLXDRIdrawable *pread);
+ void (*unbindContext) (__GLXcontext *context);
};
struct __GLXDRIdrawableRec
@@ -176,8 +166,8 @@ struct __GLXDRIdrawableRec
XID drawable;
__GLXscreenConfigs *psc;
GLenum textureTarget;
- __DRIdrawable *driDrawable;
GLenum textureFormat; /* EXT_texture_from_pixmap support */
+ unsigned long eventMask;
};
/*
@@ -250,6 +240,11 @@ typedef struct __GLXattributeMachineRec
} __GLXattributeMachine;
struct glx_context_vtable {
+ void (*destroy)(__GLXcontext *ctx);
+ void (*wait_gl)(__GLXcontext *ctx);
+ void (*wait_x)(__GLXcontext *ctx);
+ void (*use_x_font)(__GLXcontext *ctx,
+ Font font, int first, int count, int listBase);
void (*bind_tex_image)(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list);
@@ -257,6 +252,9 @@ struct glx_context_vtable {
};
+extern void
+glx_send_destroy_context(Display *dpy, XID xid);
+
/**
* GLX state that needs to be kept on the client. One of these records
* exist for each context that has been made current by this client.
@@ -394,11 +392,6 @@ struct __GLXcontextRec
/*@} */
/**
- * Record the dpy this context was created on for later freeing
- */
- Display *createDpy;
-
- /**
* Maximum small render command size. This is the smaller of 64k and
* the size of the above buffer.
*/
@@ -421,7 +414,6 @@ struct __GLXcontextRec
Bool do_destroy;
#else
__GLXDRIcontext *driContext;
- __DRIcontext *__driContext;
#endif
#endif
@@ -469,6 +461,10 @@ struct __GLXcontextRec
const struct glx_context_vtable *vtable;
};
+extern Bool
+glx_context_init(__GLXcontext *gc,
+ __GLXscreenConfigs *psc, const __GLcontextModes *fbconfig);
+
#define __glXSetError(gc,code) \
if (!(gc)->error) { \
(gc)->error = code; \
@@ -508,8 +504,16 @@ extern void __glFreeAttributeState(__GLXcontext *);
* One of these records exists per screen of the display. It contains
* a pointer to the config data for that screen (if the screen supports GL).
*/
+struct glx_screen_vtable {
+ __GLXcontext *(*create_context)(__GLXscreenConfigs *psc,
+ const __GLcontextModes *mode,
+ GLXContext shareList, int renderType);
+};
+
struct __GLXscreenConfigsRec
{
+ const struct glx_screen_vtable *vtable;
+
/**
* GLX extension string reported by the X-server.
*/
@@ -521,61 +525,16 @@ struct __GLXscreenConfigsRec
*/
char *effectiveGLXexts;
- /**
- * Context vtable to use for direct contexts on this screen
- */
- const struct glx_context_vtable *direct_context_vtable;
+ __GLXdisplayPrivate *display;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
* Per screen direct rendering interface functions and data.
*/
- __DRIscreen *__driScreen;
- const __DRIcoreExtension *core;
- const __DRIlegacyExtension *legacy;
- const __DRIswrastExtension *swrast;
- const __DRIdri2Extension *dri2;
- __glxHashTable *drawHash;
Display *dpy;
- int scr, fd;
- void *driver;
+ int scr;
__GLXDRIscreen *driScreen;
-
- const __DRIconfig **driver_configs;
-
-#ifdef __DRI_COPY_SUB_BUFFER
- const __DRIcopySubBufferExtension *driCopySubBuffer;
-#endif
-
-#ifdef __DRI_SWAP_CONTROL
- const __DRIswapControlExtension *swapControl;
-#endif
-
-#ifdef __DRI_ALLOCATE
- const __DRIallocateExtension *allocate;
-#endif
-
-#ifdef __DRI_FRAME_TRACKING
- const __DRIframeTrackingExtension *frameTracking;
-#endif
-
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- const __DRImediaStreamCounterExtension *msc;
-#endif
-
-#ifdef __DRI_TEX_BUFFER
- const __DRItexBufferExtension *texBuffer;
-#endif
-
-#ifdef __DRI2_FLUSH
- const __DRI2flushExtension *f;
-#endif
-
-#ifdef __DRI2_CONFIG_QUERY
- const __DRI2configQueryExtension *config;
-#endif
-
#endif
/**
@@ -603,6 +562,10 @@ struct __GLXscreenConfigsRec
*/
struct __GLXdisplayPrivateRec
{
+ /* The extension protocol codes */
+ XExtCodes *codes;
+ struct __GLXdisplayPrivateRec *next;
+
/**
* Back pointer to the display
*/
@@ -639,9 +602,11 @@ struct __GLXdisplayPrivateRec
* Also, per screen data which now includes the server \c GLX_EXTENSION
* string.
*/
- __GLXscreenConfigs *screenConfigs;
+ __GLXscreenConfigs **screenConfigs;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+ __glxHashTable *drawHash;
+
/**
* Per display direct rendering interface functions and data.
*/
@@ -651,6 +616,14 @@ struct __GLXdisplayPrivateRec
#endif
};
+extern int
+glx_screen_init(__GLXscreenConfigs *psc,
+ int screen, __GLXdisplayPrivate * priv);
+
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+extern __GLXDRIdrawable *
+dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
+#endif
extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *);
@@ -698,8 +671,6 @@ extern __GLXcontext *__glXcurrentContext;
extern void __glXSetCurrentContextNull(void);
-extern void __glXFreeContext(__GLXcontext *);
-
/*
** Global lock for all threads in this address space using the GLX
@@ -820,17 +791,23 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * denominator);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-GLboolean
-__driGetMscRateOML(__DRIdrawable * draw,
- int32_t * numerator, int32_t * denominator, void *private);
+extern GLboolean
+__glxGetMscRate(__GLXDRIdrawable *glxDraw,
+ int32_t * numerator, int32_t * denominator);
/* So that dri2.c:DRI2WireToEvent() can access
* glx_info->codes->first_event */
XExtDisplayInfo *__glXFindDisplay (Display *dpy);
+extern void
+GarbageCollectDRIDrawables(__GLXscreenConfigs *psc);
+
extern __GLXDRIdrawable *
-GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int *const scrn_num);
+GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable);
#endif
+extern __GLXscreenConfigs *
+indirect_create_screen(int screen, __GLXdisplayPrivate * priv);
+
#endif /* !__GLX_client_h__ */
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 16c4eef6ba8..0782b1d70f2 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -62,7 +62,7 @@
static const char __glXGLXClientVendorName[] = "Mesa Project and SGI";
static const char __glXGLXClientVersion[] = "1.4";
-static const struct glx_context_vtable glx_indirect_context_vtable;
+static const struct glx_context_vtable indirect_context_vtable;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
@@ -85,33 +85,34 @@ windowExistsErrorHandler(Display * dpy, XErrorEvent * xerr)
* \param dpy Display to destroy drawables for
* \param screen Screen number to destroy drawables for
*/
-static void
-GarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc)
+_X_HIDDEN void
+GarbageCollectDRIDrawables(__GLXscreenConfigs * sc)
{
XID draw;
__GLXDRIdrawable *pdraw;
+ __GLXdisplayPrivate *priv = sc->display;
XWindowAttributes xwa;
int (*oldXErrorHandler) (Display *, XErrorEvent *);
/* Set no-op error handler so Xlib doesn't bail out if the windows
* has alreay been destroyed on the server. */
- XSync(dpy, GL_FALSE);
+ XSync(priv->dpy, GL_FALSE);
oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
- if (__glxHashFirst(sc->drawHash, &draw, (void *) &pdraw) == 1) {
+ if (__glxHashFirst(priv->drawHash, &draw, (void *) &pdraw) == 1) {
do {
windowExistsFlag = GL_TRUE;
- XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+ XGetWindowAttributes(priv->dpy, draw, &xwa); /* dummy request */
if (!windowExistsFlag) {
/* Destroy the local drawable data, if the drawable no
longer exists in the Xserver */
(*pdraw->destroyDrawable) (pdraw);
- __glxHashDelete(sc->drawHash, draw);
+ __glxHashDelete(priv->drawHash, draw);
}
- } while (__glxHashNext(sc->drawHash, &draw, (void *) &pdraw) == 1);
+ } while (__glxHashNext(priv->drawHash, &draw, (void *) &pdraw) == 1);
}
- XSync(dpy, GL_FALSE);
+ XSync(priv->dpy, GL_FALSE);
XSetErrorHandler(oldXErrorHandler);
}
@@ -125,28 +126,16 @@ GarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc)
* the drawable is not associated with a direct-rendering context.
*/
_X_HIDDEN __GLXDRIdrawable *
-GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable, int *const scrn_num)
+GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
- const unsigned screen_count = ScreenCount(dpy);
- unsigned i;
- __GLXscreenConfigs *psc;
if (priv == NULL)
return NULL;
- for (i = 0; i < screen_count; i++) {
- psc = &priv->screenConfigs[i];
- if (psc->drawHash == NULL)
- continue;
-
- if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) {
- if (scrn_num != NULL)
- *scrn_num = i;
- return pdraw;
- }
- }
+ if (__glxHashLookup(priv->drawHash, drawable, (void *) &pdraw) == 0)
+ return pdraw;
return NULL;
}
@@ -175,7 +164,7 @@ GetGLXScreenConfigs(Display * dpy, int scrn)
return (priv
&& priv->screenConfigs !=
- NULL) ? &priv->screenConfigs[scrn] : NULL;
+ NULL) ? priv->screenConfigs[scrn] : NULL;
}
@@ -202,7 +191,7 @@ GetGLXPrivScreenConfig(Display * dpy, int scrn, __GLXdisplayPrivate ** ppriv,
}
/* Check to see if the GL is supported on this screen */
- *ppsc = &((*ppriv)->screenConfigs[scrn]);
+ *ppsc = (*ppriv)->screenConfigs[scrn];
if ((*ppsc)->configs == NULL) {
/* No support for GL on this screen regardless of visual */
return GLX_BAD_VISUAL;
@@ -233,7 +222,7 @@ ValidateGLXFBConfig(Display * dpy, GLXFBConfig config)
if (priv != NULL) {
for (i = 0; i < num_screens; i++) {
- for (modes = priv->screenConfigs[i].configs; modes != NULL;
+ for (modes = priv->screenConfigs[i]->configs; modes != NULL;
modes = modes->next) {
if (modes == (__GLcontextModes *) config) {
return (__GLcontextModes *) config;
@@ -245,6 +234,55 @@ ValidateGLXFBConfig(Display * dpy, GLXFBConfig config)
return NULL;
}
+#ifdef GLX_USE_APPLEGL
+
+static const struct glx_context_vtable applegl_context_vtable;
+
+static __GLcontext *
+applegl_create_context(__GLXscreenConfigs *psc,
+ const __GLcontextModes *mode,
+ GLXContext shareList, int renderType)
+{
+ __GLXcontext *gc;
+ int errorcode;
+ bool x11error;
+
+ /* TODO: Integrate this with apple_glx_create_context and make
+ * struct apple_glx_context inherit from __GLXcontext. */
+
+ gc = Xmalloc(sizeof *gc);
+ if (pcp == NULL)
+ return NULL;
+
+ memset(gc, 0, sizeof *gc);
+ if (!glx_context_init(&gc->base, &psc->base, mode)) {
+ Xfree(gc);
+ return NULL;
+ }
+
+ gc->vtable = &applegl_context_vtable;
+ gc->driContext = NULL;
+ gc->do_destroy = False;
+
+ /* TODO: darwin: Integrate with above to do indirect */
+ if(apple_glx_create_context(&gc->driContext, dpy, screen, fbconfig,
+ shareList ? shareList->driContext : NULL,
+ &errorcode, &x11error)) {
+ __glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
+ gc->vtable->destroy(gc);
+ return NULL;
+ }
+
+ gc->currentContextTag = -1;
+ gc->mode = fbconfig;
+ gc->isDirect = allowDirect;
+ gc->xid = 1; /* Just something not None, so we know when to destroy
+ * it in MakeContextCurrent. */
+
+ return gc;
+}
+#endif
+
/**
* \todo It should be possible to move the allocate of \c client_state_private
@@ -257,17 +295,16 @@ ValidateGLXFBConfig(Display * dpy, GLXFBConfig config)
* does all the initialization (including the pixel pack / unpack).
*/
static GLXContext
-AllocateGLXContext(Display * dpy)
+indirect_create_context(__GLXscreenConfigs *psc,
+ const __GLcontextModes *mode,
+ GLXContext shareList, int renderType)
{
GLXContext gc;
int bufSize;
CARD8 opcode;
__GLXattribute *state;
- if (!dpy)
- return NULL;
-
- opcode = __glXSetupForCommand(dpy);
+ opcode = __glXSetupForCommand(psc->dpy);
if (!opcode) {
return NULL;
}
@@ -280,6 +317,9 @@ AllocateGLXContext(Display * dpy)
}
memset(gc, 0, sizeof(struct __GLXcontextRec));
+ glx_context_init(gc, psc, mode);
+ gc->isDirect = GL_FALSE;
+ gc->vtable = &indirect_context_vtable;
state = Xmalloc(sizeof(struct __GLXattributeRec));
if (state == NULL) {
/* Out of memory */
@@ -297,7 +337,7 @@ AllocateGLXContext(Display * dpy)
** packet for the GLXRenderReq header.
*/
- bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq;
+ bufSize = (XMaxRequestSize(psc->dpy) * 4) - sz_xGLXRenderReq;
gc->buf = (GLubyte *) Xmalloc(bufSize);
if (!gc->buf) {
Xfree(gc->client_state_private);
@@ -333,7 +373,6 @@ AllocateGLXContext(Display * dpy)
else {
gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
}
- gc->createDpy = dpy;
gc->majorOpcode = opcode;
/*
@@ -350,14 +389,47 @@ AllocateGLXContext(Display * dpy)
}
gc->maxSmallRenderCommandSize = bufSize;
-#ifdef GLX_USE_APPLEGL
- gc->driContext = NULL;
- gc->do_destroy = False;
-#endif
return gc;
}
+struct glx_screen_vtable indirect_screen_vtable = {
+ indirect_create_context
+};
+
+_X_HIDDEN __GLXscreenConfigs *
+indirect_create_screen(int screen, __GLXdisplayPrivate * priv)
+{
+ __GLXscreenConfigs *psc;
+
+ psc = Xmalloc(sizeof *psc);
+ if (psc == NULL)
+ return NULL;
+
+ memset(psc, 0, sizeof *psc);
+ glx_screen_init(psc, screen, priv);
+ psc->vtable = &indirect_screen_vtable;
+
+ return psc;
+}
+
+
+_X_HIDDEN Bool
+glx_context_init(__GLXcontext *gc,
+ __GLXscreenConfigs *psc, const __GLcontextModes *fbconfig)
+{
+ gc->majorOpcode = __glXSetupForCommand(psc->display->dpy);
+ if (!gc->majorOpcode)
+ return GL_FALSE;
+
+ gc->screen = psc->scr;
+ gc->psc = psc;
+ gc->mode = fbconfig;
+ gc->isDirect = GL_TRUE;
+
+ return GL_TRUE;
+}
+
/**
* Create a new context. Exactly one of \c vis and \c fbconfig should be
@@ -375,42 +447,24 @@ CreateContext(Display * dpy, int generic_id,
Bool allowDirect,
unsigned code, int renderType, int screen)
{
- GLXContext gc;
+ GLXContext gc = NULL;
__GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
-#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL)
- int errorcode;
- bool x11error;
-#endif
-
+
if (dpy == NULL)
return NULL;
if (generic_id == None)
return NULL;
- gc = AllocateGLXContext(dpy);
+ gc = NULL;
+ if (allowDirect && psc->vtable->create_context)
+ gc = psc->vtable->create_context(psc, fbconfig,
+ shareList, renderType);
+ if (!gc)
+ gc = indirect_create_context(psc, fbconfig, shareList, renderType);
if (!gc)
return NULL;
-#ifndef GLX_USE_APPLEGL /* TODO: darwin indirect */
-#ifdef GLX_DIRECT_RENDERING
- if (allowDirect && psc->driScreen) {
- gc->driContext = psc->driScreen->createContext(psc, fbconfig, gc,
- shareList, renderType);
- if (gc->driContext != NULL) {
- gc->screen = screen;
- gc->psc = psc;
- gc->mode = fbconfig;
- gc->isDirect = GL_TRUE;
- }
- }
-#endif
-
- if (gc->driContext != NULL)
- gc->vtable = psc->direct_context_vtable;
- else
- gc->vtable = &glx_indirect_context_vtable;
-
LockDisplay(dpy);
switch (code) {
case X_GLXCreateContext: {
@@ -474,26 +528,10 @@ CreateContext(Display * dpy, int generic_id,
UnlockDisplay(dpy);
SyncHandle();
-#endif
gc->imported = GL_FALSE;
gc->renderType = renderType;
- /* TODO: darwin: Integrate with above to do indirect */
-#ifdef GLX_USE_APPLEGL
- if(apple_glx_create_context(&gc->driContext, dpy, screen, fbconfig,
- shareList ? shareList->driContext : NULL,
- &errorcode, &x11error)) {
- __glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
- __glXFreeContext(gc);
- return NULL;
- }
-
- gc->currentContextTag = -1;
- gc->mode = fbconfig;
- gc->isDirect = allowDirect;
-#endif
-
return gc;
}
@@ -529,8 +567,28 @@ glXCreateContext(Display * dpy, XVisualInfo * vis,
}
_X_HIDDEN void
-__glXFreeContext(__GLXcontext * gc)
+glx_send_destroy_context(Display *dpy, XID xid)
{
+ CARD8 opcode = __glXSetupForCommand(dpy);
+ xGLXDestroyContextReq *req;
+
+ LockDisplay(dpy);
+ GetReq(GLXDestroyContext, req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXDestroyContext;
+ req->context = xid;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+static void
+indirect_destroy_context(__GLXcontext *gc)
+{
+ if (!gc->imported && gc->xid)
+ glx_send_destroy_context(gc->psc->dpy, gc->xid);
+
+ __glXFreeVertexArrayState(gc);
+
if (gc->vendor)
XFree((char *) gc->vendor);
if (gc->renderer)
@@ -543,7 +601,6 @@ __glXFreeContext(__GLXcontext * gc)
XFree((char *) gc->buf);
Xfree((char *) gc->client_state_private);
XFree((char *) gc);
-
}
/*
@@ -552,81 +609,26 @@ __glXFreeContext(__GLXcontext * gc)
static void
DestroyContext(Display * dpy, GLXContext gc)
{
-#ifndef GLX_USE_APPLEGL /* TODO: darwin: indirect */
- xGLXDestroyContextReq *req;
- GLXContextID xid;
- CARD8 opcode;
- GLboolean imported;
-
- opcode = __glXSetupForCommand(dpy);
- if (!opcode || !gc) {
+ if (!gc)
return;
- }
__glXLock();
- xid = gc->xid;
- imported = gc->imported;
- gc->xid = None;
-
if (gc->currentDpy) {
/* This context is bound to some thread. According to the man page,
* we should not actually delete the context until it's unbound.
* Note that we set gc->xid = None above. In MakeContextCurrent()
* we check for that and delete the context there.
*/
+ if (!gc->imported)
+ glx_send_destroy_context(dpy, gc->xid);
+ gc->xid = None;
__glXUnlock();
return;
}
+ __glXUnlock();
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- /* Destroy the direct rendering context */
- if (gc->driContext) {
- (*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy);
- gc->driContext = NULL;
- GarbageCollectDRIDrawables(dpy, gc->psc);
- }
-#endif
-
- __glXFreeVertexArrayState(gc);
-#else
- __glXLock();
-#endif /* GLX_USE_APPLEGL */
-
- if (gc->currentDpy) {
-#ifdef GLX_USE_APPLEGL
- /*
- * Set the Bool that indicates that we should destroy this GLX context
- * when the context is no longer current.
- */
- gc->do_destroy = True;
-#endif
- /* Have to free later cuz it's in use now */
- __glXUnlock();
- }
- else {
- /* Destroy the handle if not current to anybody */
- __glXUnlock();
-#ifdef GLX_USE_APPLEGL
- if(gc->driContext)
- apple_glx_destroy_context(&gc->driContext, dpy);
-#endif
- __glXFreeContext(gc);
- }
-#ifndef GLX_USE_APPLEGL
- if (!imported) {
- /*
- ** This dpy also created the server side part of the context.
- ** Send the glXDestroyContext request.
- */
- LockDisplay(dpy);
- GetReq(GLXDestroyContext, req);
- req->reqType = opcode;
- req->glxCode = X_GLXDestroyContext;
- req->context = xid;
- UnlockDisplay(dpy);
- SyncHandle();
- }
-#endif
+ if (gc->vtable->destroy)
+ gc->vtable->destroy(gc);
}
PUBLIC void
@@ -674,42 +676,14 @@ glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
return rv;
}
-/*
-** Put a barrier in the token stream that forces the GL to finish its
-** work before X can proceed.
-*/
-PUBLIC void
-glXWaitGL(void)
+static void
+indirect_wait_gl(__GLXcontext *gc)
{
-#ifndef GLX_USE_APPLEGL
xGLXWaitGLReq *req;
-#endif
- GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
- if (!dpy)
- return;
-
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
-#ifdef GLX_USE_APPLEGL
- glFinish();
-#else
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- if (gc->driContext) {
- int screen;
- __GLXDRIdrawable *pdraw =
- GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen);
-
- if (pdraw != NULL) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
- glFlush();
- if (psc->driScreen->waitGL != NULL)
- (*psc->driScreen->waitGL) (pdraw);
- }
- return;
- }
-#endif
/* Send the glXWaitGL request */
LockDisplay(dpy);
@@ -719,51 +693,30 @@ glXWaitGL(void)
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
-#endif /* GLX_USE_APPLEGL */
}
/*
-** Put a barrier in the token stream that forces X to finish its
-** work before GL can proceed.
+** Put a barrier in the token stream that forces the GL to finish its
+** work before X can proceed.
*/
PUBLIC void
-glXWaitX(void)
+glXWaitGL(void)
{
-#ifndef GLX_USE_APPLEGL
- xGLXWaitXReq *req;
-#endif
GLXContext gc = __glXGetCurrentContext();
- Display *dpy = gc->currentDpy;
- if (!dpy)
- return;
+ if (gc && gc->vtable->use_x_font)
+ gc->vtable->wait_gl(gc);
+}
+
+static void
+indirect_wait_x(__GLXcontext *gc)
+{
+ xGLXWaitXReq *req;
+ Display *dpy = gc->currentDpy;
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
-#ifdef GLX_USE_APPLEGL
- apple_glx_waitx(dpy, gc->driContext);
-#else
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- if (gc->driContext) {
- int screen;
- __GLXDRIdrawable *pdraw =
- GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen);
-
- if (pdraw != NULL) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
- if (psc->driScreen->waitX != NULL)
- (*psc->driScreen->waitX) (pdraw);
- }
- else
- XSync(dpy, False);
- return;
- }
-#endif
-
- /*
- ** Send the glXWaitX request.
- */
LockDisplay(dpy);
GetReq(GLXWaitX, req);
req->reqType = gc->majorOpcode;
@@ -771,32 +724,30 @@ glXWaitX(void)
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
-#endif /* GLX_USE_APPLEGL */
}
+/*
+** Put a barrier in the token stream that forces X to finish its
+** work before GL can proceed.
+*/
PUBLIC void
-glXUseXFont(Font font, int first, int count, int listBase)
+glXWaitX(void)
{
-#ifndef GLX_USE_APPLEGL
- xGLXUseXFontReq *req;
-#endif
GLXContext gc = __glXGetCurrentContext();
- Display *dpy = gc->currentDpy;
- if (!dpy)
- return;
+ if (gc && gc->vtable->use_x_font)
+ gc->vtable->wait_x(gc);
+}
+
+static void
+indirect_use_x_font(__GLXcontext *gc,
+ Font font, int first, int count, int listBase)
+{
+ xGLXUseXFontReq *req;
+ Display *dpy = gc->currentDpy;
/* Flush any pending commands out */
- (void) __glXFlushRenderBuffer(gc, gc->pc);
-#ifdef GLX_USE_APPLEGL
- DRI_glXUseXFont(font, first, count, listBase);
-#else
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- if (gc->driContext) {
- DRI_glXUseXFont(font, first, count, listBase);
- return;
- }
-#endif
+ __glXFlushRenderBuffer(gc, gc->pc);
/* Send the glXUseFont request */
LockDisplay(dpy);
@@ -810,7 +761,46 @@ glXUseXFont(Font font, int first, int count, int listBase)
req->listBase = listBase;
UnlockDisplay(dpy);
SyncHandle();
-#endif /* GLX_USE_APPLEGL */
+}
+
+#ifdef GLX_USE_APPLEGL
+
+static void
+applegl_destroy_context(__GLXcontext *gc)
+{
+ apple_glx_destroy_context(&gc->driContext, gc->currentDpy);
+}
+
+static void
+applegl_wait_gl(__GLXcontext *gc)
+{
+ glFinish();
+}
+
+static void
+applegl_wait_x(__GLXcontext *gc)
+{
+ apple_glx_waitx(gc->dpy, gc->driContext);
+}
+
+static const struct glx_context_vtable applegl_context_vtable = {
+ applegl_destroy_context,
+ applegl_wait_gl,
+ applegl_wait_x,
+ DRI_glXUseXFont,
+ NULL, /* bind_tex_image, */
+ NULL, /* release_tex_image, */
+};
+
+#endif
+
+PUBLIC void
+glXUseXFont(Font font, int first, int count, int listBase)
+{
+ GLXContext gc = __glXGetCurrentContext();
+
+ if (gc && gc->vtable->use_x_font)
+ gc->vtable->use_x_font(gc, font, first, count, listBase);
}
/************************************************************************/
@@ -992,7 +982,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
__GLXscreenConfigs *psc;
__GLcontextModes *modes;
- psc = &priv->screenConfigs[vis->screen];
+ psc = priv->screenConfigs[vis->screen];
if (psc->driScreen == NULL)
break;
modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
@@ -1002,7 +992,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
break;
}
- if (__glxHashInsert(psc->drawHash, req->glxpixmap, pdraw)) {
+ if (__glxHashInsert(priv->drawHash, req->glxpixmap, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return None; /* FIXME: Check what we're supposed to do here... */
}
@@ -1042,14 +1032,12 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
- int screen;
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen);
- __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap);
if (pdraw != NULL) {
(*pdraw->destroyDrawable) (pdraw);
- __glxHashDelete(psc->drawHash, glxpixmap);
+ __glxHashDelete(priv->drawHash, glxpixmap);
}
}
#endif
@@ -1077,7 +1065,7 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
#endif
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
glFlush();
@@ -1690,122 +1678,103 @@ GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
glXGetCurrentDisplay)
#ifndef GLX_USE_APPLEGL
-/**
- * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests
- * to the X-server.
- *
- * \param dpy Display where \c ctx was created.
- * \param ctx Context to query.
- * \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid,
- * or zero if the request failed due to internal problems (i.e.,
- * unable to allocate temporary memory, etc.)
- *
- * \note
- * This function dynamically determines whether to use the EXT_import_context
- * version of the protocol or the GLX 1.3 version of the protocol.
- */
-static int __glXQueryContextInfo(Display * dpy, GLXContext ctx)
+PUBLIC GLXContext
+glXImportContextEXT(Display *dpy, GLXContextID contextID)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ __GLXscreenConfigs *psc;
xGLXQueryContextReply reply;
CARD8 opcode;
- GLuint numValues;
- int retval;
+ GLXContext ctx;
+ int propList[__GLX_MAX_CONTEXT_PROPS * 2], *pProp, nPropListBytes;
+ int i, renderType;
+ XID share;
+ __GLcontextModes *mode;
+
+ if (contextID == None || __glXIsDirect(dpy, contextID))
+ return NULL;
- if (ctx == NULL) {
- return GLX_BAD_CONTEXT;
- }
opcode = __glXSetupForCommand(dpy);
- if (!opcode) {
+ if (!opcode)
return 0;
- }
/* Send the glXQueryContextInfoEXT request */
LockDisplay(dpy);
- if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
+ if (priv->majorVersion > 1 || priv->minorVersion >= 3) {
xGLXQueryContextReq *req;
GetReq(GLXQueryContext, req);
req->reqType = opcode;
req->glxCode = X_GLXQueryContext;
- req->context = (unsigned int) (ctx->xid);
+ req->context = contextID;
}
else {
xGLXVendorPrivateReq *vpreq;
xGLXQueryContextInfoEXTReq *req;
GetReqExtra(GLXVendorPrivate,
- sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
- vpreq);
+ sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
+ vpreq);
req = (xGLXQueryContextInfoEXTReq *) vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_QueryContextInfoEXT;
- req->context = (unsigned int) (ctx->xid);
+ req->context = contextID;
}
_XReply(dpy, (xReply *) & reply, 0, False);
- numValues = reply.n;
- if (numValues == 0)
- retval = Success;
- else if (numValues > __GLX_MAX_CONTEXT_PROPS)
- retval = 0;
- else {
- int *propList, *pProp;
- int nPropListBytes;
-
- nPropListBytes = numValues << 3;
- propList = (int *) Xmalloc(nPropListBytes);
- if (NULL == propList) {
- retval = 0;
- }
- else {
- unsigned i;
-
- _XRead(dpy, (char *) propList, nPropListBytes);
-
- /* Look up screen first so we can look up visuals/fbconfigs later */
- pProp = propList;
- for (i = 0; i < numValues; i++, pProp += 2)
- if (pProp[0] == GLX_SCREEN) {
- ctx->screen = pProp[1];
- ctx->psc = GetGLXScreenConfigs(dpy, ctx->screen);
- }
-
- pProp = propList;
- for (i = 0; i < numValues; i++) {
- switch (*pProp++) {
- case GLX_SHARE_CONTEXT_EXT:
- ctx->share_xid = *pProp++;
- break;
- case GLX_VISUAL_ID_EXT:
- ctx->mode =
- _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++);
- break;
- case GLX_FBCONFIG_ID:
- ctx->mode =
- _gl_context_modes_find_fbconfig(ctx->psc->configs,
- *pProp++);
- break;
- case GLX_RENDER_TYPE:
- ctx->renderType = *pProp++;
- break;
- case GLX_SCREEN:
- default:
- pProp++;
- continue;
- }
- }
- Xfree((char *) propList);
- retval = Success;
- }
- }
+ if (reply.n <= __GLX_MAX_CONTEXT_PROPS)
+ nPropListBytes = reply.n * 2 * sizeof propList[0];
+ else
+ nPropListBytes = 0;
+ _XRead(dpy, (char *) propList, nPropListBytes);
UnlockDisplay(dpy);
SyncHandle();
- return retval;
+
+ /* Look up screen first so we can look up visuals/fbconfigs later */
+ psc = NULL;
+ for (i = 0, pProp = propList; i < reply.n; i++, pProp += 2)
+ if (pProp[0] == GLX_SCREEN)
+ psc = GetGLXScreenConfigs(dpy, pProp[1]);
+ if (psc == NULL)
+ return NULL;
+
+ share = None;
+ mode = NULL;
+ renderType = 0;
+ pProp = propList;
+
+ for (i = 0, pProp = propList; i < reply.n; i++, pProp += 2)
+ switch (pProp[0]) {
+ case GLX_SHARE_CONTEXT_EXT:
+ share = pProp[1];
+ break;
+ case GLX_VISUAL_ID_EXT:
+ mode = _gl_context_modes_find_visual(psc->visuals, pProp[1]);
+ break;
+ case GLX_FBCONFIG_ID:
+ mode = _gl_context_modes_find_fbconfig(psc->configs, pProp[1]);
+ break;
+ case GLX_RENDER_TYPE:
+ renderType = pProp[1];
+ break;
+ }
+
+ if (mode == NULL)
+ return NULL;
+
+ ctx = indirect_create_context(psc, mode, NULL, renderType);
+ if (ctx == NULL)
+ return NULL;
+
+ ctx->xid = contextID;
+ ctx->imported = GL_TRUE;
+ ctx->share_xid = share;
+
+ return ctx;
}
#endif
@@ -1813,38 +1782,21 @@ static int __glXQueryContextInfo(Display * dpy, GLXContext ctx)
PUBLIC int
glXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value)
{
-#ifndef GLX_USE_APPLEGL
- int retVal;
-
- /* get the information from the server if we don't have it already */
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- if (!ctx->driContext && (ctx->mode == NULL)) {
-#else
- if (ctx->mode == NULL) {
-#endif
- retVal = __glXQueryContextInfo(dpy, ctx);
- if (Success != retVal)
- return retVal;
- }
-#endif
-
switch (attribute) {
-#ifndef GLX_USE_APPLEGL
case GLX_SHARE_CONTEXT_EXT:
- *value = (int) (ctx->share_xid);
+ *value = ctx->share_xid;
break;
case GLX_VISUAL_ID_EXT:
*value = ctx->mode ? ctx->mode->visualID : None;
break;
-#endif
case GLX_SCREEN:
- *value = (int) (ctx->screen);
+ *value = ctx->screen;
break;
case GLX_FBCONFIG_ID:
*value = ctx->mode ? ctx->mode->fbconfigID : None;
break;
case GLX_RENDER_TYPE:
- *value = (int) (ctx->renderType);
+ *value = ctx->renderType;
break;
default:
return GLX_BAD_ATTRIBUTE;
@@ -1862,35 +1814,6 @@ PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx)
return ctx->xid;
}
-PUBLIC GLXContext
-glXImportContextEXT(Display * dpy, GLXContextID contextID)
-{
-#ifdef GLX_USE_APPLEGL
- return NULL;
-#else
- GLXContext ctx;
-
- if (contextID == None) {
- return NULL;
- }
- if (__glXIsDirect(dpy, contextID)) {
- return NULL;
- }
-
- ctx = AllocateGLXContext(dpy);
- if (NULL != ctx) {
- ctx->xid = contextID;
- ctx->imported = GL_TRUE;
-
- if (Success != __glXQueryContextInfo(dpy, ctx)) {
- __glXFreeContext(ctx);
- ctx = NULL;
- }
- }
- return ctx;
-#endif
-}
-
PUBLIC void
glXFreeContextEXT(Display * dpy, GLXContext ctx)
{
@@ -1898,11 +1821,6 @@ glXFreeContextEXT(Display * dpy, GLXContext ctx)
}
-
-/*
- * GLX 1.3 functions - these are just stubs for now!
- */
-
PUBLIC GLXFBConfig *
glXChooseFBConfig(Display * dpy, int screen,
const int *attribList, int *nitems)
@@ -1958,14 +1876,14 @@ glXGetFBConfigs(Display * dpy, int screen, int *nelements)
*nelements = 0;
if (priv && (priv->screenConfigs != NULL)
&& (screen >= 0) && (screen <= ScreenCount(dpy))
- && (priv->screenConfigs[screen].configs != NULL)
- && (priv->screenConfigs[screen].configs->fbconfigID
+ && (priv->screenConfigs[screen]->configs != NULL)
+ && (priv->screenConfigs[screen]->configs->fbconfigID
!= (int) GLX_DONT_CARE)) {
unsigned num_configs = 0;
__GLcontextModes *modes;
- for (modes = priv->screenConfigs[screen].configs; modes != NULL;
+ for (modes = priv->screenConfigs[screen]->configs; modes != NULL;
modes = modes->next) {
if (modes->fbconfigID != (int) GLX_DONT_CARE) {
num_configs++;
@@ -1977,7 +1895,7 @@ glXGetFBConfigs(Display * dpy, int screen, int *nelements)
if (config != NULL) {
*nelements = num_configs;
i = 0;
- for (modes = priv->screenConfigs[screen].configs; modes != NULL;
+ for (modes = priv->screenConfigs[screen]->configs; modes != NULL;
modes = modes->next) {
if (modes->fbconfigID != (int) GLX_DONT_CARE) {
config[i] = modes;
@@ -2038,29 +1956,12 @@ __glXSwapIntervalSGI(int interval)
return GLX_BAD_VALUE;
}
-#ifdef __DRI_SWAP_CONTROL
- if (gc->driContext) {
- __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
- gc->screen );
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
- gc->currentDrawable,
- NULL);
- if (psc->swapControl != NULL && pdraw != NULL) {
- psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
- return 0;
- }
- else if (pdraw == NULL) {
- return GLX_BAD_CONTEXT;
- }
- }
-#endif
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
if (gc->driContext && psc->driScreen && psc->driScreen->setSwapInterval) {
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
- gc->currentDrawable,
- NULL);
+ __GLXDRIdrawable *pdraw =
+ GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
psc->driScreen->setSwapInterval(pdraw, interval);
return 0;
}
@@ -2097,34 +1998,17 @@ __glXSwapIntervalSGI(int interval)
static int
__glXSwapIntervalMESA(unsigned int interval)
{
+#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
-#ifdef __DRI_SWAP_CONTROL
- if (gc != NULL && gc->driContext) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
- gc->screen);
-
- if ((psc != NULL) && (psc->driScreen != NULL)) {
- __GLXDRIdrawable *pdraw =
- GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if (psc->swapControl != NULL && pdraw != NULL) {
- psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
- return 0;
- }
- }
- }
-#endif
-
-#ifdef GLX_DIRECT_RENDERING
if (gc != NULL && gc->driContext) {
__GLXscreenConfigs *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
if (psc->driScreen && psc->driScreen->setSwapInterval) {
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
- gc->currentDrawable, NULL);
- psc->driScreen->setSwapInterval(pdraw, interval);
- return 0;
+ __GLXDRIdrawable *pdraw =
+ GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
+ return psc->driScreen->setSwapInterval(pdraw, interval);
}
}
#endif
@@ -2136,31 +2020,16 @@ __glXSwapIntervalMESA(unsigned int interval)
static int
__glXGetSwapIntervalMESA(void)
{
-#ifdef __DRI_SWAP_CONTROL
+#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
if (gc != NULL && gc->driContext) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
- gc->screen);
-
- if ((psc != NULL) && (psc->driScreen != NULL)) {
- __GLXDRIdrawable *pdraw =
- GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if (psc->swapControl != NULL && pdraw != NULL) {
- return psc->swapControl->getSwapInterval(pdraw->driDrawable);
- }
- }
- }
-#endif
-
-#ifdef GLX_DIRECT_RENDERING
- if (gc != NULL && gc->driContext) {
__GLXscreenConfigs *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
if (psc->driScreen && psc->driScreen->getSwapInterval) {
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
- gc->currentDrawable, NULL);
+ __GLXDRIdrawable *pdraw =
+ GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
return psc->driScreen->getSwapInterval(pdraw);
}
}
@@ -2171,107 +2040,6 @@ __glXGetSwapIntervalMESA(void)
/*
-** GLX_MESA_swap_frame_usage
-*/
-
-static GLint
-__glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
-{
- int status = GLX_BAD_CONTEXT;
-#ifdef __DRI_FRAME_TRACKING
- int screen = 0;
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
-
- if (pdraw != NULL && psc->frameTracking != NULL)
- status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE);
-#else
- (void) dpy;
- (void) drawable;
-#endif
- return status;
-}
-
-
-static GLint
-__glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
-{
- int status = GLX_BAD_CONTEXT;
-#ifdef __DRI_FRAME_TRACKING
- int screen = 0;
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen);
-
- if (pdraw != NULL && psc->frameTracking != NULL)
- status = psc->frameTracking->frameTracking(pdraw->driDrawable,
- GL_FALSE);
-#else
- (void) dpy;
- (void) drawable;
-#endif
- return status;
-}
-
-
-static GLint
-__glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage)
-{
- int status = GLX_BAD_CONTEXT;
-#ifdef __DRI_FRAME_TRACKING
- int screen = 0;
- __GLXDRIdrawable *const pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
-
- if (pdraw != NULL && psc->frameTracking != NULL) {
- int64_t sbc, missedFrames;
- float lastMissedUsage;
-
- status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
- &sbc,
- &missedFrames,
- &lastMissedUsage,
- usage);
- }
-#else
- (void) dpy;
- (void) drawable;
- (void) usage;
-#endif
- return status;
-}
-
-
-static GLint
-__glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable,
- int64_t * sbc, int64_t * missedFrames,
- GLfloat * lastMissedUsage)
-{
- int status = GLX_BAD_CONTEXT;
-#ifdef __DRI_FRAME_TRACKING
- int screen = 0;
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
-
- if (pdraw != NULL && psc->frameTracking != NULL) {
- float usage;
-
- status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
- sbc, missedFrames,
- lastMissedUsage,
- &usage);
- }
-#else
- (void) dpy;
- (void) drawable;
- (void) sbc;
- (void) missedFrames;
- (void) lastMissedUsage;
-#endif
- return status;
-}
-
-
-/*
** GLX_SGI_video_sync
*/
static int
@@ -2295,23 +2063,13 @@ __glXGetVideoSyncSGI(unsigned int *count)
psc = GetGLXScreenConfigs(gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
- pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+ pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
#endif
/* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry,
* FIXME: there should be a GLX encoding for this call. I can find no
* FIXME: documentation for the GLX encoding.
*/
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if ( psc->msc && psc->driScreen ) {
- ret = (*psc->msc->getDrawableMSC)(psc->__driScreen,
- pdraw->driDrawable, &msc);
- *count = (unsigned) msc;
-
- return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
- }
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->getDrawableMSC) {
ret = psc->driScreen->getDrawableMSC(psc, pdraw, &ust, &msc, &sbc);
@@ -2347,16 +2105,7 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
- pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
-#endif
-
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if (psc->msc != NULL && psc->driScreen ) {
- ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0,
- divisor, remainder, &msc, &sbc);
- *count = (unsigned) msc;
- return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
- }
+ pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
#endif
#ifdef GLX_DIRECT_RENDERING
@@ -2532,7 +2281,7 @@ __glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
int64_t * ust, int64_t * msc, int64_t * sbc)
{
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
- int i, ret;
+ int ret;
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw;
#endif
@@ -2542,20 +2291,9 @@ __glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
return False;
#ifdef GLX_DIRECT_RENDERING
- pdraw = GetGLXDRIDrawable(dpy, drawable, &i);
-#endif
- psc = &priv->screenConfigs[i];
-
-#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER)
- if (pdraw && psc->sbc && psc->msc)
- return ( (pdraw && psc->sbc && psc->msc)
- && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0)
- && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0)
- && (__glXGetUST(ust) == 0) );
-#endif
-
-#ifdef GLX_DIRECT_RENDERING
- if (pdraw && psc && psc->driScreen && psc->driScreen->getDrawableMSC) {
+ pdraw = GetGLXDRIDrawable(dpy, drawable);
+ psc = pdraw ? pdraw->psc : NULL;
+ if (pdraw && psc->driScreen->getDrawableMSC) {
ret = psc->driScreen->getDrawableMSC(psc, pdraw, ust, msc, sbc);
return ret;
}
@@ -2566,17 +2304,14 @@ __glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
_X_HIDDEN GLboolean
-__driGetMscRateOML(__DRIdrawable * draw,
- int32_t * numerator, int32_t * denominator, void *private)
+__glxGetMscRate(__GLXDRIdrawable *glxDraw,
+ int32_t * numerator, int32_t * denominator)
{
#ifdef XF86VIDMODE
__GLXscreenConfigs *psc;
XF86VidModeModeLine mode_line;
int dot_clock;
int i;
- __GLXDRIdrawable *glxDraw = private;
-
- (void) draw;
psc = glxDraw->psc;
if (XF86VidModeQueryVersion(psc->dpy, &i, &i) &&
@@ -2655,12 +2390,12 @@ __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator, int32_t * denominator)
{
#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
- __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL);
+ __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable);
if (draw == NULL)
return False;
- return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw);
+ return __glxGetMscRate(draw, numerator, denominator);
#else
(void) dpy;
(void) drawable;
@@ -2676,11 +2411,10 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor, int64_t remainder)
{
GLXContext gc = __glXGetCurrentContext();
- int screen;
#ifdef GLX_DIRECT_RENDERING
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
+ __GLXscreenConfigs *psc = pdraw ? pdraw->psc : NULL;
#endif
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
if (!gc) /* no GLX for this */
return -1;
@@ -2703,12 +2437,6 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
if (target_msc == 0 && divisor == 0 && remainder == 0)
remainder = 1;
-#ifdef __DRI_SWAP_BUFFER_COUNTER
- if (psc->counters != NULL)
- return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc,
- divisor, remainder);
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->swapBuffers)
return (*psc->driScreen->swapBuffers)(pdraw, target_msc, divisor,
@@ -2725,11 +2453,10 @@ __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
int64_t remainder, int64_t * ust,
int64_t * msc, int64_t * sbc)
{
- int screen;
#ifdef GLX_DIRECT_RENDERING
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
#endif
- __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+ __GLXscreenConfigs *psc = pdraw ? pdraw->psc : NULL;
int ret;
@@ -2741,18 +2468,6 @@ __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
if (divisor > 0 && remainder >= divisor)
return False;
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if (pdraw != NULL && psc->msc != NULL) {
- ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, target_msc,
- divisor, remainder, msc, sbc);
-
- /* __glXGetUST returns zero on success and non-zero on failure.
- * This function returns True on success and False on failure.
- */
- return ((ret == 0) && (__glXGetUST(ust) == 0));
- }
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) {
ret = psc->driScreen->waitForMSC(pdraw, target_msc, divisor, remainder,
@@ -2770,11 +2485,10 @@ __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
int64_t target_sbc, int64_t * ust,
int64_t * msc, int64_t * sbc)
{
- int screen;
#ifdef GLX_DIRECT_RENDERING
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
#endif
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+ __GLXscreenConfigs *psc = pdraw ? pdraw->psc : NULL;
int ret;
/* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE
@@ -2782,17 +2496,6 @@ __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
*/
if (target_sbc < 0)
return False;
-#ifdef __DRI_SWAP_BUFFER_COUNTER
- if (pdraw != NULL && psc->sbc != NULL) {
- ret =
- (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc);
-
- /* __glXGetUST returns zero on success and non-zero on failure.
- * This function returns True on success and False on failure.
- */
- return ((ret == 0) && (__glXGetUST(ust) == 0));
- }
-#endif
#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc->driScreen && psc->driScreen->waitForSBC) {
@@ -2804,72 +2507,6 @@ __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
return False;
}
-
-/**
- * GLX_MESA_allocate_memory
- */
-/*@{*/
-
-PUBLIC void *
-glXAllocateMemoryMESA(Display * dpy, int scrn,
- size_t size, float readFreq,
- float writeFreq, float priority)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- return (*psc->allocate->allocateMemory) (psc->__driScreen, size,
- readFreq, writeFreq, priority);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) size;
- (void) readFreq;
- (void) writeFreq;
- (void) priority;
-#endif /* __DRI_ALLOCATE */
-
- return NULL;
-}
-
-
-PUBLIC void
-glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- (*psc->allocate->freeMemory) (psc->__driScreen, pointer);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) pointer;
-#endif /* __DRI_ALLOCATE */
-}
-
-
-PUBLIC GLuint
-glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- return (*psc->allocate->memoryOffset) (psc->__driScreen, pointer);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) pointer;
-#endif /* GLX_DIRECT_RENDERING */
-
- return ~0L;
-}
-
/*@}*/
@@ -2938,11 +2575,10 @@ __glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr;
CARD8 opcode;
-#ifdef __DRI_COPY_SUB_BUFFER
- int screen;
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+ __GLXscreenConfigs *psc = pdraw->psc;
if (psc->driScreen->copySubBuffer != NULL) {
glFlush();
(*psc->driScreen->copySubBuffer) (pdraw, x, y, width, height);
@@ -2998,9 +2634,9 @@ __glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
* GLX_EXT_texture_from_pixmap
*/
static void
-glx_indirect_bind_tex_image(Display * dpy,
- GLXDrawable drawable,
- int buffer, const int *attrib_list)
+indirect_bind_tex_image(Display * dpy,
+ GLXDrawable drawable,
+ int buffer, const int *attrib_list)
{
xGLXVendorPrivateReq *req;
GLXContext gc = __glXGetCurrentContext();
@@ -3051,7 +2687,7 @@ glx_indirect_bind_tex_image(Display * dpy,
}
static void
-glx_indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
+indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
{
xGLXVendorPrivateReq *req;
GLXContext gc = __glXGetCurrentContext();
@@ -3080,9 +2716,13 @@ glx_indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
SyncHandle();
}
-static const struct glx_context_vtable glx_indirect_context_vtable = {
- glx_indirect_bind_tex_image,
- glx_indirect_release_tex_image,
+static const struct glx_context_vtable indirect_context_vtable = {
+ indirect_destroy_context,
+ indirect_wait_gl,
+ indirect_wait_x,
+ indirect_use_x_font,
+ indirect_bind_tex_image,
+ indirect_release_tex_image,
};
/*@{*/
@@ -3233,11 +2873,6 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX),
GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX),
- /*** GLX_MESA_allocate_memory ***/
- GLX_FUNCTION(glXAllocateMemoryMESA),
- GLX_FUNCTION(glXFreeMemoryMESA),
- GLX_FUNCTION(glXGetMemoryOffsetMESA),
-
/*** GLX_MESA_copy_sub_buffer ***/
GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA),
@@ -3250,12 +2885,6 @@ static const struct name_address_pair GLX_functions[] = {
/*** GLX_MESA_swap_control ***/
GLX_FUNCTION2(glXSwapIntervalMESA, __glXSwapIntervalMESA),
GLX_FUNCTION2(glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA),
-
- /*** GLX_MESA_swap_frame_usage ***/
- GLX_FUNCTION2(glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA),
- GLX_FUNCTION2(glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA),
- GLX_FUNCTION2(glXGetFrameUsageMESA, __glXGetFrameUsageMESA),
- GLX_FUNCTION2(glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA),
#endif
/*** GLX_ARB_get_proc_address ***/
diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c
index 691e8dfadf2..e8649b67655 100644
--- a/src/glx/glxcurrent.c
+++ b/src/glx/glxcurrent.c
@@ -295,16 +295,16 @@ FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc)
if (priv == NULL)
return NULL;
- psc = &priv->screenConfigs[gc->screen];
- if (psc->drawHash == NULL)
+ psc = priv->screenConfigs[gc->screen];
+ if (priv->drawHash == NULL)
return NULL;
- if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
+ if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
return pdraw;
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
glxDrawable, gc->mode);
- if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
+ if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return NULL;
}
@@ -399,7 +399,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
}
bindReturnValue =
- (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
+ (gc->driContext->bindContext) (gc, pdraw, pread);
}
else if (!gc && oldGC && oldGC->driContext) {
bindReturnValue = True;
@@ -441,7 +441,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
}
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
else if (oldGC->driContext && oldGC != gc) {
- oldGC->driContext->unbindContext(oldGC->driContext);
+ oldGC->driContext->unbindContext(oldGC);
}
#endif
@@ -468,34 +468,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
oldGC->currentReadable = None;
oldGC->currentContextTag = 0;
oldGC->thread_id = 0;
-#ifdef GLX_USE_APPLEGL
-
- /*
- * At this point we should check if the context has been
- * through glXDestroyContext, and redestroy it if so.
- */
- if(oldGC->do_destroy) {
- __glXUnlock();
- /* glXDestroyContext uses the same global lock. */
- glXDestroyContext(dpy, oldGC);
- __glXLock();
-#else
+
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.
*/
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- /* Destroy the old direct rendering context */
- if (oldGC->driContext) {
- oldGC->driContext->destroyContext(oldGC->driContext,
- oldGC->psc,
- oldGC->createDpy);
- oldGC->driContext = NULL;
- }
-#endif
- __glXFreeContext(oldGC);
-#endif /* GLX_USE_APPLEGL */
+ oldGC->vtable->destroy(oldGC);
}
}
if (gc) {
diff --git a/src/glx/glxext.c b/src/glx/glxext.c
index 69a7b29eb27..4a9c9d499e7 100644
--- a/src/glx/glxext.c
+++ b/src/glx/glxext.c
@@ -68,13 +68,8 @@ _X_HIDDEN int __glXDebug = 0;
/* Extension required boiler plate */
-static char *__glXExtensionName = GLX_EXTENSION_NAME;
-#ifdef GLX_USE_APPLEGL
-static XExtensionInfo __glXExtensionInfo_data;
-XExtensionInfo *__glXExtensionInfo = &__glXExtensionInfo_data;
-#else
-XExtensionInfo *__glXExtensionInfo = NULL;
-#endif
+static const char __glXExtensionName[] = GLX_EXTENSION_NAME;
+static __GLXdisplayPrivate *glx_displays;
static /* const */ char *error_list[] = {
"GLXBadContext",
@@ -92,21 +87,6 @@ static /* const */ char *error_list[] = {
"GLXBadWindow",
};
-static int
-__glXCloseDisplay(Display * dpy, XExtCodes * codes)
-{
- GLXContext gc;
-
- gc = __glXGetCurrentContext();
- if (dpy == gc->currentDpy) {
- __glXSetCurrentContextNull();
- __glXFreeContext(gc);
- }
-
- return XextRemoveDisplay(__glXExtensionInfo, dpy);
-}
-
-
#ifdef GLX_USE_APPLEGL
static char *__glXErrorString(Display *dpy, int code, XExtCodes *codes,
char *buf, int n);
@@ -115,28 +95,6 @@ static char *__glXErrorString(Display *dpy, int code, XExtCodes *codes,
static
XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
__GLX_NUMBER_ERRORS, error_list)
-static Bool
-__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire);
-static Status
-__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire);
-
-static /* const */ XExtensionHooks __glXExtensionHooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- __glXCloseDisplay, /* close_display */
- __glXWireToEvent, /* wire_to_event */
- __glXEventToWire, /* event_to_wire */
- NULL, /* error */
- __glXErrorString, /* error_string */
-};
-
-XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
- __glXExtensionName, &__glXExtensionHooks,
- __GLX_NUMBER_EVENTS, NULL)
/*
* GLX events are a bit funky. We don't stuff the X event code into
@@ -150,11 +108,12 @@ XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
static Bool
__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
- XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ __GLXdisplayPrivate *glx_dpy = __glXInitialize(dpy);
- XextCheckExtension(dpy, info, __glXExtensionName, False);
+ if (glx_dpy == NULL)
+ return False;
- switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
+ switch ((wire->u.u.type & 0x7f) - glx_dpy->codes->first_event) {
case GLX_PbufferClobber:
{
GLXPbufferClobberEvent *aevent = (GLXPbufferClobberEvent *)event;
@@ -209,9 +168,10 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
static Status
__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire)
{
- XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ __GLXdisplayPrivate *glx_dpy = __glXInitialize(dpy);
- XextCheckExtension(dpy, info, __glXExtensionName, False);
+ if (glx_dpy == NULL)
+ return False;
switch (event->type) {
case GLX_DAMAGED:
@@ -244,9 +204,9 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv)
GLint i, screens;
/* Free screen configuration information */
- psc = priv->screenConfigs;
screens = ScreenCount(priv->dpy);
- for (i = 0; i < screens; i++, psc++) {
+ for (i = 0; i < screens; i++) {
+ psc = priv->screenConfigs[i];
if (psc->configs) {
_gl_context_modes_destroy(psc->configs);
if (psc->effectiveGLXexts)
@@ -260,19 +220,13 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv)
Xfree((char *) psc->serverGLXexts);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- if (psc->driver_configs) {
- unsigned int j;
- for (j = 0; psc->driver_configs[j]; j++)
- free((__DRIconfig *) psc->driver_configs[j]);
- free(psc->driver_configs);
- psc->driver_configs = NULL;
- }
if (psc->driScreen) {
psc->driScreen->destroyScreen(psc);
- __glxHashDestroy(psc->drawHash);
- XFree(psc->driScreen);
- psc->driScreen = NULL;
+ } else {
+ Xfree(psc);
}
+#else
+ Xfree(psc);
#endif
}
XFree((char *) priv->screenConfigs);
@@ -284,20 +238,34 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv)
** structure. The caller will free the extension structure.
*/
static int
-__glXFreeDisplayPrivate(XExtData * extension)
+__glXCloseDisplay(Display * dpy, XExtCodes * codes)
{
- __GLXdisplayPrivate *priv;
+ __GLXdisplayPrivate *priv, **prev;
+ GLXContext gc;
+
+ _XLockMutex(_Xglobal_lock);
+ prev = &glx_displays;
+ for (priv = glx_displays; priv; prev = &priv->next, priv = priv->next) {
+ if (priv->dpy == dpy) {
+ (*prev)->next = priv->next;
+ break;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ gc = __glXGetCurrentContext();
+ if (dpy == gc->currentDpy) {
+ gc->vtable->destroy(gc);
+ __glXSetCurrentContextNull();
+ }
- priv = (__GLXdisplayPrivate *) extension->private_data;
FreeScreenConfigs(priv);
- if (priv->serverGLXvendor) {
+ if (priv->serverGLXvendor)
Xfree((char *) priv->serverGLXvendor);
- priv->serverGLXvendor = 0x0; /* to protect against double free's */
- }
- if (priv->serverGLXversion) {
+ if (priv->serverGLXversion)
Xfree((char *) priv->serverGLXversion);
- priv->serverGLXversion = 0x0; /* to protect against double free's */
- }
+
+ __glxHashDestroy(priv->drawHash);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/* Free the direct rendering per display data */
@@ -315,10 +283,9 @@ __glXFreeDisplayPrivate(XExtData * extension)
#endif
Xfree((char *) priv);
- return 0;
-}
-/************************************************************************/
+ return 1;
+}
/*
** Query the version of the GLX extension. This procedure works even if
@@ -672,15 +639,15 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
}
static GLboolean
-getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
+getVisualConfigs(__GLXscreenConfigs *psc,
+ __GLXdisplayPrivate *priv, int screen)
{
xGLXGetVisualConfigsReq *req;
- __GLXscreenConfigs *psc;
xGLXGetVisualConfigsReply reply;
+ Display *dpy = priv->dpy;
LockDisplay(dpy);
- psc = priv->screenConfigs + screen;
psc->visuals = NULL;
GetReq(GLXGetVisualConfigs, req);
req->reqType = priv->majorOpcode;
@@ -701,15 +668,14 @@ getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
}
static GLboolean
-getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
+getFBConfigs(__GLXscreenConfigs *psc, __GLXdisplayPrivate *priv, int screen)
{
xGLXGetFBConfigsReq *fb_req;
xGLXGetFBConfigsSGIXReq *sgi_req;
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXGetFBConfigsReply reply;
- __GLXscreenConfigs *psc;
+ Display *dpy = priv->dpy;
- psc = priv->screenConfigs + screen;
psc->serverGLXexts =
__glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
@@ -748,6 +714,22 @@ getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
return psc->configs != NULL;
}
+_X_HIDDEN Bool
+glx_screen_init(__GLXscreenConfigs *psc,
+ int screen, __GLXdisplayPrivate * priv)
+{
+ /* Initialize per screen dynamic client GLX extensions */
+ psc->ext_list_first_time = GL_TRUE;
+ psc->scr = screen;
+ psc->dpy = priv->dpy;
+ psc->display = priv;
+
+ getVisualConfigs(psc, priv, screen);
+ getFBConfigs(psc, priv, screen);
+
+ return GL_TRUE;
+}
+
/*
** Allocate the memory for the per screen configs for each screen.
** If that works then fetch the per screen configs data.
@@ -762,12 +744,9 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
** First allocate memory for the array of per screen configs.
*/
screens = ScreenCount(dpy);
- psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
- if (!psc) {
+ priv->screenConfigs = Xmalloc(screens * sizeof *priv->screenConfigs);
+ if (!priv->screenConfigs)
return GL_FALSE;
- }
- memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
- priv->screenConfigs = psc;
priv->serverGLXversion =
__glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
@@ -777,33 +756,18 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
}
for (i = 0; i < screens; i++, psc++) {
- getVisualConfigs(dpy, priv, i);
- getFBConfigs(dpy, priv, i);
-
+ psc = NULL;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- psc->scr = i;
- psc->dpy = dpy;
- psc->drawHash = __glxHashCreate();
- if (psc->drawHash == NULL)
- continue;
-
- /* Initialize per screen dynamic client GLX extensions */
- psc->ext_list_first_time = GL_TRUE;
-
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 && priv->driswDisplay)
- psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv);
-
- if (psc->driScreen == NULL) {
- __glxHashDestroy(psc->drawHash);
- psc->drawHash = NULL;
- }
+ psc = (*priv->dri2Display->createScreen) (i, priv);
+ if (psc == NULL && priv->driDisplay)
+ psc = (*priv->driDisplay->createScreen) (i, priv);
+ if (psc == NULL && priv->driswDisplay)
+ psc = (*priv->driswDisplay->createScreen) (i, priv);
#endif
+ if (psc == NULL)
+ psc = indirect_create_screen(i, priv);
+ priv->screenConfigs[i] = psc;
}
SyncHandle();
return GL_TRUE;
@@ -815,72 +779,59 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
_X_HIDDEN __GLXdisplayPrivate *
__glXInitialize(Display * dpy)
{
- XExtDisplayInfo *info = __glXFindDisplay(dpy);
- XExtData **privList, *private, *found;
__GLXdisplayPrivate *dpyPriv;
- XEDataObject dataObj;
- int major, minor;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
Bool glx_direct, glx_accel;
#endif
+ int i;
- /* The one and only long long lock */
- __glXLock();
+ _XLockMutex(_Xglobal_lock);
- if (!XextHasExtension(info)) {
- /* No GLX extension supported by this server. Oh well. */
- __glXUnlock();
- XMissingExtension(dpy, __glXExtensionName);
- return 0;
+ for (dpyPriv = glx_displays; dpyPriv; dpyPriv = dpyPriv->next) {
+ if (dpyPriv->dpy == dpy) {
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyPriv;
+ }
}
- /* See if a display private already exists. If so, return it */
- dataObj.display = dpy;
- privList = XEHeadOfExtensionList(dataObj);
- found = XFindOnExtensionList(privList, info->codes->extension);
- if (found) {
- __glXUnlock();
- return (__GLXdisplayPrivate *) found->private_data;
+ dpyPriv = Xcalloc(1, sizeof *dpyPriv);
+ if (!dpyPriv)
+ return NULL;
+
+ dpyPriv->codes = XInitExtension(dpy, __glXExtensionName);
+ if (!dpyPriv->codes) {
+ Xfree(dpyPriv);
+ _XUnlockMutex(_Xglobal_lock);
+ return NULL;
}
+ dpyPriv->dpy = dpy;
+ dpyPriv->majorOpcode = dpyPriv->codes->major_opcode;
+ dpyPriv->serverGLXvendor = 0x0;
+ dpyPriv->serverGLXversion = 0x0;
+
/* See if the versions are compatible */
- if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
- /* The client and server do not agree on versions. Punt. */
- __glXUnlock();
- return 0;
+ if (!QueryVersion(dpy, dpyPriv->majorOpcode,
+ &dpyPriv->majorVersion, &dpyPriv->minorVersion)) {
+ Xfree(dpyPriv);
+ _XUnlockMutex(_Xglobal_lock);
+ return NULL;
}
- /*
- ** Allocate memory for all the pieces needed for this buffer.
- */
- private = (XExtData *) Xmalloc(sizeof(XExtData));
- if (!private) {
- __glXUnlock();
- return 0;
+ for (i = 0; i < __GLX_NUMBER_EVENTS; i++) {
+ XESetWireToEvent(dpy, dpyPriv->codes->first_event + i, __glXWireToEvent);
+ XESetEventToWire(dpy, dpyPriv->codes->first_event + i, __glXEventToWire);
}
- dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
- if (!dpyPriv) {
- __glXUnlock();
- Xfree((char *) private);
- return 0;
- }
-
- /*
- ** Init the display private and then read in the screen config
- ** structures from the server.
- */
- dpyPriv->majorOpcode = info->codes->major_opcode;
- dpyPriv->majorVersion = major;
- dpyPriv->minorVersion = minor;
- dpyPriv->dpy = dpy;
- dpyPriv->serverGLXvendor = 0x0;
- dpyPriv->serverGLXversion = 0x0;
+ XESetCloseDisplay(dpy, dpyPriv->codes->extension, __glXCloseDisplay);
+ XESetErrorString (dpy, dpyPriv->codes->extension,__glXErrorString);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
+ dpyPriv->drawHash = __glxHashCreate();
+
/*
** Initialize the direct rendering per display data and functions.
** Note: This _must_ be done before calling any other DRI routines
@@ -893,32 +844,25 @@ __glXInitialize(Display * dpy)
if (glx_direct)
dpyPriv->driswDisplay = driswCreateDisplay(dpy);
#endif
+
#ifdef GLX_USE_APPLEGL
- if (apple_init_glx(dpy) || !AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
-#else
- if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+ if (apple_init_glx(dpy)) {
+ Xfree(dpyPriv);
+ return NULL;
+ }
#endif
- __glXUnlock();
- Xfree((char *) dpyPriv);
- Xfree((char *) private);
- return 0;
+ if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+ Xfree(dpyPriv);
+ return NULL;
}
- /*
- ** Fill in the private structure. This is the actual structure that
- ** hangs off of the Display structure. Our private structure is
- ** referred to by this structure. Got that?
- */
- private->number = info->codes->extension;
- private->next = 0;
- private->free_private = __glXFreeDisplayPrivate;
- private->private_data = (char *) dpyPriv;
- XAddToExtensionList(privList, private);
-
- if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
+ if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1)
__glXClientInfo(dpy, dpyPriv->majorOpcode);
- }
- __glXUnlock();
+
+ dpyPriv->next = glx_displays;
+ glx_displays = dpyPriv;
+
+ _XUnlockMutex(_Xglobal_lock);
return dpyPriv;
}
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index e58c296b309..4eb6a5536ab 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -85,21 +85,17 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N },
#ifdef GLX_USE_APPLEGL
{ GLX(MESA_agp_offset), VER(0,0), N, N, N, N }, /* Deprecated */
- { GLX(MESA_allocate_memory), VER(0,0), N, N, N, N },
{ GLX(MESA_copy_sub_buffer), VER(0,0), N, N, N, N },
#else
{ GLX(MESA_agp_offset), VER(0,0), N, N, N, Y }, /* Deprecated */
- { GLX(MESA_allocate_memory), VER(0,0), Y, N, N, Y },
{ GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N },
#endif
{ GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */
{ GLX(MESA_release_buffers), VER(0,0), N, N, N, N }, /* Deprecated */
#ifdef GLX_USE_APPLEGL
{ GLX(MESA_swap_control), VER(0,0), N, N, N, N },
- { GLX(MESA_swap_frame_usage), VER(0,0), N, N, N, N },
#else
{ GLX(MESA_swap_control), VER(0,0), Y, N, N, Y },
- { GLX(MESA_swap_frame_usage), VER(0,0), Y, N, N, Y },
#endif
{ GLX(NV_float_buffer), VER(0,0), N, N, N, N },
{ GLX(NV_render_depth_texture), VER(0,0), N, N, N, N },
diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
index f556b1239c9..4f1b6619d65 100644
--- a/src/glx/glxextensions.h
+++ b/src/glx/glxextensions.h
@@ -41,7 +41,6 @@ enum
EXT_visual_rating_bit,
EXT_import_context_bit,
MESA_agp_offset_bit,
- MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
MESA_copy_sub_buffer_bit,
MESA_depth_float_bit,
MESA_pixmap_colormap_bit,
diff --git a/src/glx/xfont.c b/src/glx/xfont.c
index 797fd7a4900..db3a5701100 100644
--- a/src/glx/xfont.c
+++ b/src/glx/xfont.c
@@ -212,9 +212,8 @@ isvalid(XFontStruct * fs, int which)
}
_X_HIDDEN void
-DRI_glXUseXFont(Font font, int first, int count, int listbase)
+DRI_glXUseXFont(GLXContext CC, Font font, int first, int count, int listbase)
{
- GLXContext CC;
Display *dpy;
Window win;
Pixmap pixmap;
@@ -231,7 +230,6 @@ DRI_glXUseXFont(Font font, int first, int count, int listbase)
int i;
- CC = __glXGetCurrentContext();
dpy = CC->currentDpy;
win = CC->currentDrawable;