texback: reuse read-back buffers instead of making one per copy-back #1359
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1359
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1359"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@fxceless on GitHub · 2026-11-26 18:09 UTC · original
fxceless:claude/project-thread-hxiqdc→main· +111 −6 · 1 files · 1 commits · openRequested by ELEVEN · project thread
Addresses #1340.
Problem
With
VICTORY_TEXTURE_BACKon,texback::recordcalledhost.read_back_buffer(total)(aCreateCommittedResourceon a read-back heap) for every copy-back, and the buffer was released at the list's reset: ~966,000 buffers in a 21-minute run. On Linux with NVIDIA's open kernel module that churn contributes to the driver running out of DMA mappings.Change (
crates/victory-gpu/src/texback.rsonly)Drop for Back. ABacklives in the list'sDeferreduntilHostList::reset(only after the list's last submission has run) or until the list is dropped, so a closed list that is submitted more than once lands every run from the same buffer, and no buffer is reused while a list that may still run holds it.COPY_DEST, andlandreads only the footprints the copies wrote, so reuse needs no clearing or barriers.VICTORY_READBACK_POOL=0: made and released each time, as before.VICTORY_READBACK_POOL_MB: the most bytes kept spare (256).texture readback landedlog line now also reportsbuffers_reusedandbuffers_made, so a run shows whether the churn is gone.Testing
cargo clippy -p victory-gpu --all-targets --all-features --target x86_64-pc-windows-msvc -- -D warnings: clean.readback_buffers_pool_by_power_of_two_up_to_16_mib. Unit tests were not run (no Windows linker in the environment); CI will run them.Xid 31fault was seen with a similar patch.Generated by Claude Code
@fxceless on GitHub · 2026-11-26 18:12 UTC · original
CI note: both clippy steps (default and
--all-features,-D warnings) pass. The only failure ispolicy::tests::repository_passes_policy, which flagscrates/victory-gpu/src/host.rs(528,954 bytes) andcrates/victory-shader/src/emit/lower.rs(535,588 bytes) over the 512 KiB limit. This PR touches neither file (onlytexback.rs), and main fails the same check (#1342 tracks the split). Not fixed here to keep the change scoped.Also worth knowing: CI's
cargo testrun doesn't includevictory-gpu's unit tests, so the newreadback_buffers_pool_by_power_of_two_up_to_16_mibtest isn't exercised by CI.Generated by Claude Code
@rafaconvaitis on GitHub · 2026-11-26 18:30 UTC · original
I ran a same-binary Windows Series S comparison on an RTX 4070 12 GB while testing the related Cool Fox port (DoubleGhosty/cool_fox#27). Both arms loaded the same checkpoint bytes, ran with the async logger, and had a warm D3D12 pipeline library. The pool flag was the configuration change.
@ArturoWolff on GitHub · 2026-11-26 19:24 UTC · original
Linux/NVIDIA qualification of the authored pool change (game-free)
Complementing the Windows comparison above and the allocation-accounting discussion in #1340, I ran a matched test on an RTX 4060 8 GB / 16 GB RAM Linux workstation. Windows-target
victory-gputests under GE-Proton 11-14 (Wine 11.0 Staging, vkd3d-proton build71cae091b06571e, NVIDIA driver620.73.04, kernel7.3.5-zen1-1-zen). DXGI reported the physical NVIDIA adapter, not a software device.Compared the exact PR parent
e4245f3c1b0490250d9cf0946a2113000be98687with authored headb3694a26942d1fe403ecf6d41408fb874a57b265, not with the newer advertised base. Both used an identical fixture and common test-only allocation/list instrumentation, with candidate-only pool-accounting assertions. Separate Cargo targets, identical starting Wine-prefix contents and graphics DLLs, and empty per-case driver-cache directories were used. The candidate had no additional production changes.The workload records three ordinary committed 512x128 RGBA8 textures with four mips in each of 24 batches. Each closed list is submitted twice, with a completed fence and device-status check before each landing; its buffers remain owned until reset. The three textures have distinct deterministic byte patterns. Every landing checks all 348,160 texel bytes and a 64-byte untouched tail against a CPU oracle. Successful new readback-resource creation is counted separately from pool reuse and landing count. Idle-buffer count and width are checked at every reset, and the pool must stay empty while the closed list owns the buffers.
VICTORY_READBACK_POOL=0VICTORY_READBACK_POOL_MB=1All 576 completed GPU readbacks matched, including the untouched tails (200,577,024 checked bytes total). Default pooling eliminated 95.8% of successful new readback allocations in this workload. The opt-out restores the baseline allocation frequency, and the tighter idle cap still permits reuse while retaining only two 512 KiB buffers. The allocation-invalidation test passed in every process, as did the new pool-size unit test in all three candidate processes.
Two separate Windows-target test builds succeeded; all four test processes exited 0. The external host-memory floor remained 512 MiB, with no additional cgroup memory or swap caps. Across the two supervised scopes (including builds), minimum sampled available host RAM was 8,344.6 / 8,745.1 MiB; peak sampled GPU memory usage during GPU phases was 924 MiB in both. No host OOM kills, matching kernel GPU-fault events, or device-removal failures were observed. Idle width is not a measurement of driver DMA mapping count or physical VRAM savings.
This is evidence for the intended allocation reduction and closed-list/reset lifetime behavior on this Linux/Proton stack. It is not a test of overlapping independent in-flight lists, a full renderer regression suite, prolonged memory pressure, title lighting/water correctness, or FPS. In particular it does not establish that #1340's mapping exhaustion or remaining Xid faults are fixed. The landing count alone can also overstate allocation count: here 144 landings came from 72 recordings even with pooling disabled.
AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol Max).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.