Skip to content

Windows: frames: occlusion asked when drawing, no steady presents, one queued frame - #844

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

Hona merged 1 commit into
devfrom
present-frames

Conversation

@Hona

@Hona Hona commented Nov 13, 2026

Copy link
Copy Markdown
Member

On Windows, a window now draws only when it has something new to show, and stays asleep while it doesn't.

  • No hooks: the window no longer listens to every app's window events. Whether other windows cover it is checked when it's about to draw a frame: by walking the z-order, and by checking minimised, cloaked (another virtual desktop) and the lock screen. A covered window with a spinner checks again every 250 ms.
  • No steady presents: after each change, a focused window used to present every refresh for a second, for windowed G-SYNC (hex#689). On a fixed-rate display that changed nothing on screen. It now presents only real changes. On an NVIDIA display adapter, the swap chain composites premultiplied instead, which keeps G-SYNC off without extra frames.
  • One queued frame: a frame waits for room in the swap chain in the event loop, not inside acquire. Input that arrives during the wait goes into that frame.

Measured on a 240 Hz Iris Xe laptop (release, visible desktop). Keys are posted into OpenCode's composer, and Desktop Duplication finds the frame that shows each one:

Before After
Input to photon, focused, p50 32,958 µs 12,318-13,836 µs
Frames in a 40 s typing run 2,939 90
UI-thread CPU in those frames 150,754 µs/s 8,850 µs/s
Idle wakes per second, visible while another window moves 298.9 0.2
Idle wakes per second, covered while the cover moves 296.9 0.3

For comparison, a bare D3D11 window on the same present path takes 3,314-6,023 µs p50.

…e queued frame

- Occlusion: the rune-occlusion thread and its SetWinEventHooks are gone. platform/win32/occlusion.rs is a query (Chromium's z-order walk, minimised, cloaked, locked); window/look.rs is the machine: a frame looks when the last look is over 250 ms old or the window's own move, size or focus made it stale, and the pointer reaching the window counts as seen. A covered window runs no motion and still draws what changed, settled (CoveredDraw); only a covered window with a loop on screen looks again, every 250 ms. WakeEvent::Covered is replaced by WakeEvent::FrameSlot.
- Steady (a second of presents every refresh after each change, for windowed G-SYNC, hex#689) is removed: on a fixed-rate panel it changed nothing on screen. On an NVIDIA display adapter the swap chain composites premultiplied for good instead (cpu_frame::vrr_guard, VideoLayers::hold_premultiplied), which keeps G-SYNC off with no frames.
- Windows swap chains hold one frame (FRAME_LATENCY); wgpu doesn't wait on the waitable (DontWait). window/slot.rs takes the swap chain's room at the frame's start, or registers a one-shot thread-pool wait that asks for the frame when there is room, so input that arrives meanwhile is in it.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 00:03

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 b459621 into dev Nov 13, 2026
1 check passed
@Hona
Hona deleted the present-frames branch November 13, 2026 00:03
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