Skip to content

M5.6: with a GPU, a slider drag's preview is drawn in the frame of the drag tick - #1413

Merged
bflatastic merged 1 commit into
storytold:mainfrom
dev-null-undefined:claude/same-frame-drafts
Oct 13, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
dev-null-undefined:claude/same-frame-drafts

Conversation

@dev-null-undefined

@dev-null-undefined dev-null-undefined commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The problem

During a drag, a frame applies the tick (develop.set), the loupe asks for a draft, and the frame ends. On the GPU the draft is ready a few milliseconds later. Renderer::poll only collects it at the start of the next frame, so it reaches the screen one frame later than it could. At 1920×1200 that frame is most of the time from tick to texture: a median of 18.5 ms, while the GPU drafts take a few milliseconds.

Changes

  1. Renderer::wait_for_draft. Right after the loupe asks for its draft during a drag, it waits for it, turning finished jobs into textures as they arrive, so the draft is drawn in the same frame. The wait is at most 40 % of a frame (egui's predicted_dt, clamped to 1/240–1/30 s).
    • It only waits when the last loupe render took well under that budget (×1.5 margin: 4.4 ms at 60 Hz). A CPU render, which would only make the frame late, isn't waited for.
    • It doesn't wait with a render offload (the web's workers), on wasm, or zoomed in, where what changes on screen is the zoom window's draft.
  2. JobPool::wait(timeout). Waits for the next finished job and keeps it for try_recv.
  3. Renderer::poll. Its loop over finished jobs moved, unchanged, into collect, which the wait also calls.

Result

main → this branch. Each value is the median of 3 runs. Second Exposure drag on the raw, 30 ticks at 60 Hz, GPU drafts, driven headlessly through the real app:

main this branch
1920×1200 @1× (draft 831×554): drafts shown 23, 19, 28 of 30 27, 23, 21 of 30
tick → texture, median / p90 18.5 / 43.9 ms 6.2 / 10.2 ms
frames from tick to texture, median 1 0
UI thread time per frame, median 1.8 ms 5.6 ms (includes the wait)
2560×1440 @1.5× (draft 1599×1066): drafts shown 19, 18, 16 of 30 16, 15, 16 of 30
tick → texture, median / p90 20.2 / 61.9 ms 21.4 / 68.6 ms

Measured on a Sony ILCE-7RM6 64 MP compressed raw (private photo), an RTX 4070 Ti SUPER (Vulkan) and a Ryzen 7 9800X3D. The app ran under a 4-CPU cgroup quota that other builds kept saturated during every run, so the p90s are noisy.

Verification

Related

…e drag tick

A drag tick requested the loupe's draft and the frame ended; the draft,
done in 1.5-3 ms on the GPU, was picked up at the start of the next frame,
a frame after the slider moved. Now, in a drag, the loupe waits up to 40 %
of a frame for its draft when the last loupe render took well under that
(not with a render offload, nor zoomed in, where what changes on screen is
the window's draft). A CPU render, which would only make the frame late, is
not waited for.

JobPool::wait waits for the next finished job, which try_recv then hands
out; Renderer::poll's collection of finished jobs is split out so the wait
can turn the draft into the texture.

Co-Authored-By: Claude <noreply@anthropic.com>
@bflatastic

Copy link
Copy Markdown
Member

Landed on main in #1431. Thank you, @dev-null-undefined!


Generated by Claude Code

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