feat: memory caps follow the card's budget and the PC's RAM #256

Open
github-bot wants to merge 1 commit from github-bot/gh-256 into main AGit
Owner

@⁠Skyfrye on GitHub · 2026-11-25 21:57 UTC · original
Skyfrye:nep/memory-caps-follow-machine → main · +310 −45 · 11 files · 1 commits · draft

Draft: the in-game check on this base is pending (the test machine's GPU is in use for a few hours). Everything below the game run is done.

Change

The launcher sets Neptune's switch set, which is tuned for a 16 GB card and a 32 GB PC (its own note: "on smaller cards, lower VICTORY_CARD_WINDOWS_MB and VICTORY_CARD_BUFFERS_MB"). On an 8 GB card those two alone ask for 5.6 GB of copies in a budget of about 7.2 GB, before any texture or render target; on a 16 GB PC the idle list pool, texture staging and upload pools keep their 32 GB values.

Now the engine sizes these caps from the machine when their switch is not set (memplan.rs):

  • card caps (card windows, card buffers) follow the card's budget (QueryVideoMemoryInfo), proportionally to a 14.4 GiB reference;
  • RAM caps (idle list pool and count, texture stage, stage pool, window upload pool) follow the PC's RAM (GlobalMemoryStatusEx), proportionally to a 31 GiB reference (a "32 GB" PC reports a little less);
  • each is rounded down to a step, never above the reference, never below a floor.

On the reference machine (16 GB card, 32 GB RAM) the values are exactly the launcher's former ones, so nothing changes there. Any of the seven switches still wins when set. The plan is logged once at INFO with the budget, the RAM, each cap and the switches that overrode it. The two card caps are asked of the plan at each use (the plan keeps its answer once the card has reported a budget), so a cap asked before the device exists does not stay at its floor.

The launcher no longer sets the five absolute values (VICTORY_CARD_WINDOWS_MB, VICTORY_CARD_BUFFERS_MB, VICTORY_LIST_POOL_MB, VICTORY_LIST_POOL_MOST, VICTORY_TEXTURE_STAGE_MB); its test and the "16 GB card" sentences of docs/running-gta6.md and docs/fr/lancer-gta6.md follow.

Card RAM card windows card buffers idle lists / MB texture stage stage pool window upload
8 GB 32 GB 2048 768 2048 / 2048 512 256 512
12 GB 32 GB 3072 1152 2048 / 2048 512 256 512
16 GB 32 GB 4096 1536 2048 / 2048 512 256 512
8 GB 16 GB 2048 768 1056 / 1056 256 128 256
16 GB 16 GB 4096 1536 1056 / 1056 256 128 256

(MB; card budget taken as 0.9 x the card's size.)

Linked issue: none.

Verification

Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080 (16 GB), 32 GB RAM, on upstream main at affaf15, from third_party/victory:

cargo build --locked --release -p victory                              -> Finished, no new warning (the 3 of main)
cargo build --locked --profile diag -p victory --features diagnostics  -> Finished, no new warning
cargo test --locked -p victory-gpu --lib memplan::                     -> 4 passed (CPU only)
cargo xtask policy                                                     -> asset policy: ok

With plan made to return the reference values always, smaller_cards_and_less_ram_get_less_but_not_below_floors fails.

Not run: python -m pytest tests/test_lanceur_victory.py and ruff (not installed on this machine; the test's 12 functions without fixtures were run by hand and pass; CI runs the rest). Pending: a game run on this 16 GB / 32 GB machine (the plan's line must show the reference values) and, if anyone can, one on a smaller card.

Oracle and test data

None involved. Failure cases (memplan.rs tests): the reference machine gives the launcher's former values exactly; 8 and 12 GB cards and 16 GB of RAM give smaller, floored values; no cap exceeds the reference across a card x RAM grid; a switch overrides its value.

Checklist

  • The PR covers a single reviewable behaviour (memory caps follow the machine).
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above (pytest and the game run are pending, said above).
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Not concerned.)
  • README: not touched (it does not state the 16 GB figure).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none.

AI assistance: written with Claude Code. Claude Sonnet 5.5 wrote the change and its tests; Claude Opus 5.5 reviewed it, fixed the start-up order of the two card caps, ran the checks on my machine and wrote this description.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-25 21:57 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/256) `Skyfrye:nep/memory-caps-follow-machine` → `main` · +310 −45 · 11 files · 1 commits · draft **Draft: the in-game check on this base is pending** (the test machine's GPU is in use for a few hours). Everything below the game run is done. ## Change The launcher sets Neptune's switch set, which is tuned for a 16 GB card and a 32 GB PC (its own note: "on smaller cards, lower `VICTORY_CARD_WINDOWS_MB` and `VICTORY_CARD_BUFFERS_MB`"). On an 8 GB card those two alone ask for 5.6 GB of copies in a budget of about 7.2 GB, before any texture or render target; on a 16 GB PC the idle list pool, texture staging and upload pools keep their 32 GB values. Now the engine sizes these caps from the machine when their switch is not set (`memplan.rs`): - card caps (card windows, card buffers) follow the card's budget (`QueryVideoMemoryInfo`), proportionally to a 14.4 GiB reference; - RAM caps (idle list pool and count, texture stage, stage pool, window upload pool) follow the PC's RAM (`GlobalMemoryStatusEx`), proportionally to a 31 GiB reference (a "32 GB" PC reports a little less); - each is rounded down to a step, never above the reference, never below a floor. On the reference machine (16 GB card, 32 GB RAM) the values are exactly the launcher's former ones, so nothing changes there. Any of the seven switches still wins when set. The plan is logged once at INFO with the budget, the RAM, each cap and the switches that overrode it. The two card caps are asked of the plan at each use (the plan keeps its answer once the card has reported a budget), so a cap asked before the device exists does not stay at its floor. The launcher no longer sets the five absolute values (`VICTORY_CARD_WINDOWS_MB`, `VICTORY_CARD_BUFFERS_MB`, `VICTORY_LIST_POOL_MB`, `VICTORY_LIST_POOL_MOST`, `VICTORY_TEXTURE_STAGE_MB`); its test and the "16 GB card" sentences of `docs/running-gta6.md` and `docs/fr/lancer-gta6.md` follow. | Card | RAM | card windows | card buffers | idle lists / MB | texture stage | stage pool | window upload | |---|---|---|---|---|---|---|---| | 8 GB | 32 GB | 2048 | 768 | 2048 / 2048 | 512 | 256 | 512 | | 12 GB | 32 GB | 3072 | 1152 | 2048 / 2048 | 512 | 256 | 512 | | 16 GB | 32 GB | 4096 | 1536 | 2048 / 2048 | 512 | 256 | 512 | | 8 GB | 16 GB | 2048 | 768 | 1056 / 1056 | 256 | 128 | 256 | | 16 GB | 16 GB | 4096 | 1536 | 1056 / 1056 | 256 | 128 | 256 | (MB; card budget taken as 0.9 x the card's size.) Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080 (16 GB), 32 GB RAM, on upstream `main` at `affaf15`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished, no new warning (the 3 of main) cargo build --locked --profile diag -p victory --features diagnostics -> Finished, no new warning cargo test --locked -p victory-gpu --lib memplan:: -> 4 passed (CPU only) cargo xtask policy -> asset policy: ok ``` With `plan` made to return the reference values always, `smaller_cards_and_less_ram_get_less_but_not_below_floors` fails. Not run: `python -m pytest tests/test_lanceur_victory.py` and ruff (not installed on this machine; the test's 12 functions without fixtures were run by hand and pass; CI runs the rest). Pending: a game run on this 16 GB / 32 GB machine (the plan's line must show the reference values) and, if anyone can, one on a smaller card. ## Oracle and test data None involved. Failure cases (`memplan.rs` tests): the reference machine gives the launcher's former values exactly; 8 and 12 GB cards and 16 GB of RAM give smaller, floored values; no cap exceeds the reference across a card x RAM grid; a switch overrides its value. ## Checklist - [x] The PR covers a single reviewable behaviour (memory caps follow the machine). - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above (pytest and the game run are pending, said above). - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Not concerned.) - [x] README: not touched (it does not state the 16 GB figure). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none. AI assistance: written with Claude Code. Claude Sonnet 5.5 wrote the change and its tests; Claude Opus 5.5 reviewed it, fixed the start-up order of the two card caps, ran the checks on my machine and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The engine's fixed memory caps were tuned for one machine (a 16 GB card with a
14.4 GB budget and 32 GB of RAM) and the launcher forced them. They are now
sized from the machine in one place, victory-gpu/src/memplan.rs.

plan(budget, ram) gives, per cap:
  cap = max(floor, reference * min(have, have_reference) / have_reference),
rounded down to 64 MiB (card caps) or 32 MiB (RAM caps), never above the
reference. Card caps (card windows, card buffers) follow the card's budget
(reference 14.4 GiB); PC caps (idle list pool and count, texture stage, stage
pool, window upload pool) follow the total RAM (reference 31 GiB, so a "32 GB"
PC that Windows reports a little under counts as the reference). The reference
values are what the launcher set: 4096 / 1536 / 2048 lists + 2048 MB / 512 /
256 / 512 MB. Floors: 256 MB card windows and buffers, 128 lists, 256 MB list
pool, 192 MB texture stage, 128 MB stage and upload pools.

Every switch (VICTORY_CARD_WINDOWS_MB, VICTORY_CARD_BUFFERS_MB,
VICTORY_LIST_POOL_MOST, VICTORY_LIST_POOL_MB, VICTORY_TEXTURE_STAGE_MB,
VICTORY_STAGE_POOL_MB, VICTORY_CARD_WINDOW_UPLOAD_MB) still wins when set. The
card windows default no longer is "4096 at a budget of 14 GiB or more, else 0":
it is the plan's value. The plan is logged once at INFO with the budget, the
RAM, each cap and the switches that overrode it.

The launcher stops setting the five absolute values; the docs and the launcher
test follow. Unit tests of the pure function run without a GPU.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:40:41 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 00:06 UTC · original

Thanks — this is exactly the area we are working on (12 GB cards). It now conflicts with #265, which changed the launcher defaults after measuring on an RTX 4070 SUPER 12 GB: VICTORY_CARD_WINDOWS_MB=1536, VICTORY_CARD_BUFFERS_MB=1536, VICTORY_LIST_POOL_MB=512, VICTORY_TEXTURE_ROOM_PERCENT=93. Could you rebase onto main, keep those as the reference for 12 GB, and update the comments that still cite a 16 GB reference card? On this card your plan() would give 3,072 MB of windows and 1,152 MB of buffers — under the ~1,189 MB of buffer copies we see in use — so a measured A/B would be welcome.

**@⁠LooperSalty** on GitHub · 2026-11-26 00:06 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/256#issuecomment-7178409886) Thanks — this is exactly the area we are working on (12 GB cards). It now conflicts with #265, which changed the launcher defaults after measuring on an RTX 4070 SUPER 12 GB: `VICTORY_CARD_WINDOWS_MB=1536`, `VICTORY_CARD_BUFFERS_MB=1536`, `VICTORY_LIST_POOL_MB=512`, `VICTORY_TEXTURE_ROOM_PERCENT=93`. Could you rebase onto main, keep those as the reference for 12 GB, and update the comments that still cite a 16 GB reference card? On this card your plan() would give 3,072 MB of windows and 1,152 MB of buffers — under the ~1,189 MB of buffer copies we see in use — so a measured A/B would be welcome.
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 10:32 UTC · original

Test report for #256 on three adapters.

Does not merge cleanly onto current main: tools/lancer_victory.ps1 and tests/test_lanceur_victory.py conflict with the launcher's fast set (#265 and later). The Rust side merges cleanly. For the Rust runs I took main's side of those two files. Setup: current origin/main (c4c93bd) merged with this PR, Windows 11, cargo test --locked in third_party/victory. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is --features diagnostics + VICTORY_D3D12_WARP=1. victory-gpu runs with --test-threads=1.

victory-gpu --lib main main + #256
RTX 4060 Laptop 183 passed, main's 3 failed 187 passed, main's 3 failed
Intel UHD 183 passed, main's 3 failed 187 passed, main's 3 failed
WARP 196 passed, main's 3 failed 200 passed, main's 3 failed

"main's 3" = descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed, indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots, indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others. They fail on all three adapters on main too. The 4 memplan tests pass everywhere. No new failure.

pytest tests/test_lanceur_victory.py: PR head (on affaf15) 19 passed. Current main 25 passed. The PR's launcher test needs redoing on top of main's.

What the plan's inputs are on this laptop (32 GB RAM, small probe calling QueryVideoMemoryInfo on each adapter):

Adapter dedicated LOCAL budget plan: card windows / card buffers
RTX 4060 Laptop (8 GB) 7,956 MB 7,188 MB 1,984 / 704 MB (my arithmetic from plan)
Intel UHD (UMA) 128 MB 15,483 MB 4,096 / 1,536 MB (the reference)
WARP 0 15,483 MB 4,096 / 1,536 MB

Notes:

  • UMA / iGPU: the LOCAL budget of an integrated GPU is system RAM (about half of it here). So on a 32 GB PC the "card" caps come out at the 16 GB-card reference, and they come out of the same RAM the RAM-side caps are sized from. Main already did this for windows (budget >= 14 GiB → 4096), so this is not a regression. But "follows the card" doesn't hold there. You could use D3D12_FEATURE_DATA_ARCHITECTURE::UMA (or the dedicated size) to cap the card side on such adapters.
  • The reference no longer matches main's launcher. Main now sets VICTORY_CARD_WINDOWS_MB=1536 ("4096 spilled VRAM on a 12 GB card") and VICTORY_LIST_POOL_MB=512. REFERENCE still says 4096 and 2048. So with the launcher's line removed, a 16 GB card would go back to 4096 windows, and a 12 GB card would get 3072, which nobody has measured. -Quality also sets these five switches explicitly, so it still works, but the rebase has to decide which numbers the reference is.
  • Without the launcher (plain victory), defaults change on big machines: idle lists 128/256 MB → 2048/2048 MB, texture stage 192 → 512 MB, card buffers 1024 → 1536 MB. That may be wanted, but the PR body doesn't say it.
  • memplan::current() calls host::host(), which creates the device on first use. If anything inside host::create reaches current() (list pool, stage pool, window upload pool), that is a re-entrant OnceLock init. The tests passed here, so I found no such path. A comment saying current() must not be called during create would help.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

**@⁠KainanP** on GitHub · 2026-11-26 10:32 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/256#issuecomment-7189495210) Test report for #256 on three adapters. **Does not merge cleanly onto current main**: `tools/lancer_victory.ps1` and `tests/test_lanceur_victory.py` conflict with the launcher's fast set (#265 and later). The Rust side merges cleanly. For the Rust runs I took main's side of those two files. Setup: current `origin/main` (c4c93bd) merged with this PR, Windows 11, `cargo test --locked` in `third_party/victory`. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is `--features diagnostics` + `VICTORY_D3D12_WARP=1`. victory-gpu runs with `--test-threads=1`. | `victory-gpu --lib` | main | main + #256 | |---|---|---| | RTX 4060 Laptop | 183 passed, main's 3 failed | 187 passed, main's 3 failed | | Intel UHD | 183 passed, main's 3 failed | 187 passed, main's 3 failed | | WARP | 196 passed, main's 3 failed | 200 passed, main's 3 failed | "main's 3" = `descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed`, `indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots`, `indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others`. They fail on all three adapters on main too. The 4 `memplan` tests pass everywhere. No new failure. `pytest tests/test_lanceur_victory.py`: PR head (on affaf15) 19 passed. Current main 25 passed. The PR's launcher test needs redoing on top of main's. What the plan's inputs are on this laptop (32 GB RAM, small probe calling `QueryVideoMemoryInfo` on each adapter): | Adapter | dedicated | LOCAL budget | plan: card windows / card buffers | |---|---|---|---| | RTX 4060 Laptop (8 GB) | 7,956 MB | 7,188 MB | 1,984 / 704 MB (my arithmetic from `plan`) | | Intel UHD (UMA) | 128 MB | **15,483 MB** | 4,096 / 1,536 MB (the reference) | | WARP | 0 | 15,483 MB | 4,096 / 1,536 MB | Notes: - **UMA / iGPU:** the LOCAL budget of an integrated GPU is system RAM (about half of it here). So on a 32 GB PC the "card" caps come out at the 16 GB-card reference, and they come out of the same RAM the RAM-side caps are sized from. Main already did this for windows (budget >= 14 GiB → 4096), so this is not a regression. But "follows the card" doesn't hold there. You could use `D3D12_FEATURE_DATA_ARCHITECTURE::UMA` (or the dedicated size) to cap the card side on such adapters. - **The reference no longer matches main's launcher.** Main now sets `VICTORY_CARD_WINDOWS_MB=1536` ("4096 spilled VRAM on a 12 GB card") and `VICTORY_LIST_POOL_MB=512`. `REFERENCE` still says 4096 and 2048. So with the launcher's line removed, a 16 GB card would go back to 4096 windows, and a 12 GB card would get 3072, which nobody has measured. `-Quality` also sets these five switches explicitly, so it still works, but the rebase has to decide which numbers the reference is. - Without the launcher (plain `victory`), defaults change on big machines: idle lists 128/256 MB → 2048/2048 MB, texture stage 192 → 512 MB, card buffers 1024 → 1536 MB. That may be wanted, but the PR body doesn't say it. - `memplan::current()` calls `host::host()`, which creates the device on first use. If anything inside `host::create` reaches `current()` (list pool, stage pool, window upload pool), that is a re-entrant `OnceLock` init. The tests passed here, so I found no such path. A comment saying `current()` must not be called during `create` would help. _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
This pull request has changes conflicting with the target branch.
  • tests/fixtures/lancer_victory_neptune.ps1
  • tests/test_lanceur_victory.py
  • third_party/victory/crates/victory-gpu/src/draw.rs
  • third_party/victory/crates/victory-gpu/src/lib.rs
  • third_party/victory/crates/victory-gpu/src/list.rs
  • third_party/victory/crates/victory-gpu/src/shadow.rs
  • third_party/victory/crates/victory-gpu/src/texture.rs
  • third_party/victory/crates/victory-gpu/src/windowup.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/256/head:github-bot/gh-256'
git switch 'github-bot/gh-256'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-256'
git switch 'github-bot/gh-256'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-256'
git switch 'github-bot/gh-256'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-256'
git switch 'main'
git merge --squash 'github-bot/gh-256'
git switch 'main'
git merge --ff-only 'github-bot/gh-256'
git switch 'main'
git merge 'github-bot/gh-256'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.