Repository navigation
Conversation
…rame; an idle turn makes it again The kept last frame (`render::damaged`, 9.2 MB at 1920x1200) stayed for the window's life. After `LONG_REST_AFTER` (60 s) with no frame, the rest machine gives it back and polls the device once without waiting, so wgpu frees it then. The first frame back draws whole straight into the drawable, making and copying nothing (frame-profile `whole`: "given back"). On Windows, the next idle turn with no input waiting (`post_frame`) makes it again and draws the frame whole into it, with no present.
…ffer (unseen); drop kept frame on Unseen
With two buffers at frame latency 1 the GPU can't start a frame until DWM gives back the buffer it draws into; while another window keeps the GPU busy that round trip takes two refreshes, and a scrolling list shows a new image every other refresh. A window created visible is created with three buffers (the frame latency stays 1, so input never waits behind a queued frame). Out of sight for the rest's long timer (60 s, shared with the kept last frame) it goes back to two; it grows back on a free turn once it can be seen again, never with input waiting and never within 250 ms of input. A refused third buffer keeps two for the window's life.
`Renderer::give_back_kept` lives in `render::damaged`, which only Windows and wasm build; the rest's GiveBackKept arm and GiveBackAll's call now build on Windows only (macOS keeps no frame).
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Commits, by author package:
The head isn't final yet: #1082 merges first. Then I merge |
Latency while animating: two buffers against threeSame measuring builds, frame latency 1 and the waitable swap chain in both arms; two buffers is
Slide rows are two tickets of 10 each, shown separately; their "seen" is a Desktop Duplication capture.
|
|
Closing: shelved (third swap-chain buffer, stacked on #1063); 13 files conflict with dev after the window/surface rework, no path to merge as is. Branch kept. |
Stacked on #1063 (MEMORY's shared 60 s rest timer): merge that first. This PR's own changes are its last two commits; the second makes that timer build on macOS. With two buffers at frame latency 1, the GPU can't start a frame until DWM gives back the buffer it will draw into. While another app keeps the GPU busy, that round trip takes two refreshes, so a scroll shows a new image every other refresh. A third buffer removes the wait. The frame latency stays 1, so input never queues behind an extra frame.
mermaid stateDiagram-v2 [*] --> Three: created visible and opaque [*] --> Two: created hidden or with alpha Three --> Two: hidden, minimised or covered whole for 60 s (Rest DropThirdBuffer) Two --> Three: free turn while visible, no input waiting, 250 ms after the last input Two --> Off: third buffer refused Three --> Two: resize or remade (grows back on a free turn)-window/depth.rs: the buffer-count state machine (Depth,DepthEvent,depth_turn,configure_depth). - Grow: only on a free turn: nothing to draw, no input waiting, and the swap chain's room free. Never withinHOLD(250 ms) of a wheel, key, press, touch or resize step, becauseResizeBuffersremakes every buffer (7–20 ms, scaling with the window's size). - Shrink: onRestEffect::DropThirdBufferfrom the rest's one long timer (window/rest.rs, #1063). There is no second timer. - Refused allocation: the window keeps two buffers for its life, and the process never exits for it. -vendor/wgpu-hal:dx12::Surface::set_extra_buffersadds buffers beyondmaximum_frame_latency + 1at the next configure;buffer_countreports them. Both are invendor/wgpu-hal.patch. ### Missed refresheslistscrolling at 240 Hz beside the OpenCode desktop, blade (Iris Xe), release, per-swap-chainGetFrameStatistics, 4 interleaved runs per arm, median: | | Two buffers (dev) | Three buffers (this PR) | |---|---:|---:| | Missed refreshes of ~717 | 292 | 3 | | Read-then-scroll onlist| 306 | 5 | ### Input during motion Posted key or click to its frame seen on screen, focused, pooled ABBA, n=20 per arm, median µs: | | Two | Three | |---|---:|---:| | Key during a scroll | 16,660 | 12,290 | | Click during a scroll | 15,901 | 11,338 | | Key during a slide | 11,341 | 11,399 | | Click during a slide | 12,555 | 10,555 | ### Start-up A window created visible configures three buffers in its first configure, so there is noResizeBuffersafter launch. Blade (Iris Xe), launches alternating ABBA, medians:nn| | Arm | n | First configure | GPU's first present, from the spawn |n|---|---|---:|---:|---:|n|list| Two | 10 | 5.6 ms | 193.8 ms |n| | Three | 10 | 6.8 ms | 191.6 ms |n| The app | Two | 8 | 5.8 ms | 239.5 ms |n| | Three | 8 | 6.5 ms | 236.1 ms |nnThe first configure takes about 1 ms more; the first frame on screen comes no later. In the app that configure runs on the GPU thread, off the UI thread. No window grew after launch. ### Memory One window-sized BGRA8 buffer while visible: 5,529,600 B at 1440×960, 14,745,600 B at 2560×1440. None after 60 s out of sight.hello` on blade (Iris Xe), GPU bytes, 3 runs per arm, median. Two buffers is the same build with the third turned off. | | Size | Two buffers | Three buffers | Difference | |---|---|---:|---:|---:| | Visible, 15 s after input | 1440×960 | 34,656,256 | 39,661,568 | +5,005,312 | | Visible, 15 s after input | 2538×1384 | 58,830,848 | 73,089,024 | +14,258,176 | | Minimised for 70 s | 1440×960 | 27,209,728 | 27,217,920 | +8,192 | | Minimised for 70 s | 2538×1384 | 44,060,672 | 44,064,768 | +4,096 |