Repository navigation
Conversation
… end A GPU frame keeps its encoder open while the CPU renderer runs layers with GPU effects (Gpu::effects -> run_chain). Each call's Enc handed its textures back to the shared pool, where they waited for every open encoder, so all effect intermediates of a frame stayed allocated until the frame ended (17.7 GB by layer 17 of a heavy 4K comp, then OOM). Effect calls now borrow a pool owner (Enc::lent) that is given back once the call's work is submitted or discarded; its kept textures are trimmed to the pool budget, so the rest are freed after each call.
Once the wgpu allocator holds more than a cap (8 GiB on discrete GPUs, 2 GiB otherwise; EFFECTCRAFT_GPU_MEMCAP_MB overrides, 0 = off), a frame submits its encoder and waits for the queue so wgpu destroys dropped textures and pending pool textures free up. Checked every 8 effect calls / layers. Fixes out-of-memory errors at 3-4 frames in flight on 4K comps.
…where Linux reports it storytold#1550's default cap is 8 GiB for every discrete card, above all of a 2-4 GB card such as the RX 550 in storytold#1487, which ran out of memory during export and took the system down. On Linux the amdgpu driver publishes the card's memory in sysfs (mem_info_vram_total), readable without unsafe: match the DRM card by PCI vendor and device id and cap discrete cards at min(8 GiB, 3/4 of it). Integrated GPUs keep 2 GiB; EFFECTCRAFT_GPU_MEMCAP_MB still overrides. Co-Authored-By: Claude <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #1550: this branch is #1550 (
23da45dd) plus one commit (d02f000a). Review only the last commit; the rest is #1550's. Refs #1487.Problem
#1487 is a 2–4 GB RX 550 on Fedora that took the whole system down during export (
amdgpu_vm_validate() failed,Not enough memory for command submission!). #1550's default cap is 8 GiB for every discrete card, which is more memory than that card has, so the gate would never trigger there.Change (
crates/gpu/src/memcap.rs)wgpu has no safe memory query, but on Linux the amdgpu driver publishes the card's memory in sysfs, and reading it needs no
unsafe:/sys/class/drm/cardN/device/mem_info_vram_total.MemCap::newmatches the DRM card by PCIvendor/deviceagainstAdapterInfoand caps discrete cards at min(8 GiB, ¾ × VRAM):Integrated GPUs keep 2 GiB (an APU's carve-out isn't its limit).
EFFECTCRAFT_GPU_MEMCAP_MBstill overrides it. Where the size isn't known (Windows, NVIDIA on Linux), the 8 GiB default applies as in #1550. Windows' WDDM pages video memory to system memory instead of hard-crashing like #1487, which is why this targets Linux.Tests
known_video_memory_lowers_the_discrete_cap: the arithmetic above.video_memory_is_read_from_the_matching_drm_card: a fake sysfs tree with an Intel card that has nomem_info_vram_total, the RX 550 (0x1002:0x699f, 4 GiB) and acard1-DP-1connector entry; plus a non-matching id and a missing directory.Run on Windows 11 / RX 6900 XT, Vulkan:
cargo test -p effectcraft-gpu --lib --releasegives 212 passed. The only 3 failures also fail onmain(#1605).cargo clippy -p effectcraft-gpu --all-targets --release -- -D warningsis clean. Not tested on Linux: the fixture covers the parsing, but the real sysfs read still needs a Linux/amdgpu machine.🤖 Generated with Claude Code