Skip to content

perf(umbrielfx): unified transient scratch pool, cache eviction, fused blur, and bounded captures - #965

Open
ZhangDM-520 wants to merge 1 commit into
noctalia-dev:mainfrom
ZhangDM-520:perf/umbrielfx-bandwidth-rework
Open

ZhangDM-520 wants to merge 1 commit into
noctalia-dev:mainfrom
ZhangDM-520:perf/umbrielfx-bandwidth-rework

Conversation

@ZhangDM-520

@ZhangDM-520 ZhangDM-520 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Unifies the umbrielfx offscreen buffer pool, persistent blur cache eviction, half/quarter-res fused blur, and bounded capture optimizations into a single coherent rework:

  • Transient scratch pool (fx_scratch_pool): Replaces struct fx_target_buffers (output / group) and per-slot scratch fields with a per-output transient FBO pool keyed by (width, height, drm_format) with 2-idle-frame eviction (fx_scratch_acquire, fx_scratch_release, fx_scratch_end_frame).
  • Persistent blur cache eviction: Ages and evicts optimized_blur_buffer / optimized_no_blur_buffer after 2 idle frames via fx_offscreen_buffers_age_optimized_blur, wired to consumer-gated dirty uncull and on-demand rebuild. Drops optimized_no_blur_buffer when skip_optimized_no_blur is set so partial-strength blur never re-blurs a stale wallpaper.
  • Half/quarter-res fused blur + capture-box offset sampling: Stores optimized_blur_buffer at half resolution and fuses the final upsample. Samples optimized_blur_buffer at the accumulated pass->animation_boxes offset so bounded/offset captures (drag, physics deform, window move, open/close) use the wallpaper-only optimized cache instead of falling back to live blur. Uses optimized_blur_target_aligned(pass) in fx_render_pass_add_optimized_blur so output-sized depth-1 workspace captures can still rebuild the cache.
  • Bounded captures & shadow reuse: Bounded drag deformation, depth-1 zero-copy backdrop, 128 px quantized capture boxes, and shadow caster reuse.
  • Tests: Added perf-budget-scratch-pool-eviction and perf-budget-persistent-cache-eviction (umbrielfx/tests/perf_budget.c), and updated color.c / effects.c assertions.

Motivation

Previously, fx_offscreen_buffers owned a fixed set of output-sized offscreen buffers per feature with separate lifetimes, holding tens of megabytes of idle VRAM and causing FBO allocation thrash when bounded captures, blur, and deformation interacted. Replacing them with a single transient scratch pool and unified cache eviction cuts idle VRAM and offscreen fill-rate without per-feature buffer proliferation.

Type of Change

  • Refactoring

Testing

  • clang-format --dry-run -Werror on all modified C/C++ files: PASS
  • ninja -C build-debug umbriel umbrielfx/umbrielfx-perf-budget-test: PASS (0 warnings)
  • UMBRIELFX_TEST_DRM_DEVICE=/dev/dri/renderD128 meson test -C build-debug --suite umbrielfx: 81/82 PASS (only pre-existing host umbrielfx-egl-abi fails)
  • just check output/direct_scanout_state layout/struts: PASS

Checklist

  • This PR is ready for review, or it is marked as Draft.
  • This change fits SCOPE.md, or its scope was agreed in an issue or on Discord first.
  • I read and followed the relevant guidance in CONTRIBUTING.md.
  • I ran just format, or this PR has no C++, shader, or Markdown changes.
  • I ran the relevant build, test, lint, or verification commands, or explained why they were not run.
  • I functionally verified compositor behavior where automated checks are insufficient.
  • I self-reviewed the changes.
  • I checked for new warnings or errors.
  • I updated docs/ and examples/config.toml, or this PR does not change user-facing configuration or behavior.
  • I used canonical names for config keys, IPC actions, paths, and identifiers.

Additional Notes

@talia-ci talia-ci Bot 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.

Talia preliminary review

Check Result
Merge score 🟡 3/5 — Minor changes needed before merging
Findings 🟡 2 medium
Review depth 2/5 — how thoroughly the changed code could be checked by reading it
Coverage 25 of 25 changed files reviewed

What Talia checked: Read the full wlr_scene.c, fx_pass.c, fx_offscreen_buffers.[ch], effect and src diffs; confirmed the always-zero skipped-depth tracking is dead, but could not fully validate blur half-res src/dst scaling or scratch-buffer aging within budget.

Findings

# Severity Finding Location
1 🟡 P2 Dead skipped_persistent_depth render state added by the animation-capture rewrite umbrielfx/types/scene/wlr_scene.c:1012
2 🟡 P2 Dead skipped_persistent_depth/skipped_depth tracking in render path umbrielfx/types/scene/wlr_scene.c:4862

Each finding is explained in a review comment on its line.

