Repository navigation
GPU: contain frame-local validation failures (refs #1319) - #1326
Conversation
…frame's textures (refs storytold#1319)
…flag it unused (refs storytold#1319)
…r waiting on another encoder (refs storytold#1319)
…like the CPU (refs storytold#1319)
|
I can reproduce #1319's exact error on Linux by running out of VRAM, and this PR keeps the compositor on through it. Setup: RTX 5070 12 GB, NVIDIA 615.78.08, Fedora 44, Vulkan, headless sway. A separate process allocated and held
On On The one run on I couldn't show from outside the app that frames render on the GPU again after the release. There's no per-frame signal On Linux with the RTX 5070: Not tested: what fills a 12 GB card in the reporter's normal session, X11, KWin, driver 580, and exports or |
|
Tested on AMD (RX 6900 XT, Windows, Vulkan, Generated with Claude Code |
|
Another reproduction of this failure, from #1812 (a 3D parallax project with 21 120 px plates). Windows 11, RTX 4070 Laptop (8 GB), Vulkan, desktop app on During playback, 16 preview workers ran the device out of memory on a cold start. The next use of the failed texture escaped the guard and retired the compositor for the session: I had opened #1919 with only the 🤖 Generated with Claude Code |
|
I was encountering the same issue on Ubuntu with my RTX4070 Super. I asked Qwen-3.8-Flash to check out this branch and build locally so I could test and grab any new error messages. I reproduced the issue and ran a "pressure test" to fill the VRAM and trigger the error. The AI Summary follows: At full-card pressure this project retires the compositor on the tip too — via uncaptured Setup: RTX 4070 SUPER (12 GB), NVIDIA 595.71.05, Ubuntu 25.10, native Wayland, Vulkan, wgpu 30.0.1, Ryzen 7 9700X (16 preview workers). Builds: A. Demo, fill until refused (~8.5 GiB held, ~0.45 GiB headroom) — the #1319 failure, contained:
The label goal of the PR is met: every message names the failing texture's size, including the B. Real project, moderate fill (capped at 5.0 GiB → ~1.3 GiB headroom: workers fail, main-thread allocations survive) — same fix on a heavy real comp:
Those are the first real-project confirmations I've seen of the C. Real project, extreme fill (refused at 5.5 GiB held → ~0.55 GiB headroom) — the tip still retires, through a different door: ~15 s into each run, while Cache-When-Idle preview prefetch was allocating, on both builds: The guard never engaged first (0 scoped catches before the retire on either build; after it, the PR's workers do report the labeled combined string). Uncaptured count 3 on the PR vs 13 on D. Suite on this device ( Not tested: exports and render-queue frames under pressure (the description's other uncovered area), and X11. Summary: on both the demo and a heavy real project, this branch turns #1319's session-ending unlabelled |
|
Merged, thank you @tylerjenningsw! It landed on |
Refs #1319. This is "refs", not "fixes": the reporter's first failure is still unknown. This PR stops that kind of failure from turning off the GPU compositor for the rest of the session, and makes the next report say which texture failed.
What was wrong
Gpu::within_memory(the guard around each viewer frame) only had OutOfMemory and Internal error scopes. A Validation error, like the reportedTexture::create_view: Texture with '' label is invalid, escaped as an uncaptured error. The desktop app's handler then retires the GPU compositor, and preview stays on the CPU until restart. One way this happens: a texture allocation fails, the code goes on with the invalid texture, and itscreate_viewis then a validation error that the allocation scopes don't catch.released, and became free (and reusable) when that encoder closed.GpuContext::texture). The viewer's display texture is labelledviewer frame.Changes
within_memoryalso pushes a Validation scope. On any scoped error it reports every error, allocation errors first (…; then: …). It drops the failed result, then frees everything kept for reuse with a newGpuContext::discard_kept: uploads, staging buffers, the shared zero textures, the particle checkpoints and the texture pool. For the pool,Pool::discarddrops the free textures, those waiting for an open encoder, and those kept by a live encoder, and raises a pool generation. A texture taken before the failure is then never handed back to the pool. The encoders' bookkeeping (open, ids) stays, so reuse remains ordered. The compositor stays on, and the next frame tries the GPU again.within_memoryreturns aFrameError(Retired/Memory/Validation) instead ofString. Inframes.rs, a plain validation failure no longer logs "the GPU ran out of memory" and no longer halves the RAM preview's GPU frames. Memory failures behave as before.working image {w}×{h}.docs/architecture.mddescribes the new behaviour.Tests (
crates/gpu/src/tests.rs, each on a device of its own)a_view_of_an_invalid_texture_fails_the_frame_not_the_compositor: a texture the device rejected, made beforehand under a scope of its own. Inside the guard only itscreate_viewruns, the reported operation. The test checks that:FrameError::Validation, naming the texture;check_healthis still OK;The test device's handler panics on an uncaptured Validation error under test. With the old guard, the failure is
uncaptured GPU error: Validation Error, the reported one.a_failed_frame_returns_no_texture_to_the_pool: anotherEnckeeps its encoder open across the failed frame, and an image taken by an earlier frame is handed back after the cleanup. Then the open encoder closes. The next frame takes both sizes and the pool reports no reuse. With the oldPool::clear, both textures were reused (2 hits).The tests skip without a GPU adapter, like the crate's other GPU tests. No VRAM exhaustion is needed.
Checks run locally
Run on an NVIDIA RTX 3060, Vulkan, Windows:
cargo fmt -p effectcraft-gpu -p effectcraft-ui-egui -- --checkcargo test -p effectcraft-gpu --lib -- within_memory a_view_of_an_invalid a_failed_frame_returns enc_reuses texture_reuse_does_not readback_staging(6 passed, including the existing pool-reuse tests)cargo test -p effectcraft-ui-egui --lib(257 passed)cargo clippy --no-deps -p effectcraft-gpu --lib --tests -- -D warningscargo clippy --no-deps -p effectcraft-ui-egui --lib -- -D warningscargo clippy --no-deps -p effectcraft-gpu --target wasm32-unknown-unknown -- -D warningsThe full
cargo xtask cigate wasn't run locally, including the whole GPU test suite and the ui-egui test binaries. I haven't reproduced the reporter's Linux failure.Not covered
within_memory. Exports and render-queue frames throughAccelerator::comp_frame, and Info-panel readbacks, can still retire the compositor on an uncaptured validation error.Renderer::content_buf_timedcan insert buffers into the shared layer cache, and slow ones are written to the disk cache, before the guard reports a failure. The CPU retry skips the cache, but later frames read it again. I haven't shown that a rejected GPU effect actually leaves wrong pixels there rather than falling back to the CPU. Fixing it properly means staging a GPU attempt's entries and publishing them, in memory and on disk, only when the attempt succeeds. That's a separate change. A RAM-only purge wouldn't cover the disk cache, and would drop other threads' valid entries.frames.rs. There's no test injecting an out-of-memory or internal error.