Skip to content

Issue #1937: GPU editing on Windows keeps its device through window resizes, stays within the card's memory, and settles sooner at 1:2 - #1940

Merged
emmertex merged 5 commits into
emmertex:stagingfrom
RAD-Films:pr/gpu-stable
Dec 5, 2026
Merged

emmertex merged 5 commits into
emmertex:stagingfrom
RAD-Films:pr/gpu-stable

Conversation

@OneSlips

@OneSlips OneSlips commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1937

Four fixes for GPU editing on Windows with large raws and masks: the render device survives window resizes, the editing card stays within its memory, and the sharp view at 1:2 comes sooner.

What changed

  • GPU-STABLE-1: a surface configure failure no longer replaces the render device. wgpu-core 30's Surface::configure can return GpuWaitTimeout and drop the map callbacks it collected. A readback whose callback was dropped now checks whether the buffer is mapped anyway (Mapped::{Yes, Dropped, Failed}) and reads it, instead of treating the device as lost. egui's scissor error on the frame after such a failure is logged as the window's error (window_frame_error), not counted against the renderer.
  • GPU-STABLE-2: the device stages and the buffer pool stay within the card's memory. The views' device stages get their own budget, a fifth of the editing card (stage_vram_budget; idle views give way first, the loupe last). Each card's pool keeps at most a fifth of the card while it works (was a third). After an out-of-memory render, or when a device is replaced, the shared original, the Auto Mask strokes and every view's device stages are released (take_memory_pressure).
  • GPU-STABLE-3: a zoomed view's window and tiles share the frame's colour noise model. It is kept per photo and frame (FRAME_NOISE, keyed by the source and Plan::frame_lin_key, 16 kept), so the tiles stop measuring the whole frame's noise again on the CPU.
  • GPU-STABLE-4: on Windows the GPU renderer uses a device of its own by default. The window's surface configures then stop waiting on the renderer's submissions. CHROMAFORGE_GPU_WINDOW=1 shares the window's device as before, and =0 never shares it on any platform. Documented in docs/gpu-pipeline.md.
  • GPU-STABLE-5: What's New and changelog entries.

What staging already has: the typed polls and per-device error recording (REVIEW-F01, F02, T06, P09 to P13) complement these changes; they cover none of the four. F01's stricter poll handling makes the window-frame filter in GPU-STABLE-1 more needed.

Trade-off: on Windows, drafts are no longer drawn straight from textures on the window's device. The settle times below include that cost.

Measured

Release builds, staging (5df5a81) against this branch. 3 Canon R5 C CR3s from a real wedding, each with global edits and subject, linear, radial and brush masks, on an RTX 5070 (Vulkan). The session is 6 minutes of slider drags at fit, 1:2 and 1:1, then 4 minutes of slider drags with window resizes between them, then an export of the three photos.

Measure Staging This branch
Fit settle, median 350 ms 351 ms
1:2 settle, median (p90, max) 1.90 s (2.59, 3.98) 1.21 s (1.68, 2.06)
1:1 settle, median (p90) 2.88 s (3.88) 2.69 s (3.71)
1:2 draft sharpness before the sharp frame 0.88 to 0.98 about 1.0
"configure failed" on the window surface 9 0
Device loss, out of memory, device replaced, panics 0 0
Export, 3 photos 6.3 to 7.7 s 6.3 to 6.9 s

Exports

Exports are pixel-identical between staging and this branch for the same run outcome. Separately, the same photo can export to two different JPEGs in two runs of the app, on staging as on this branch (photo 1 here, max 37 levels on 2.1 % of pixels, in dark edited areas). That is filed as #1938 with the numbers. This PR doesn't change it.

Checks

  • cargo xtask ci --quick --base origin/staging: everything this branch touches passes. Three tests fail, from staging's face-prototype work, as on staging itself: tests_face_recognize::a_trained_person_and_an_untrained_one_are_scored_the_same_way, i18n::tests::no_language_has_translation_gaps (34 "Face Prototypes" strings) and tests_i18n_coverage::ui_text_has_no_em_dashes (one What's New line).
  • lcc_gpu tests pass on both cards (RTX 4070 SUPER and RTX 5070).

Manual: none, no user-visible change in the manual's pages.

🤖 Generated with Claude Code

OneSlips and others added 5 commits December 4, 2026 21:20
…laces the render device

wgpu-core 30's Surface::configure waits for the GPU and, when a render thread submits during the
wait, returns GpuWaitTimeout and drops every map callback it collected unanswered. A readback then
saw "map callback: channel is empty and sending half is closed", took it for a lost device and
replaced the window's healthy device in the middle of a slider drag (2026-11-28 18:33 log). The
mapping itself is done: it is read as usual (uploads and the view readback too); a buffer that is
somehow not mapped fails that render only.

egui's next frame after such a failure still draws at the old size, and wgpu rejects its scissor
rectangle ("not contained in the render target", egui-wgpu's encoder): on the window's device that
is the window's error, logged, not the renderer's. Reproduced on a recent build with window resizes
during slider drags (1 device replacement in 4 min); gone with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the card's memory

The views' device stages were budgeted from system RAM alone (a quarter of the memory budget, 4.3
GB here, and the open photo's views up to four times that), and each card's buffer pool could keep
a third of the card: with the renders in flight and the window's own memory beside them, the 12 GB
editing card ran out (9.9 GB used, a 196 MiB buffer refused, 2026-11-28). Now:
- the device stages have their own budget, a fifth of the editing card's memory
  (lcc_gpu::stage_vram_budget; the idle views' go first, the loupe's last);
- the pool keeps at most a fifth of each card while it works (was a third);
- after an out-of-memory render and when a device is replaced, the shared original, the Auto Mask
  strokes and every view's device stages are released (lcc_gpu::take_memory_pressure), so the next
  render has the room and nothing of a replaced device is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…our noise model

A zoomed view renders its window and each tile as jobs of their own, the tiles without a stage
cache, and each measured the whole frame's noise for the joint colour NR again on the CPU: 270-450
ms of a 45 MP raw's 700-900 ms render, 13 times after every slider release at 1:2. The model is
now kept per photo and frame (FRAME_NOISE, keyed by the source and Plan::frame_lin_key, 16 kept).
Measured on three R5 C raws with masks (slider out and back, 10 min): the sharp view after a
release at 1:2 settled in 2.0 s median (5.4 s before), 1:1 in 3.9 s (5.9 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… default

Sharing the window's device failed under the renderer's work on Windows (RTX 5070, Vulkan, 45 MP
raws with masks): besides the dropped readbacks and egui's frame after a failed configure
(GPU-STABLE-1), a real "Device is lost" on the shared device took the window with it. egui dropped
every frame from then on and the screen froze for good, while the renderer had already recovered on a
new device. With a device of its own, two 4-minute resize-and-slider stress runs raised no surface
error and no device failure, and slider moves were as quick: Fit 386 against 410 ms, the sharp
1:2 view 1.0 against 2.7 s. CHROMAFORGE_GPU_WINDOW=1 shares the window's device as before; other
platforms keep sharing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fixes

Manual: none, no user-visible change in the manual's pages (the Windows device default is
documented in docs/gpu-pipeline.md).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@emmertex
emmertex merged commit e2fad2d into emmertex:staging Dec 5, 2026
3 checks passed
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.

GPU on Windows: a window resize replaces the healthy render device, the editing card runs out of memory, and the sharp 1:2 view comes late

2 participants