Skip to content

android: A56 release the framebuffers a flip replaced at the next flip; CI builds the Xwayland implicit-sync fix - #25

Closed
utkarshdalal wants to merge 4 commits into
gamenativefrom
a56-release-one-flip-later
Closed

utkarshdalal wants to merge 4 commits into
gamenativefrom
a56-release-one-flip-later

Conversation

@utkarshdalal

Copy link
Copy Markdown

Problem

On KMS a page-flip event means the replaced framebuffer is free. On gamenative-drm the event arrives when SurfaceFlinger latches the new frame, but the replaced buffer stays on the panel until its release fence signals, about one vsync later. Dropping the FB at the event hands the client a buffer that is still being scanned out, which it then renders into. With the cursor plane (A55) this path is taken by every cursor-showing game, which is how the Two Point Campus reports started.

Change

  • A56 (0052-A56-release-framebuffers-one-flip-later.patch): under gamenative-drm page_flip_handler keeps the FBs a flip took off screen in m_RetiredFbIds and drops them at the next flip; a plane turned off drops both sets; finish_drm drops everything. Only the release moves; event, timestamp and visible bookkeeping are unchanged. GAMESCOPE_GN_RELEASE_AT_FLIP=1 restores the KMS behaviour. Swapchain depth is discussed in the patch header (pool 5 slots, DXVK 3 images, Xwayland allocates on demand, composite ring of 3 reused by index).
  • CI: libxcvt is built unversioned (soname libxcvt.so, as the shipped payload expects), the Xwayland checkout points at GameNative/xserver xwayland-no-implicit-sync-gamenative (Xwayland finishes GPU work before each present on gamenative-drm, xwayland: treat implicit sync as unsupported on gamenative-drm xserver#1), and the artifact includes the Xwayland binary.

Pairs with gamenative-drm scanout-flip-at-latch (the daemon sends the flip event at SurfaceFlinger latch, after the previous release fence).

Measured (Retroid Pocket 6)

  • Blazing Chrome (DXVK), cap 60: 59.5 fps, 79 % of intervals on the 2-vsync grid, no stalls.
  • SteamWorld Dig 2 (GL), with the Xwayland fix: 0 tears in 25 s against 23 on the shipped build, same scripted motion.

@joshuatam

Copy link
Copy Markdown
Collaborator

Closing: the tearing this patch addresses is fixed in gamenative-drm rather than in gamescope — GameNative/gamenative-drm#67.

A56 moves gamescope's release one flip later so a client never gets a framebuffer that is still being scanned out. The same guarantee now comes from the other side: the shim parks a slot until the daemon reports the display's own release, and only then hands the image back to the guest. Measured on device, tearing is gone on Portal 2 (declares IMMEDIATE, served MAILBOX) and Half-Life 2 under direct scan-out, with the same builds at Witcher 3 23.5 → 53.8 fps and Doom 2016 29.9 → 57.4.

Two reasons this landed in drm instead, both measured earlier in the branch:

  • A56 was tested as the fix and was not one — the release timing was correct and the tear persisted, which is what pointed at reuse on the shim side;
  • patching gamescope costs a payload rebuild and a second place to keep in step, and the shim already had the buffer in hand.

The CI work here (unversioned libxcvt, the Xwayland implicit-sync checkout) is unrelated to the tear and should be re-filed separately if it is still wanted.

@joshuatam joshuatam closed this Nov 13, 2026
@joshuatam
joshuatam deleted the a56-release-one-flip-later branch November 16, 2026 14:43
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