From aca1999d016c238c4d77819fcc7b356d57ac5c99 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Mon, 19 Feb 2018 12:15:37 +0000 Subject: [PATCH] wip-not-working: poll special dri2 events Mimic what is done for present extension in src/loader/loader_dri3_helper.c src/glx/dri2.c::DRI2WireToEvent is never called when xcb owns the Xlib event queue or as soon as xcb_poll_for_event is called from the app client. https://bugs.freedesktop.org/show_bug.cgi?id=105132 --- src/glx/dri2_glx.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 0f44635..fac2ea3 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -90,6 +90,11 @@ struct dri2_drawable uint64_t previous_time; unsigned frames; + + /* dri2 events */ + xcb_special_event_t *special_event; + uint32_t eid; + uint32_t *stamp; }; static const struct glx_context_vtable dri2_context_vtable; @@ -358,6 +363,11 @@ dri2DestroyDrawable(__GLXDRIdrawable *base) if (pdraw->base.xDrawable != pdraw->base.drawable) DRI2DestroyDrawable(psc->base.dpy, pdraw->base.xDrawable); + if (pdraw->special_event) { + xcb_connection_t *conn = XGetXCBConnection(base->psc->dpy); + xcb_unregister_for_special_event(conn, pdraw->special_event); + } + free(pdraw); } @@ -371,6 +381,7 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable, struct glx_display *dpyPriv; struct dri2_display *pdp; GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; + xcb_connection_t *conn = NULL; dpyPriv = __glXInitialize(psc->base.dpy); if (dpyPriv == NULL) @@ -431,6 +442,13 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable, if (psc->vtable.setSwapInterval) psc->vtable.setSwapInterval(&pdraw->base, pdraw->swap_interval); + conn = XGetXCBConnection(pdraw->base.psc->dpy); + pdraw->eid = xcb_generate_id(conn); + pdraw->special_event = xcb_register_for_special_xge(conn, + &xcb_dri2_id, + pdraw->eid, + pdraw->stamp); + return &pdraw->base; } @@ -566,6 +584,19 @@ dri2Flush(struct dri2_screen *psc, dri2Throttle(psc, draw, throttle_reason); } + + if (draw->special_event) { + xcb_connection_t *conn = XGetXCBConnection(draw->base.psc->dpy); + xcb_generic_event_t *ev = NULL; + + while ((ev = xcb_poll_for_special_event(conn, + draw->special_event)) != NULL) { + // if (ev->opcode == XCB_DRI2_INVALIDATE_BUFFERS) + //xcb_dri2_invalidate_buffers_event_t *be = (void *) ev; + //xcb_dri2_buffer_swap_complete_event_t *ce = (void *) ev; + dri2InvalidateBuffers(draw->base.psc->dpy, draw->base.xDrawable); + } + } } static void -- 2.7.4