<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-07-20 12:54 GMT+02:00 Michel Dänzer <span dir="ltr"><<a href="mailto:michel@daenzer.net" target="_blank">michel@daenzer.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
When the window size has changed, do you call glViewport et al between<br>
glXSwapBuffers and glClear?<br>
<br>
Which version of Mesa are you testing with?<span class="gmail-m_8129939371162555527gmail-HOEnZb"><font color="#888888"></font></span></blockquote><div><br></div><div>Mesa version is 18.1.4.</div><div><br></div><div>I think I have fixed this along with probably some other mistakes on my end.</div><div>To summarize my current code (which solves the issues I described above):</div><div> - 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.<br></div><div> - on expose event: repaint(true)</div><div> - on configure event: repaint(false)</div><div> - on map event: repaint(true)<br></div><div> - For DRI2 (verified by setting LIBGL_DRI3_DISABLE=true): I handle all unknown events with this piece of code:</div><div>        auto proc = XESetWireToEvent(display.get(), event.response_type, 0);<br>        if(proc)<br>        {<br>          XESetWireToEvent(display.get(), event.response_type, proc);<br>          XEvent dummy;<br>          event.sequence = static_cast<std::uint16_t>(LastKnownRequestProcessed(display.get()));<br>          proc(display.get(), &dummy, reinterpret_cast<xEvent*>(&event));<br>        }<br></div><div></div><div><br></div><div>Previously, I did not repaint on configure notify events, which seems to cause issues with composited GLX windows.</div><div>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.</div><div>This gives me repaint when needed, and no funny business when resizing.<br></div><div>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.</div><div>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.</div><div>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.<br></div><div><br></div><div>So the glClear call actually only seemed to cause it (probably because it exacerbated the effect). It was nonetheless unnecessary in my current setup.<br></div><div><br></div><div>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.<br></div><div><br></div><div>Ruben<br></div></div></div></div>