Skip to content

Early present commit and present-reap thread (VKBRIDGE_PRESENT_EARLY / VKBRIDGE_PRESENT_REAP) - #84

Open
pgm1207 wants to merge 3 commits into
ASEbrahim:mainfrom
pgm1207:pr/4-present-early
Open

pgm1207 wants to merge 3 commits into
ASEbrahim:mainfrom
pgm1207:pr/4-present-early

Conversation

@pgm1207

@pgm1207 pgm1207 commented Nov 16, 2026

Copy link
Copy Markdown

Problem

The Wayland commit waits for GPU completion. This PR is independent of the swapchain-image PR (VKBRIDGE_SWAPCHAIN_IMAGES); the numbers below were measured with 6 images, which that PR makes possible. With 6 swapchain images, committing early moved the menu from 102 to 118 fps.

Change

  • VKBRIDGE_PRESENT_EARLY: commit as soon as the fence is imported into the dma-buf (the compositor waits on the fence).
  • VKBRIDGE_PRESENT_REAP: thread "vkb-present-rp" that reaps completed presents. Effective only together with EARLY. Gain 118 -> 118.5.
  • tests/present_early_check (needs /dev/udmabuf), passing on an Intel laptop.

How tested

Host quick-check 14/14 (RADV), present_early_check pass (Intel). Device runs on Poco (menu and Megabonk) and CMF Phone 1 (menu).

Evidence

Verified on the Poco (menu; log shows about 103 early commits/s, 0 fallbacks, 0 import errors): 102 -> 118 with early present plus 6 images, 118 -> 118.5 with present reap. The image count alone gives about 117 (PR 3), so early present is not isolated on the Poco; it is on CMF Phone 1 only as a single off-run. CMF Phone 1: early present off 68.6, present reap off 71.2 vs about 76 (n=1 each, menu only). In game on CMF Phone 1: no measurable effect (GPU-bound). Not measured: early present alone on the Poco, other GPUs.

Devices: Poco X8 Pro Max (2602BPC18G, Immortalis-G925) and CMF Phone 1 (A015, Mali-G615 MC2, MT6878, 120 Hz). Test app: MaliDeck (a re-signed DroidDeck 0.7.1 test build). Wireless adb. No power numbers are claimed: some runs were USB- or AC-powered.

Steam menu, fps while moving Poco X8 Pro Max CMF Phone 1
stock-like (all new defaults off) 75 (shipped build) 28.7 and 33.2 (2 runs)
all new defaults on 118.5 77.0 and 74.7 (2 runs)

CMF Phone 1, one default turned off at a time (n=1, 30 s each; none off is about 76): ANGLE=vulkan off 37.1, 6 images off 56.6, pass-through off 66.0, early present off 68.6, present reap off 71.2, async create off 74.0.
Poco, cumulative steps: 75 -> 84 (web UI on ANGLE Vulkan) -> 90 (async create) -> 102 (pass-through) -> 118 (early present + 6 images) -> 118.5 (present reap). Frames on the 8.3 ms slot: 71-76 % -> 98.8 %.
Megabonk in game, Poco, 75 s after a 30 s warm-up, p7 vs stock: 83.3 vs 77.9 fps and 110.9 vs 92.3 fps (n=2 per arm, different scenes). A gain of about 5-10 fps is plausible, not proven. CMF Phone 1, Megabonk, p8 defaults vs stock (stock 21.6 and 22.0; p8 20.9, 17.6, and 24.5 with tracing on): no measurable difference, scene noise about 3 fps; the game is GPU-bound there (GPU done 23 ms after commit against a 40 ms present interval), so these toggles are not shown to help a GPU-bound game. No power numbers on CMF Phone 1.

Limitations: attribution rows are single 30 s samples. In-game A/B has scene noise (n=2 per arm). On CMF Phone 1 an "Offline Mode" popup was on screen in all menu runs, so absolute fps may differ from a clean menu. A forced-composite vs pass-through flicker comparison was run only in CMF Phone 1 Megabonk (6 screenshots each, no flicker or tearing seen either way, fps equal within noise); not on the Poco. In the Poco game flicker check, 78 of about 79 composite_why lines were layers=1 / composite=0, one was layers=2, and one frame was black at the Guide-button transition. On CMF Phone 1 the menu was GPU-limited (GPU at max clock 36-97 % of the time) and showed no flicker with pass-through. Quick 30 s menu runs are screening only, not benchmarks. In game the Poco is limited by game CPU and GPU together; the 11 stalls over 50 ms came from game loading/GC, not the bridge.

How to reproduce

Set the toggle named in this text (others at their defaults), open the Steam menu, move the pointer for 30 s, and read frame intervals from the compositor/gamescope frame log (intervals under 100 ms count as in motion). Raw runs and scripts are available on request.

Risks

Relies on the compositor honouring the explicit fence. In-game flicker was checked once on the Poco (see Limitations); that is not proof for other devices. DroidDeck already forces composite on Mali-G76 because of flicker.

Toggles / defaults

EARLY: off. REAP: on, but inert without EARLY. Both checks are in the Evidence section; I leave the default decision to you.

Dropped

Nothing in this PR.


[Disclosure: I prepared this change and text with the help of an AI assistant. The measurements come from real device runs; the limits are stated above.]

…is imported into the dma-buf

Off by default. With VKBRIDGE_PRESENT_EARLY=1 the presenting thread does not wait for a frame's rendering before it commits the
frame to the compositor: the frame's submit also signals an exportable binary semaphore, its sync file is attached to the frame's
dma-buf as a write fence (DMA_BUF_IOCTL_IMPORT_SYNC_FILE, client/dmabuf_attach.c), and the compositor waits on the fence in the
buffer itself. Any failure (no sync-fd export, no ioctl, an import error) switches the swapchain back to commit-after-fence and is
logged; a "present early: N frames, fallback N, import errors N" line is logged with VKBRIDGE_STATS.
Checks what VKBRIDGE_PRESENT_EARLY rests on, on a real dma-buf: a submit signals a sync-fd exportable semaphore, the sync file attaches
to a udmabuf as a write fence, and a reader polling the dma-buf is not woken before the submit's GPU work is done. Skips (exit 77)
without /dev/udmabuf, sync-fd export or the ioctl.
… thread (default on, only with VKBRIDGE_PRESENT_EARLY)

With VKBRIDGE_PRESENT_EARLY a frame is already committed when the presenting thread still has to wait for its rendering (for the
latency accounting and to reuse its fence). That wait ran on the presenting thread and delayed the next queued frame by the GPU time
of the previous one. A "vkb-present-rp" thread now does it, so the presenting thread picks up the next frame at once.
VKBRIDGE_PRESENT_REAP=0 puts the wait back on the presenting thread. No effect without VKBRIDGE_PRESENT_EARLY.
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.

1 participant