Run details
  • Commit reviewed: bd6889d
  • Source lookups: 114 file reads, 92 searches
  • Prompt version: 859b7490ca3d

Preliminary automated review: Talia read the changed code and related source; nothing was built, run or tested, and AI can make mistakes. It is not a scope acceptance or a promise to merge; a human reviewer makes the final call. See our ethos.

Comment thread umbrielfx/types/scene/wlr_scene.c Resolved
Comment thread umbrielfx/types/scene/wlr_scene.c Resolved
@ZhangDM-520
ZhangDM-520 force-pushed the perf/umbrielfx-bandwidth-rework branch from bd6889d to 68aef31 Compare December 1, 2026 14:48
@ItsLemmy

ItsLemmy commented Dec 2, 2026

Copy link
Copy Markdown
Member

Hey, thanks for the PR Zhang! I've been running it on my ThinkPad and VRAM dropped by about 35%, nice work!

A few things before merging:

Needs a fix

  • Window open/close animations: a blurred window (default blur_optimized) shows the windows behind it during the animation, then snaps back to wallpaper-only blur. I can reproduce it reliably. The new 128 px capture boxes fail optimized_blur_target_aligned (fx_pass.c:3147), so blur inside them falls back to live blur, and the backdrop has no blur margin, so the box edges also clamp. Reading the optimized cache at the capture box offset should fix both.

Question

  • fx_render_pass_add_optimized_blur now returns early when animation_depth != 0 (fx_pass.c:3485). render_workspace_scene draws inside output-sized depth-1 captures, so the cache can't rebuild during a workspace switch, which main allowed. Is the guard needed? If not, if (!optimized_blur_target_aligned(pass)) return false; keeps that path working.

Smaller things

  • fx_scratch_end_frame: leases are released before it runs, so a buffer reaches idle_frames == 1 in the frame it was used and is freed after one idle frame, not two. > instead of >= fixes it; the effects.c scratch.count == 0 check then needs a second idle frame.
  • fx_render_pass_add_optimized_blur with skip_optimized_no_blur keeps the old optimized_no_blur_buffer and still marks the cache valid, so a later partial-strength blur can re-blur a stale wallpaper. Dropping the buffer when skipping avoids that.
  • perf_bench.c: H1/H2 bind to slot 0 (FX_SLOT_WINDOW, the in-place persistent slot), so the drag slot, bounded deformation and box captures are never exercised, and the timing stops before the GPU work runs (glFlush only). Since nothing runs it, please drop it along with the stats counters only it reads (blur_passes, offscreen_pixels_written, backdrop_copies, shadow_caster_reuses, cumulative); perf_budget.c only needs alloc_count and the live byte totals.
  • color.c: the extra render_metadata_scene call hides that dropping blur strength from 1.0 to 0.5 now rebuilds the cache. Please assert the rebuild on the first frame and direct rendering on the second.
  • effects.c: scratch.count == 1 no longer tells an in-place copy from a capture. Wrapping the render in fx_renderer_fail_animation_capture_for_test would.
  • fx_render_pass_optimized_blur_stale is now only used by a test and can go.

Split
The pool, eviction, blur and capture changes belong together, fine to keep them in one PR.

Please move the parts that don't use the pool into a separate PR: finishQuantizedSpringTail, the vblank-seeded focus dim, and the 8-bit setter checks. Two notes for that PR: skip the tail cut when an animation effect is bound (the fade then drives umbriel_progress, not alpha), and handleFrame can call latestVblankMsec() so the time sampling isn't duplicated.

Also, please close #837, #840 and #844; they stay available for reference once closed and this helps unclutter the queue.

I'll keep running it for a bit on the lappy, to ensure I don't discover any other regression.

@ZhangDM-520

ZhangDM-520 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor Author

I have reproduced it, my live test missed this case, thanks for pointing it out! greatly grateful for correction. I will look further per your findings and split the PR into refactor part (pool) and behaviour fixes (bounded animation, quantization and etc)

I will update when it's ready.


