[Xcb] XCB/GLX and resizing windows leads to incorrectly places GLX contents

Ruben Van Boxem vanboxem.ruben at gmail.com
Fri Jul 20 17:34:39 UTC 2018


2018-07-20 12:54 GMT+02:00 Michel Dänzer <michel at daenzer.net>:

> When the window size has changed, do you call glViewport et al between
> glXSwapBuffers and glClear?
>
> Which version of Mesa are you testing with?


Mesa version is 18.1.4.

I think I have fixed this along with probably some other mistakes on my end.
To summarize my current code (which solves the issues I described above):
 - window::repaint(bool force): fetches current geometry through
xcb_get_geometry/xcb_query_tree/xcb_translate_coordinates and stores it,
calls glXMakeCurrent, glViewport with fetched geometry. Next, Skia draws
into the framebuffer with OpenGL, glXSwapBuffers is called after that. If
force = false, only actually do anything (glXMakeCurrent, glViewport, Skia
drawing, glXSwapBuffers) if geometry has changed, otherwise, continue on.
 - on expose event: repaint(true)
 - on configure event: repaint(false)
 - on map event: repaint(true)
 - For DRI2 (verified by setting LIBGL_DRI3_DISABLE=true): I handle all
unknown events with this piece of code:
        auto proc = XESetWireToEvent(display.get(), event.response_type, 0);
        if(proc)
        {
          XESetWireToEvent(display.get(), event.response_type, proc);
          XEvent dummy;
          event.sequence =
static_cast<std::uint16_t>(LastKnownRequestProcessed(display.get()));
          proc(display.get(), &dummy, reinterpret_cast<xEvent*>(&event));
        }

Previously, I did not repaint on configure notify events, which seems to
cause issues with composited GLX windows.
If I repaint(true) on configure, I get too many repaint events that still
cause repaints even after I've physically stopped resizing the window.
This gives me repaint when needed, and no funny business when resizing.
I'm probably missing some logic for scenarios I haven't considered yet but
this seems to cover most of it at least in an efficient manner.
The DRI2 issue actually was unrelated, but had an even more drastic effect
on repainting on resize which really needs the above fix to function
properly.
Oh, and this is all running in a window specific thread that hosts the
window-specific event loop, so I lock a mutex inside the repaint function
to prevent a closing window from invalidating the GLX context drawable.

So the glClear call actually only seemed to cause it (probably because it
exacerbated the effect). It was nonetheless unnecessary in my current setup.

Thanks and I hope this helps anyone looking for help in this area finds
this useful. I've been fighting to perfect this for quite some time and am
sure it still is far from optimal.

Ruben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20180720/ca73baf6/attachment.html>


More information about the Xcb mailing list