Skip to content

fix(rune): Windows resize reuses display-sized buffers between steps - #1065

Closed
Hona wants to merge 1 commit into
devfrom
present-resize-bounded
Closed

Hona wants to merge 1 commit into
devfrom
present-resize-bounded

Conversation

@Hona

@Hona Hona commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Windows: each step of a live resize called ResizeBuffers, which waits for every frame the GPU has in flight and then makes new buffers. On a single display in the measured envelope, the window now keeps swap-chain buffers the size of its display while it's resized, draws each step at its own size into the renderer's kept frame, and copies that frame into the top-left. One second after the last step, outside the system's size loop, the buffers go back to the window's size.

stateDiagram-v2
    [*] --> Exact
    Exact --> Growing: resize, display measured
    Growing --> Filled: exact-size frame presented
    Filled --> Larger: grow to display size
    Larger --> Larger: resize on same display
    Larger --> Exact: 1 s after last step, outside size loop
    Exact --> Fallback: unmeasured display or size, alpha, no COPY_DST
    Growing --> Fallback: display changed
    Filled --> Fallback: growth refused (OOM or configure error)
    Larger --> Fallback: ScaleFactorChanged, moved to another display, drawable size mismatch
    Fallback --> Fallback: today's exact-size path for the window's lifetime
Loading
  • Measured envelope (window/buffer.rs, Display::measured): one active monitor (SM_CMONITORS == 1), scale 1.5, a monitor up to 2560×1440, a client up to 2180×1420 (grow) or 2488×1406 (maximised). Anything else takes Fallback, which is dev's path.
  • First step stays exact. DWM shows the new size with that frame. The buffers grow only after it is presented (Filled), so no empty, larger buffer is ever shown.
  • Leaving early: a WM_DPICHANGED (ScaleFactorChanged), a move to another monitor, a drawable whose size doesn't match, or a refused growth (an OutOfMemory error scope around the configure) reconfigures at the exact size and resets the slot and damage history.

Blade, Iris Xe, 2560×1440 at 240 Hz, with the OpenCode desktop drawing beside it (about 18% GPU). Benchmark-release apps (not shipping PGO), measured on b2b3cea5, which is this diff on bc05f817:

Row dev (bc05f817) This PR
SetWindowPos answered, p50 of 40 steps, 5 runs 19,344–27,512 µs 2,345–2,837 µs
Unfilled frames, gbench resize (per run) 0, 0, 0, 0, 1 0, 0, 0, 0, 0
GPU memory at rest (hello, 1440×960 client) 32,550,912–32,559,104 B 32,555,008 B
GPU memory peak during a 40-step grow (3 runs) 46,051,328–48,029,696 B 56,639,488–77,586,432 B
GPU memory 1 s after the last step 33,439,744–33,447,936 B 29,671,424–30,855,168 B
Maximised (2488×1406) / restored 50.5 MB / 33.4 MB 46.7–47.9 MB / 30.2–31.4 MB
Grow: images with unfilled pixels 5, 6, 5 (up to 98,610 px) 0, 0, 0
Grow: SetWindowPos p50 18,761–19,577 µs 1,267–1,372 µs
  • The cost is memory, only while a resize runs. The peak is 8.6–29.6 MB above dev's. The bound:
    • The swap chain's buffers at the display's size: 2 × width × height × 4 B, which is 29,491,200 B at 2560×1440. Display::measured caps the display at 2560×1440, so this is the largest it can be.
    • The kept frame at the window's size: at most 2488 × 1406 × 4 = 13,992,512 B inside the envelope.
    • The exact-size buffers the first grow replaces: they stay until the device's frees run.
  • It is gone within a second. SETTLE (1 s after the last step, outside the size loop) configures the exact size, drops the kept frame and polls the device's frees. One second after the last step, GPU memory is 2.6–3.8 MB below dev's. Memory at rest is unchanged.
  • 4K (computed, not measured): two 3840×2160 BGRA8 buffers hold 66,355,200 B of pixels. A 4K output is outside the envelope, so it takes Fallback today.
  • Not measured: a mixed-DPI drag, a second monitor, and 3440×1440. All of them take Fallback.

Present the first new size before growing the buffers. Keep subsequent frames at the client size, fill exposed edges, and release the headroom after resizing settles. A different scale or monitor, larger or unknown dimensions, or a refused growth uses exact-size buffers for the rest of the window's lifetime.
Copilot AI balanced review requested due to automatic review settings November 16, 2026 09:02

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 commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Closing (owner's decision): this predates the window/surface rewrite (6 conflicts); if live-resize lag is measured on Windows, redo it on the new window/surface code. Branch kept.

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