mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-30 21:16:52 -06:00
GPU: running out of video memory falls back to the CPU instead of crashing (#106)
The desktop app shares egui-wgpu's device, which had no uncaptured-error handler, so wgpu's default one panicked on an out-of-memory error on every frame thread; the panicking frame stayed "in progress" forever and never rendered again. The GPU frame budget was a fixed 1 GiB. - GpuContext::new logs uncaptured errors once its pipelines are built (errors while building them still panic there, which the app catches to fall back to CPU compositing). - Gpu::within_memory runs GPU work in an out-of-memory error scope; on an error the result is discarded and uploaded layers and pooled textures are freed. - Frame workers render each frame within it; out of memory, the frame renders on the CPU and the RAM preview keeps half as many GPU frames (down to 64 MiB), since wgpu can't tell how much video memory there is. - A frame whose render panics renders again on the CPU, or is released, so the viewer asks for it again. Tests: a_frame_whose_render_panics_is_released (failed before), running_out_of_video_memory_halves_the_gpu_frame_budget and within_memory_returns_the_work_when_there_is_room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0fac647928
commit
e64076e432
@@ -268,7 +268,11 @@ zero texture per size, readback staging buffers are reused, and the 8/16 bpc qua
|
||||
each layer is fused into the layer's composite kernel; under test, pooled scratch images start
|
||||
as NaNs (a kernel that skips pixels fails the oracle) and validation errors panic. The desktop viewer builds the
|
||||
`Gpu` on egui-wgpu's device and shows frames from GPU textures without reading them back
|
||||
(`ui-egui::frames`); headless renders, the CLI (unless `--gpu`) and CI use the CPU. On the web
|
||||
(`ui-egui::frames`); headless renders, the CLI (unless `--gpu`) and CI use the CPU. Outside
|
||||
tests, device errors are logged rather than fatal. A viewer frame that runs out of video memory
|
||||
(`Gpu::within_memory`) renders on the CPU, the uploaded layers and pooled textures are freed, and
|
||||
the RAM preview keeps half as many GPU frames from then on. A frame whose render panics is
|
||||
rendered again on the CPU or released, never left in progress. On the web
|
||||
(WebGPU) the GPU composites viewer frames; steps that need a readback fall back to the CPU (the
|
||||
Info panel's pixel readout reads GPU frames back asynchronously). **GPU particles**
|
||||
(`effects::psim`, `gpu::particles`): CC Particle World, CC Particle Systems II and Particle
|
||||
|
||||
Reference in New Issue
Block a user