Skip to content

perf(render): backdrop copies hold the blurred regions, not the window - #2137

Merged
Hona merged 8 commits into
devfrom
memory-b/backdrop-region
Nov 25, 2026
Merged

Hona merged 8 commits into
devfrom
memory-b/backdrop-region

Conversation

@Hona

@Hona Hona commented Nov 25, 2026 •

Copy link
Copy Markdown
Member
  • Renderer::ensure_backdrop made one window-sized texture per target format whenever a frame held a backdrop blur, however small the blurred element. The blur's pyramid was already sized to the region; the copy it reads from was not.
  • Now every pooled copy holds the frame's blurred regions: Renderer::backdrop_frame gives them one place and size (in 64 px steps; a texture stays while it holds the regions and isn't four times their area), ActivePass::split copies into it at that offset, and the first down pass maps its taps against it.
  • An effect that reads what is below it (EffectSite::backdrop) still gets a copy of the whole target at the target's own size.
pub(super) struct Backdrop {
    pub(super) format: wgpu::TextureFormat,
    pub(super) texture: wgpu::Texture,
    pub(super) view: wgpu::TextureView,
    /// Where its first texel sits in the window, in device pixels.
    pub(super) origin: [u32; 2],
}
flowchart LR
  subgraph before
    W1[window 2560x1440] --> C1[BGRA8 copy 2560x1440, 14 MB]
    W1 --> C2[RGBA16F copy 2560x1440, 29 MB]
  end
  subgraph after
    W2[window 2560x1440] --> R[blurred regions] --> C3[BGRA8 copy 128x64]
    R --> C4[RGBA16F copy 128x64]
  end
Loading

Memory

A desktop app with one frosted pill on screen (a session scrolled away from its end), Intel Iris Xe, Direct3D 12. Two Windows x64 builds of the app from one tree, the after side with this change's commit as its Rune pin; private working set (Task Manager's "Memory"), one run a side, each after a throwaway launch of its own build. On this adapter the driver maps every texture into the process, so the copies count in that number.

2560x1440 window before after
at rest, a restored 150-turn session 57.3 MB 58.4 MB
20 sessions opened and scrolled, the pill on screen 134.1 MB 92.9 MB
13 s after the last input 131.7 MB 90.5 MB
textures mapped into the process 61.3 MB 19.8 MB
GPU shared memory 106.9 MB 65.3 MB
1920x1200 window before after
three more sessions opened and scrolled 103.2 MB 77.5 MB
back on the home screen, 60 s 73.5 MB 73.8 MB

On builds that count the renderer's textures (same scene at 2560x1440): pooled backdrop copies 2 textures, 42,992,640 B before; 2 textures, 98,304 B after.

Pixels

Headless pictures of the app, before against after, with lines of text under the frosted pill. Differing pixels:

scene 1920x1200 px 1500x1050 px 2561x1440 px
a streaming reply scrolled away, the pill over text, at 9 s and at 12.5 s (fixture, simulated time) 1 and 1 1 and 1 0 and 0
the same before the scroll (no pill) 0
the before build against itself, the pill over text 0
a session of long paragraphs scrolled up 4 and 7 wheel notches (live server) 0 and 1 0 and 0 0 and 0
the composer's drop zone, a backdrop blur over the whole timeline (live server) 0 0 0
  • Every differing pixel is one pixel inside the pill, one channel off by 1 of 255, the same pixel each time a scene is repeated. The first down pass now maps its taps against a 128x64 copy instead of a window-sized one, so a tap's place rounds differently.

Frames

Two pairs of app builds, each pair from one tree with only this change between its sides and the same profile counts but for the functions this change touches. Real windows and headless runs on a busy machine; a frame row's own spread among calm runs is about a quarter here.

the frame where the pill first shows (a cold launch, a reply streaming) before after
wheel 4 s after start, the app at Rune d5c7a5ad2 (four runs a side) 37.6, 33.8, 34.4, 14.9 ms 20.8, 13.4, 12.8, 14.2 ms
wheel 8 s after start, same pin (two runs a side) 15.0, 33.3 ms 19.7, 17.9 ms
wheel 8 s after start, the app at Rune ffea1a6ea (two runs a side) 13.8, 16.0 ms 13.6, 13.1 ms
CPU per frame, headless, 1,381 frames a run, medians of four calm runs before after
a reply streams while scrolled away, the pill on screen: mean 1.790 ms 1.820 ms
the same: 95th percentile 3.408 ms 3.584 ms
the same reply at its end, no pill (this change draws nothing here): mean 1.683 ms 1.839 ms
the same: 95th percentile 3.426 ms 3.770 ms
launch, files in memory, 24 alternating pairs, the app's own clock, medians before after paired
first frame 35.0 ms 34.4 ms -0.5 ms
content live 50.5 ms 48.7 ms -0.5 ms
  • Launch: no change, memory-low (the machine was short of memory during the series; every stretch is inside the margin, the sides split near even).- On the frame where the pill first shows, the before side makes the two pooled copies at the window's size (27.6 MB at 1920x1200) and the after side two of 128x64. That is by reading; no recording names the resource.
  • The row without the pill moved more than the row with it, and each run's mean follows the machine's load: the per-frame difference is not the copies. Four runs show no large cost; they cannot show or exclude a small one.

Tests

Rune's macOS tests on this branch's head 4dcc833ff (dev 0b89a5cd9 taken in), run 45665099792: all 47 test binaries passed; rune's unit tests 3670 passed, 0 failed.

  • New: render::backdrop_tests::a_blur_alone_pools_a_copy_of_its_region_not_of_the_window: a red / blue seam under a 64x32 pill in a 1024x768 target blends and stays sharp away from the pill; the copy is region-sized; a moved pill makes no texture; an effect slot still gets a copy of the whole target.
  • The tests ran on Metal. The memory rows, the pictures and the frame rows above are Direct3D 12.

@Hona
Hona marked this pull request as ready for review November 25, 2026 17:35
@Hona
Hona merged commit 86bdf9b into dev Nov 25, 2026
6 checks passed
@Hona
Hona deleted the memory-b/backdrop-region branch November 25, 2026 17:38
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.

1 participant