Skip to content

glue: explain in comment why glFinish() must be called after glXSwapBuffers() - #37

Merged
igagis merged 1 commit into
cppfw:mainfrom
igagis-bot:doc-explain-post-swap-glfinish
Nov 25, 2026
Merged

igagis merged 1 commit into
cppfw:mainfrom
igagis-bot:doc-explain-post-swap-glfinish

Conversation

@igagis-bot

Copy link
Copy Markdown
Contributor

In swap_frame_buffers() (xorg/OpenGL), the existing comment states that
calling glFinish() right after the swap reduces perceived cursor latency,
but only when it's called after the swap — without explaining why.

This PR expands the comment to explain the mechanism:

  • With VSYNC enabled, glXSwapBuffers() only queues the present
    (render -> wait for vertical blank -> present) and returns immediately,
    so the event loop resumes while a present is still in flight. The next
    mouse-move event's commands then queue behind that pending present and
    the new cursor frame latches to a later vsync boundary.
  • glFinish() after the swap drains the GPU queue (including the
    just-queued present) before event handling resumes, so the new frame
    starts immediately and latches to the earliest possible vsync boundary.
  • A glFinish() before the swap only guarantees rendering is done; the
    present is still in flight, so it has no effect.

Also fixes a typo in the comment ("noticable" -> "noticeable").

Comment-only change; no code changes.

…uffers()

Also fix a typo in the comment ('noticable' -> 'noticeable').
@igagis
igagis merged commit 6a4a826 into cppfw:main Nov 25, 2026
1 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants