<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>> Indeed. The main trick is to always wait for the previous
      buffer swap to complete (using GLX_INTEL_swap_event or <br>
      > GLX_OML_sync_control) before drawing the next frame. Then the
      normal _NET_WM_SYNC protocol should work. <br>
    </p>
    <p>As far as I can tell I am doing that. the current loop looks
      something like this:<br>
      <a
href="https://privatebin.net/?7c57104ced0a8790#9Usgz9FTsXvTeoJmYQ5tVyMPs6sQKynb8LtXf39NnhsH"
        id="pasteurl" rel="nofollow noopener noreferrer">https://privatebin.net/?7c57104ced0a8790#9Usgz9FTsXvTeoJmYQ5tVyMPs6sQKynb8LtXf39NnhsH</a></p>
    <p>(non-highlighted version at the bottom for longevity purposes)</p>
    <p>Although I might have understood wrong what you actually mean.
      From my PoV glXSwapBuffers should already "wait" until the frame
      is drawn, especially when we block afterwards using something like
      glClear(0) or glXWait*<br>
      There's obviously a lot more code around that, but that's the
      basis of it.</p>
    <p>The  _synced_resize is, as I mentioned, set in another thread
      which just polls XNextEvent.<br>
    </p>
    <p>What I understand to be the problem is that during resizes we
      would need to render at > framerate, as resize events can be
      submitted at that speed, or could be submitted between vblanks
      asking for additional frames that the compositor needs to make
      things look smooth. But using VSYNC we are capped to *exactly* the
      framerate of the monitor that we're on, so we cannot submit frames
      any faster than that, especially since OpenGL must be run
      singlethreaded, i.e. we have no way to submit frames with VSYNC
      without blocking with glXSwapBuffers().</p>
    <p>My current "fix", is to simply deactivate VSync before the buffer
      swap if it's a synced resize and reactivate it afterwards.<br>
      This achieves quite satisfying results, although I believe it is
      the entirely wrong path to take. At least that way we can submit
      more frames than VSYNC dictates whilst keeping VSYNC on for the
      remainder of the program's operation.<br>
    </p>
    <p>plain code version:<br>
      ```<br>
      while(!_closed) {<br>
          // acquire at start to avoid submitting a frame rendered for a
      smaller size as the response to the synced resize<br>
          bool synced_resize = _synced_resize;<br>
       <br>
          render();<br>
       <br>
          glXSwapBuffers();<br>
          // glXSwapBuffers doesn't block itself, only the next
      window-altering GL call does, if we want to force a block we can
      put a glClear(0) here<br>
       <br>
          if (synced_resize) {<br>
              // respond to sync using counter here<br>
          }<br>
      }<br>
      ```<br>
    </p>
  </body>
</html>