DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ struct glx_drawable *glxDraw;
XextCheckExtension(dpy, info, dri2ExtensionName, False);
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xDRI2BufferSwapComplete2 *awire = (xDRI2BufferSwapComplete2 *)wire;
+ __GLXDRIdrawable *pdraw;
+
+ pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
/* Ignore swap events if we're not looking for them */
aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
}
aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
- aevent->sbc = awire->sbc;
+
+ glxDraw = GetGLXDrawable(dpy, pdraw->drawable);
+ if (awire->sbc < glxDraw->lastEventSbc)
+ glxDraw->eventSbcWrap += 0x100000000;
+ glxDraw->lastEventSbc = awire->sbc;
+ aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
+
return True;
}
#endif
Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
xGLXCreateWindowReq *req;
+ struct glx_drawable *glxDraw;
CARD32 *data;
unsigned int i;
CARD8 opcode;
if (!opcode)
return None;
+ glxDraw = Xmalloc(sizeof(*glxDraw));
+ if (!glxDraw)
+ return None;
+
LockDisplay(dpy);
GetReqExtra(GLXCreateWindow, 8 * i, req);
data = (CARD32 *) (req + 1);
UnlockDisplay(dpy);
SyncHandle();
+ if (InitGLXDrawable(dpy, glxDraw, drawable, xid)) {
+ free(glxDraw);
+ return None;
+ }
+
if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) {
if (glxCode == X_GLXCreatePixmap)
glxCode = X_GLXDestroyPixmap;
protocolDestroyDrawable(dpy, drawable, glxCode);
+ DestroyGLXDrawable(dpy, drawable);
DestroyDRIDrawable(dpy, drawable, GL_FALSE);
return;
*/
struct glx_screen **screens;
+ __glxHashTable *glXDrawHash;
+
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__glxHashTable *drawHash;
#endif
};
+struct glx_drawable {
+ XID xDrawable;
+ XID drawable;
+
+ uint32_t lastEventSbc;
+ int64_t eventSbcWrap;
+};
+
extern int
glx_screen_init(struct glx_screen *psc,
int screen, struct glx_display * priv);
applegl_create_display(struct glx_display *display);
#endif
+
+extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);
+extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,
+ XID xDrawable, GLXDrawable drawable);
+extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable);
+
extern struct glx_context dummyContext;
extern struct glx_screen *
#endif
+_X_HIDDEN struct glx_drawable *
+GetGLXDrawable(Display *dpy, GLXDrawable drawable)
+{
+ struct glx_display *priv = __glXInitialize(dpy);
+ struct glx_drawable *glxDraw;
+
+ if (priv == NULL)
+ return NULL;
+
+ if (__glxHashLookup(priv->glXDrawHash, drawable, (void *) &glxDraw) == 0)
+ return glxDraw;
+
+ return NULL;
+}
+
+_X_HIDDEN int
+InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, XID xDrawable,
+ GLXDrawable drawable)
+{
+ struct glx_display *priv = __glXInitialize(dpy);
+
+ if (!priv)
+ return -1;
+
+ glxDraw->xDrawable = xDrawable;
+ glxDraw->drawable = drawable;
+ glxDraw->lastEventSbc = 0;
+ glxDraw->eventSbcWrap = 0;
+
+ return __glxHashInsert(priv->glXDrawHash, drawable, glxDraw);
+}
+
+_X_HIDDEN void
+DestroyGLXDrawable(Display *dpy, GLXDrawable drawable)
+{
+ struct glx_display *priv = __glXInitialize(dpy);
+ struct glx_drawable *glxDraw;
+
+ if (!priv)
+ return;
+
+ glxDraw = GetGLXDrawable(dpy, drawable);
+ __glxHashDelete(priv->glXDrawHash, drawable);
+ free(glxDraw);
+}
/**
* Get the GLX per-screen data structure associated with a GLX context.
return pixmap;
#else
xGLXCreateGLXPixmapReq *req;
+ struct glx_drawable *glxDraw;
GLXPixmap xid;
CARD8 opcode;
return None;
}
+ glxDraw = Xmalloc(sizeof(*glxDraw));
+ if (!glxDraw)
+ return None;
+
/* Send the glXCreateGLXPixmap request */
LockDisplay(dpy);
GetReq(GLXCreateGLXPixmap, req);
UnlockDisplay(dpy);
SyncHandle();
+ if (InitGLXDrawable(dpy, glxDraw, pixmap, req->glxpixmap)) {
+ free(glxDraw);
+ return None;
+ }
+
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
do {
/* FIXME: Maybe delay __DRIdrawable creation until the drawable
UnlockDisplay(dpy);
SyncHandle();
+ DestroyGLXDrawable(dpy, glxpixmap);
+
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
struct glx_display *const priv = __glXInitialize(dpy);
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xGLXBufferSwapComplete2 *awire = (xGLXBufferSwapComplete2 *)wire;
+ struct glx_drawable *glxDraw = GetGLXDrawable(dpy, awire->drawable);
aevent->event_type = awire->event_type;
aevent->drawable = awire->drawable;
aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
- aevent->sbc = awire->sbc;
+
+ if (!glxDraw)
+ return False;
+
+ if (awire->sbc < glxDraw->lastEventSbc)
+ glxDraw->eventSbcWrap += 0x100000000;
+ glxDraw->lastEventSbc = awire->sbc;
+ aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
return True;
}
default:
if (priv->serverGLXversion)
Xfree((char *) priv->serverGLXversion);
+ __glxHashDestroy(priv->glXDrawHash);
+
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__glxHashDestroy(priv->drawHash);
XESetCloseDisplay(dpy, dpyPriv->codes->extension, __glXCloseDisplay);
XESetErrorString (dpy, dpyPriv->codes->extension,__glXErrorString);
+ dpyPriv->glXDrawHash = __glxHashCreate();
+
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);