Skip to content

Windows: a frame redraws and presents only what changed - #852

Merged
Hona merged 1 commit into
devfrom
present-damage
Nov 13, 2026
Merged

Hona merged 1 commit into
devfrom
present-damage

Conversation

@Hona

@Hona Hona commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

On Windows, a frame now redraws and presents only the part of the window that changed.

  • What changed: each frame's instances are compared with the last frame's. The lists' common start and end are skipped. An instance whose bytes are in both lists didn't change, wherever it moved in the list. The bounds of the instances only one list has become at most four rectangles.
  • Redraw: the renderer keeps the last frame in its own texture and redraws only those rectangles into it. Each rectangle gets a clear quad, then every instance with its scissors kept inside the rectangle. The texture is then copied to the drawable: wgpu treats an acquired drawable as empty, so Rune can't draw over it.
  • Present: only those rectangles are presented, through Present1 dirty rectangles. The vendored wgpu-hal makes flip-sequential swap chains, which partial presents need, and gains Surface::set_present_rects.
  • When it draws whole: for an effect slot, backdrop blur, GPU springs, a native surface, a turned or blurred layer, a changed image, a new size or clear colour, or a change that covers most of the window. A compositor's Frame::draw_ui takes the partial path too.
  • RUNE_WHOLE_FRAMES=1 draws every frame whole, for checking partial frames against.

Measured typing into OpenCode's composer, 1350x900 px on a 240 Hz Iris Xe, release build. Keys are posted at random moments in the refresh. Desktop Duplication timestamps when each key reaches the screen, and PresentMon gives the GPU time:

Whole frames (#844) Partial frames
GPU per key frame, p50 4,170 µs 890 µs
Present to on screen, p50 13,020 µs 7,140 µs
Input to photon, p50 12,318 µs 7,782 µs
Keys shown at the 2nd refresh after the key or sooner 12 of 120 71 of 80

For comparison, a bare D3D11 window on the same present path takes 4,686 µs p50.

A spinner's frame redraws a 19x24 px square. After the same run of keys, the screen with partial frames matches the screen with RUNE_WHOLE_FRAMES=1 exactly (0 of 1,215,000 pixels differ).

- window/damage.rs: the instances that differ from the last frame's (common start and end skipped; in the middle, an instance whose bytes both lists have didn't change; reordered common instances mean everything changed), their bounds gathered into at most four rectangles; a frame draws whole when the size or clear colour changed or most of it changed.
- render/damaged.rs: the renderer keeps the last frame in a texture of its own, redraws the armed rectangles into it (a clear quad, then every instance with its scissors kept inside the rectangle, ActivePass::borrowed_within) and copies it to the drawable, which wgpu treats as empty when acquired. draw (so a compositor's Frame::draw_ui) takes the armed rectangles; effects, backdrop blur, GPU springs, native surfaces and turned or blurred layers draw whole. The window reads back what happened every frame.
- Vendored wgpu-hal: flip-sequential swap chains (partial presentation needs them) and Surface::set_present_rects, presented with Present1's dirty rectangles. The swap chain's usage takes COPY_DST.
- The frame log gains damage, whole (why a frame drew whole) and change.
- RUNE_WHOLE_FRAMES=1 draws every frame whole, to check partial frames against.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 01:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

@Hona
Hona merged commit e1d5cd4 into dev Nov 13, 2026
1 check passed
@Hona
Hona deleted the present-damage branch November 13, 2026 01:37
Hona added a commit that referenced this pull request Nov 16, 2026
Partial frames (#852) redraw changed rectangles into a window-sized texture the renderer keeps, and copy it to the drawable. The first partial frame makes it and nothing gave it back: after a session is open and closed, Home holds it for the window's life (9,708,544 B of GPU memory at 1920x1200 on an Iris Xe, mapped into the process as private bytes). Rest now drops it with the other textures it gives back; the next partial frame finds no kept frame and draws whole into a new one, as the first one does.
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