drm-gbm: present via vsynced page flips instead of per-frame SetCrtc#25
Open
lhoward wants to merge 1 commit into
Open
drm-gbm: present via vsynced page flips instead of per-frame SetCrtc#25lhoward wants to merge 1 commit into
lhoward wants to merge 1 commit into
Conversation
NativeWindowDrmGbm::SwapBuffers() called drmModeSetCrtc every frame, which is not vsynced -- the CRTC re-latches its scanout buffer immediately, not at vblank. On slower panels with high-contrast transitions the seam is plainly visible as tearing. Refs sony#136. Use drmModePageFlip with DRM_MODE_PAGE_FLIP_EVENT after the initial modeset. WaitForPageFlip() drains the previous flip event before the next is queued, and a release-on-flip handshake (bo_release_after_flip_ -> bo_pending_release_) ensures a displaced BO is freed only after the kernel has stopped scanning it out. No explicit GPU wait is needed: eglSwapBuffers attaches an implicit dma-buf exclusive fence to the rendered BO, which the legacy page-flip path already honours -- the kernel will not latch a framebuffer whose fence has not signalled. Resize() drains the in-flight flip and re-arms modeset for the fresh GBM surface; the destructor drains before restoring the original CRTC. enable_vsync_ remains a gate -- passing enableVSync: false in the Swift wrapper restores the legacy synchronous SetCrtc path. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019df5d6-7d1c-755a-9be1-e10d54295a9f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: AI-generated
NativeWindowDrmGbm::SwapBuffers()calleddrmModeSetCrtcevery frame, which is not vsynced -- the CRTC re-latches its scanout buffer immediately, not at vblank. On slower panels with high-contrast transitions the seam is plainly visible as tearing. Refs sony#136.Use
drmModePageFlipwithDRM_MODE_PAGE_FLIP_EVENTafter the initial modeset.WaitForPageFlip()drains the previous flip event before the next is queued, and a release-on-flip handshake (bo_release_after_flip_ -> bo_pending_release_) ensures a displaced BO is freed only after the kernel has stopped scanning it out.No explicit GPU wait is needed:
eglSwapBuffersattaches an implicit dma-buf exclusive fence to the rendered BO, which the legacy page-flip path already honours -- the kernel will not latch a framebuffer whose fence has not signalled.Resize() drains the in-flight flip and re-arms modeset for the fresh GBM surface; the destructor drains before restoring the original CRTC. enable_vsync_ remains a gate -- passing enableVSync: false in the Swift wrapper restores the legacy synchronous SetCrtc path.