[Xcb] Event processing and GLX

Jamey Sharp jamey at minilop.net
Sun Nov 20 14:37:52 PST 2011


Hello, Dan!

On Sun, Nov 20, 2011 at 01:06:12PM -0500, Dan Cecile wrote:
> I'm starting to experiment with using XCB in a new OpenGL project, and
> I'm running into a snag with resizing windows. After finding the
> explanation that GLX requires Xlib data structures, I modeled some
> code off of the wiki tutorial (http://xcb.freedesktop.org/opengl/).
> 
> Opening the window and drawing work properly. When the window size
> increases, though, the GLX framebuffer stays at its original size, and
> OpenGL cannot draw on the full size of the expanded window.
> 
> To simplify the problem, I've modified the "glxdemo" Mesa demo. The
> original code, using pure Xlib, can be found in the Mesa Git
> repository:
> 
>   http://cgit.freedesktop.org/mesa/demos/plain/src/xdemos/glxdemo.c
> 
> I've modified this code very slightly, replacing the Xlib event loop
> with an event loop written in XCB. This is enough to trigger the
> resizing problem (which does not exist in the original, pure Xlib
> demo).
> ...
> 
> The only other change I made was to give XCB ownership of the event
> loop immediately after connecting to the X server:
> 
>    dpy = XOpenDisplay(NULL);
>    XSetEventQueueOwner( dpy, XCBOwnsEventQueue );

To debug this, I tried modifying the demo as you suggested, but also
adding a default case to the switch statement over event types that
prints the unhandled event type. Sure enough:

	Resize event
	Redraw event
	unrecognized event 75
	unrecognized event 74
	unrecognized event 75

On my server, xdpyinfo -queryExtensions says the DRI2 extension event
base is 74, so event 74 is BufferSwapComplete and 75 is
InvalidateBuffers.

The DRI2 spec says InvalidateBuffers "is generated when the buffers the
client had requested ... become inappropriate because they don't match
the drawable dimensions anymore, or a buffer swap has been performed."
The client is supposed to "bring them back up-to-date with another
GetBuffers request."

So the cause of your troubles is pretty clear: the client-side 3D
driver needs to see those events, and it's expecting to get them from
Xlib, but Xlib doesn't own the event queue so the events never arrive
there.

Much less clear is what to do about it. For now, I think your only
option is to use Xlib for event handling, and just migrate all your
request/response code to XCB. I'd love to hear any suggestions about how
to do better, though.

Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20111120/1a535125/attachment.pgp>


More information about the Xcb mailing list