i mistakenly force-pushed the PR split with review fixes, making the history obscure... my bad. I am summarizing the changes. i have split the PR (both are independent) and addressed the findings you flagged out, also some more problem found.

  • Sample optimized_blur_buffer at the accumulated pass->animation_boxes offset in fx_render_pass_add_blur / render_blur_composite so bounded/offset captures (drag, deform, window move, open/close) use the wallpaper-only cache instead of falling back to live blur.
  • Replaced the animation_depth != 0 guard in fx_render_pass_add_optimized_blur with if (!optimized_blur_target_aligned(pass)) return false; so output-sized depth-1 workspace captures can still rebuild the cache.
  • Fixed the fx_scratch_end_frame off-by-one (> instead of >=, using FX_OFFSCREEN_IDLE_FRAME_LIMIT = 2) so scratch buffers evict after 2 idle frames instead of 1.
  • Dropped optimized_no_blur_buffer (releasing its owned wlr_buffer) when skip_optimized_no_blur is set so later partial-strength blur never re-blurs a stale wallpaper.
  • Made scratch and optimized blur caches age during direct scanout via non-allocating fx_offscreen_buffers_lookup so idle allocations evict during fullscreen scanout.
  • Removed perf_bench.c, quantized-opacity-setter, fx_render_pass_optimized_blur_stale, fx_render_pass_note_shadow_caster_reuse, and unused stats counters, keeping only alloc_count, live_scratch_bytes, and live_cache_bytes for perf_budget.c.
  • Updated color.c to assert cache rebuild on the first 0.5f frame and direct rendering on the second, and update effects.c to wrap the in-place render in fx_renderer_fail_animation_capture_for_test and add a second idle frame.
  • Split the non-pool animation changes (finishQuantizedSpringTail with effect-preset guard and rounding-cell check, latestVblankMsec reused by handleFrame, and vblank-seeded focus dim) into perf(animation): cut 8-bit spring tails and seed focus dim from vblank #971 and dropped the lossy 8-bit setter guards.

marking it ready.

@ZhangDM-520
ZhangDM-520 force-pushed the perf/umbrielfx-bandwidth-rework branch from 68aef31 to 1b068e3 Compare December 2, 2026 05:38
@ZhangDM-520 ZhangDM-520 changed the title perf(umbrielfx): unify scratch FBO pool, cache eviction, and 8-bit dirty checks perf(umbrielfx): unified transient scratch pool, cache eviction, fused blur, and bounded captures Dec 2, 2026
@ZhangDM-520
ZhangDM-520 force-pushed the perf/umbrielfx-bandwidth-rework branch 2 times, most recently from 327be23 to 898fd93 Compare December 2, 2026 06:06
ZhangDM-520 added a commit to ZhangDM-520/umbriel-nightly that referenced this pull request Dec 2, 2026
Split out from noctalia-dev#965 as requested in review:

- Add AnimatedValue::finishQuantizedSpringTail(255.0) to stop overdamped alpha springs once remaining displacement stays strictly within the target's 8-bit rounding cell, skipping the cut when an animation effect preset is bound (Layers / DimUnfocused).
- Add Output::latestVblankMsec() (reused by Output::handleFrame()) and AnimatedValue::seedStartMsec() to seed focus-dim transitions from the latest vblank so the first tick advances immediately.

Assisted-by: LLM (human-reviewed)
Signed-off-by: ZhangDM-520 <jixianqiang1540@gmail.com>
…d blur, and bounded captures

Replace per-feature output-sized offscreen buffers with a per-output transient fx_scratch_pool keyed by (width, height, drm_format) with 2-idle-frame eviction, and unify the umbrielfx bandwidth/memory improvements:

- Transient scratch pool (fx_scratch_pool) replacing struct fx_target_buffers and per-slot scratch fields, eliminating FBO allocation thrash on drag/deform/shadow frames.
- Persistent optimized blur cache aging/eviction (2 idle frames) with consumer-gated dirty uncull and on-demand rebuild, plus dropping stale optimized_no_blur_buffer when skipped.
- Half/quarter-resolution fused blur and half-resolution optimized_blur_buffer, with capture-box offset sampling so bounded/offset captures (drag, deform, window move, open/close) sample the optimized blur cache directly.
- Bounded drag deformation, depth-1 zero-copy backdrop, 128 px quantized capture boxes, and shadow caster reuse.
- Regression tests (perf-budget-scratch-pool-eviction, perf-budget-persistent-cache-eviction) and updated color/effects tests.

Assisted-by: LLM (human-reviewed)
Signed-off-by: ZhangDM-520 <jixianqiang1540@gmail.com>
@ZhangDM-520
ZhangDM-520 force-pushed the perf/umbrielfx-bandwidth-rework branch from 898fd93 to ff54666 Compare December 2, 2026 06:22
ZhangDM-520 added a commit to ZhangDM-520/umbriel-nightly that referenced this pull request Dec 2, 2026
Split out from noctalia-dev#965 as requested in review:

- Add AnimatedValue::finishQuantizedSpringTail(255.0) to stop springs (e.g. overdamped alpha springs) once remaining displacement stays strictly within the target's 8-bit rounding cell, skipping the cut when an animation effect preset is bound (Layers / DimUnfocused).
- Add Output::latestVblankMsec() (reused by Output::handleFrame()) and AnimatedValue::seedStartMsec() to seed focus-dim transitions from the latest vblank so the first tick advances immediately.

Assisted-by: LLM (human-reviewed)
Signed-off-by: ZhangDM-520 <jixianqiang1540@gmail.com>
@ZhangDM-520
ZhangDM-520 marked this pull request as ready for review December 2, 2026 07:19
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