Indirect batches: scratch buffers go to a pool when their list has run #1441

Manually merged
github merged 1 commit from github-bot/gh-1441 into main 2026-11-29 08:21:08 +00:00 AGit
Owner

@⁠saltdam36 on GitHub · 2026-11-28 20:04 UTC · original
saltdam36:fix/indirect-batch-buffers → main · +40 −3 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

What

HostList::batch_place pushes a new scratch buffer whenever a recording needs more batches than the list has had before, and batches_common resets the count but never the vector. So every host list keeps the buffers of its busiest recording for the rest of the run.

With VICTORY_INDIRECT_BATCH=1 on an RX 7800 XT (16 GB, Series S profile, no DLSS) that was 12,719 buffers in eight minutes of open-world play. The system counts 256 KiB for each (card use rose in steps that match "made so far: N card buffers" x 256 KiB to within 1 %), so 3.2 GB in all. Card use went from 11.1 GB to 14.3 GB against a budget of 13.3 GB, and time on the card went from about 5 ms to over 200 ms a frame (4 fps). Nothing the layer counts moved in that time (texture copies, blocks, targets and buffer copies were all flat), and the texture queue said "no room" throughout, since it sees the system's figure but cannot let these go.

VICTORY_INDIRECT_BATCH=2 (the launcher's value) makes fewer batches a recording, so it grows more slowly; I have not measured how much. This may be one part of #848 and #1378; I cannot say it is all of it.

Change

A list gives its batch buffers back in HostList::reset (every submission of it has run, and batches_common left them in the common state), and batch_place takes one from that pool before it makes a new one, as scratch chunks and preludes already do. 512 are kept; more are retired with retire_resource. One file, about 40 lines.

(Edited: this replaces the version first pushed here, see the last column but one.)

Measured

Same card and settings, VICTORY_INDIRECT_BATCH=1, the same stretch of dense coast and canal:

Before Each list keeps those of its last recording ...of its last 128 recordings (first pushed here) Pool (this change)
Card use 11.1 -> 14.3 GB in 8 min, still rising at about the budget, 50 min of play 1.5 GB over the budget for about two minutes in the dense stretch, then back under the budget in every one of 17 min (peak 13.2 of 13.6 GB)
5 s readings slow on the card over 200 ms from minute 8 on none over 100 ms 45 to 68 ms, 10 fps, for those two minutes none over 40 ms
Card buffers made a minute about 54,000 5,000 to 10,600 about 200 (at most 552)

Seen by the player: with buffers made anew all the time (second column) the foliage flickered more than before; with the pool it flickered least of all four.

Not measured: sessions longer than 17 minutes with this version, an NVIDIA card, Series X, VICTORY_INDIRECT_BATCH=2.

Checks

cargo test -p victory-gpu --lib batch passes. cargo clippy --workspace ... -D warnings fails on main as it is now (two errors in victory-shader/src/emit/lower.rs, not touched here); clippy reports nothing in the changed lines.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KfgN1FfW7f4Zv2hqXUsNr2

**@⁠saltdam36** on GitHub · 2026-11-28 20:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1441) `saltdam36:fix/indirect-batch-buffers` → `main` · +40 −3 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC ## What `HostList::batch_place` pushes a new scratch buffer whenever a recording needs more batches than the list has had before, and `batches_common` resets the count but never the vector. So every host list keeps the buffers of its busiest recording for the rest of the run. With `VICTORY_INDIRECT_BATCH=1` on an RX 7800 XT (16 GB, Series S profile, no DLSS) that was 12,719 buffers in eight minutes of open-world play. The system counts 256 KiB for each (card use rose in steps that match "made so far: N card buffers" x 256 KiB to within 1 %), so 3.2 GB in all. Card use went from 11.1 GB to 14.3 GB against a budget of 13.3 GB, and time on the card went from about 5 ms to over 200 ms a frame (4 fps). Nothing the layer counts moved in that time (texture copies, blocks, targets and buffer copies were all flat), and the texture queue said "no room" throughout, since it sees the system's figure but cannot let these go. `VICTORY_INDIRECT_BATCH=2` (the launcher's value) makes fewer batches a recording, so it grows more slowly; I have not measured how much. This may be one part of #848 and #1378; I cannot say it is all of it. ## Change A list gives its batch buffers back in `HostList::reset` (every submission of it has run, and `batches_common` left them in the common state), and `batch_place` takes one from that pool before it makes a new one, as scratch chunks and preludes already do. 512 are kept; more are retired with `retire_resource`. One file, about 40 lines. (Edited: this replaces the version first pushed here, see the last column but one.) ## Measured Same card and settings, `VICTORY_INDIRECT_BATCH=1`, the same stretch of dense coast and canal: | | Before | Each list keeps those of its last recording | ...of its last 128 recordings (first pushed here) | Pool (this change) | |---|---|---|---|---| | Card use | 11.1 -> 14.3 GB in 8 min, still rising | at about the budget, 50 min of play | 1.5 GB over the budget for about two minutes in the dense stretch, then back | under the budget in every one of 17 min (peak 13.2 of 13.6 GB) | | 5 s readings slow on the card | over 200 ms from minute 8 on | none over 100 ms | 45 to 68 ms, 10 fps, for those two minutes | none over 40 ms | | Card buffers made a minute | | about 54,000 | 5,000 to 10,600 | about 200 (at most 552) | Seen by the player: with buffers made anew all the time (second column) the foliage flickered more than before; with the pool it flickered least of all four. Not measured: sessions longer than 17 minutes with this version, an NVIDIA card, Series X, `VICTORY_INDIRECT_BATCH=2`. ## Checks `cargo test -p victory-gpu --lib batch` passes. `cargo clippy --workspace ... -D warnings` fails on `main` as it is now (two errors in `victory-shader/src/emit/lower.rs`, not touched here); clippy reports nothing in the changed lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KfgN1FfW7f4Zv2hqXUsNr2
A host list kept the scratch buffers of its busiest recording for good
(`batch_args` was only pushed to). With about 1,500 lists alive that was
12,719 buffers in eight minutes of play on an RX 7800 XT (16 GB) with
VICTORY_INDIRECT_BATCH=1: 3.2 GB of the card by the system's count
(256 KiB a buffer), past its budget, and 200 ms a frame on the card
from there. No counter saw them, so nothing could let them go.

Now a list keeps the buffers of the busiest of its last 128 recordings
and one more; the rest are retired as any other resource. (Keeping
those of the last recording alone held the memory too, but 900 buffers
a second were then made anew.)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KfgN1FfW7f4Zv2hqXUsNr2
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 20:06:05 +00:00
github-bot changed title from Indirect batches: a list lets go of scratch buffers it has not used of late to Indirect batches: scratch buffers go to a pool when their list has run 2026-11-28 20:39:49 +00:00
github-bot force-pushed github-bot/gh-1441 from 9aa2ab6c78 to e6bda107e0 2026-11-28 20:39:50 +00:00 Compare
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

Tested on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off, combined perf stack) across multiple 20+ min sessions. Indirect batch scratch pooling ran cleanly with zero visual/GPU issues and helped bring steady-state VRAM down from ~14.2 GB to ~10.6-12.7 GB.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1441#issuecomment-7251372889) Tested on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off, combined perf stack) across multiple 20+ min sessions. Indirect batch scratch pooling ran cleanly with zero visual/GPU issues and helped bring steady-state VRAM down from ~14.2 GB to ~10.6-12.7 GB.
github manually merged commit fb0a48b67f into main 2026-11-29 08:21:08 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1441
No description provided.