Skip to content

M5.6: Dehaze while zoomed no longer resamples the whole original on every pan and slider step - #1419

Merged
echelon merged 1 commit into
storytold:mainfrom
dev-null-undefined:claude/dehaze-airlight-cache
Oct 14, 2026
Merged

echelon merged 1 commit into
storytold:mainfrom
dev-null-undefined:claude/dehaze-airlight-cache

Conversation

@dev-null-undefined

@dev-null-undefined dev-null-undefined commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The problem

With Dehaze on, a zoomed view (a window render, #323) dehazes with the airlight of the whole frame, not that of the pixels in the window. local::frame_airlight estimates it on a 384 px proxy of the frame. Every window job sampled the whole original down to that proxy again: every pan at 1:1 and every slider step while zoomed.

On a 64 MP raw that is ~200 ms of CPU per window, several times what the GPU render of the window itself costs. The CPU pipeline plans windows through the same function, so it pays the same.

The numbers below come from a Sony ILCE-7RM6 64 MP raw on an RTX 4070 Ti SUPER (Ryzen 7 9800X3D) under a 4-CPU cgroup quota.

Changes (one commit; same pixels)

  1. The proxy is kept. frame_proxy keeps the sampled proxy for the last 4 (source fingerprint, frame, proxy size), using optics::fingerprint like the lateral CA and Upright caches. Frame now derives PartialEq for the key.
    • The proxy is taken before white balance, so a WB drag still hits.
    • White balance, the dark channel, its blur and the percentile still run on the 384 px proxy every time (well under a millisecond).
    • Each entry is at most 384 × 384 × 12 B ≈ 1.8 MB.
  2. No panic on an empty image. optics::fingerprint indexed the first pixel of an empty image. It now hashes only the dimensions then. The change is byte for byte the one in [On hold, follow-up to #1283] Dehaze: per-channel airlight and a soft veil for negative values (#1237) #1286, so the two merge without a conflict there.

Result

main → this branch, render_bench ONLY=window GPU_ONLY=1 N=7 (a 3072 × 2304 window of the 9984 × 6656 frame, typical() settings with Dehaze 10), best of 7, two runs each:

CPU time wall clock
Pan (new window, source on the GPU) 208–212 → 9–11 ms 143–190 → 38–39 ms
Exposure change at 1:1 200–204 → 4.1 ms 90–109 → 5.1–5.7 ms
Draft exposure drag at 1:1 200–210 → 3.8–4.3 ms 102–117 → 4.8–6.1 ms
Noise Reduction change at 1:1 212–217 → 12.5–13.6 ms 189–196 → 39 ms

Wall clock on main varies with the load on the shared machine (load average ~16). CPU time is stable. The first window of a photo still samples the proxy once. Its row in render_bench isn't comparable, because the best of 7 hits the cache from the second run on.

Verification

  • Same pixels: the GPU window render_bench writes with DUMP= is byte-identical on main and on this branch.
  • Tests:
    • local::tests::the_kept_airlight_proxy_matches_a_fresh_one_and_misses_on_another_source_or_frame: the second request is served from the cache; the airlight is bit-identical to a fresh estimate; another source of the same size and the same source with another crop each get their own.
    • optics::tests::an_empty_image_has_a_fingerprint: panicked on main ("index out of bounds: the len is 0 but the index is 0").
  • cargo xtask ci: fmt, clippy (workspace, all targets) and heif pass; parity, layers, assets and wasm pass.
    • cargo test --workspace --no-fail-fast: everything passes except catalog's tests_lock::dropping_the_lock_frees_the_library_while_another_thread_spawns_processes. That test spawns /bin/true, which doesn't exist on this NixOS machine. It fails the same way on main, and this PR doesn't touch the catalog crate.
  • Every cargo command ran with RUSTFLAGS="-A clippy::chunks_exact_to_as_chunks". Clippy on rustc 1.98 flags that lint in crates/pipeline/src/spots.rs:250 on main, which this PR doesn't touch.

Related

…d slider step resampled the whole original)

A windowed render dehazes with the whole frame's airlight, estimated on a 384 px proxy of the frame
(`local::frame_airlight`). Every window asked for that proxy again, so every pan of a 1:1 view and every
slider step while zoomed sampled the whole original down to it on the CPU: ~200 ms of CPU on a 64 MP raw.

The proxy (taken before white balance) is now kept for the last 4 (source fingerprint, frame, size); white
balance, the dark channel and the percentile still run on it every time. Same pixels: the GPU window of
`render_bench` is byte-identical.

`optics::fingerprint` indexed the first pixel of an empty image; it now hashes only the dimensions then.

render_bench ONLY=window GPU_ONLY=1 on a 64 MP Sony ILCE-7RM6 raw (RTX 4070 Ti SUPER, 4-CPU quota), CPU time:
pan 208-212 -> 9-11 ms, exposure change 200-204 -> 4 ms, NR change 211-217 -> 13 ms.

Co-Authored-By: Claude <noreply@anthropic.com>
@echelon

echelon commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thank you @dev-null-undefined! This landed on main in integration batch 35 (#1682).

If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there.

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