Card accounting: weigh only the levels a host copy holds #3751

Open
github-bot wants to merge 2 commits from github-bot/gh-3751 into main AGit
Owner

@⁠Mikey970 on GitHub · 2026-11-30 05:57 UTC · original
Mikey970:pr/card-accounting-held-levels → main · +129 −30 · 1 files · 2 commits · open

Title: [pr-diagnostics] Card accounting: weigh only the levels a host copy holds

Fixes #

What it changes

VICTORY_CARD_ACCOUNTING=1 writes a line that says … of which N MB are levels whose title memory is not mapped. With held_only, a host copy of the levels a view shows holds the title's levels from HostTexture::base on. But card_accounting in resource.rs shared the copy's bytes over every level of the description. So the larger levels the copy never held, which are usually not mapped, made up most of the copy's weight, and the unmapped MB were overstated.

What changes:

  • Only the levels a copy holds are weighed now, missing levels included. The weighing is in a new pure function, held_levels, with a unit test: card_accounting_weighs_only_the_levels_a_host_copy_holds.
  • "The largest level" now means the largest level the copy holds.
  • Copies whose held levels are all mapped no longer count as partly mapped.
  • The line ends with two new counts, each with its MB: copies with no held level mapped (dead), and copies with every held level mapped.

This is diagnostics only and changes no behaviour.

How it was tested

  • In game on this branch's base (main 41adb551 + this change): the full route completed and the line carries the new tail, e.g. card accounting: room true, the card 11939 MB in use of a budget of 14124 MB; … alive 2902 MB, of which 961 MB are levels whose title memory is not mapped … weighed by the levels each copy holds: 2095 copies 240 MB with no held level mapped, 58305 copies 1849 MB with every held level mapped. Build: main at 41adb551 with this change, release, RTX 4080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Series X profile, DLSS Performance through Streamline (1080p rendered, 3840x2160 output), ray tracing off, frame generation off, warm pipeline cache from an earlier run, the 375 s Chapter 1 route (interrogation, therapist, flyover, boat, shore) driven by VICTORY_KEYS.

  • GPU and profile: RTX 4080, 32 GB RAM, Series X profile, 1080p rendered to 4K with DLSS, Chapter 1 flyover. Measured first on our fork's build (figures below); the in-game check on this branch is above.

  • Before: the line reported 3,100–4,600 MB of about 7,000 MB of host copies as levels not mapped.

  • After: weighed by held levels, the same scene reports 2,900 MB. The new tail of the line reported 1,686–1,779 MB in copies with no held level mapped.

  • For shader changes, the wave sizes tested: n/a

  • cargo test passed for the crates it touches: yes. cargo test -p victory-gpu --lib card_accounting gave 1 passed. Clippy for victory-gpu (--all-targets, and again with --all-features) added no new warnings. Pristine main already fails -D warnings: victory-shader has 3 errors, and victory-gpu has 25 pre-existing warnings. None of them are in this change. cargo xtask policy --staged passed.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: none found. Searches for "card accounting" and held_only turned up #3454, #2986 and #2538, which change card admission and eviction, not this diagnostic's arithmetic.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 05:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3751) `Mikey970:pr/card-accounting-held-levels` → `main` · +129 −30 · 1 files · 2 commits · open **Title:** [pr-diagnostics] Card accounting: weigh only the levels a host copy holds Fixes # ## What it changes `VICTORY_CARD_ACCOUNTING=1` writes a line that says `… of which N MB are levels whose title memory is not mapped`. With `held_only`, a host copy of the levels a view shows holds the title's levels from `HostTexture::base` on. But `card_accounting` in `resource.rs` shared the copy's bytes over *every* level of the description. So the larger levels the copy never held, which are usually not mapped, made up most of the copy's weight, and the unmapped MB were overstated. What changes: - Only the levels a copy holds are weighed now, missing levels included. The weighing is in a new pure function, `held_levels`, with a unit test: `card_accounting_weighs_only_the_levels_a_host_copy_holds`. - "The largest level" now means the largest level the copy holds. - Copies whose held levels are all mapped no longer count as partly mapped. - The line ends with two new counts, each with its MB: copies with no held level mapped (dead), and copies with every held level mapped. This is diagnostics only and changes no behaviour. ## How it was tested - **In game on this branch's base (`main` 41adb551 + this change):** the full route completed and the line carries the new tail, e.g. `card accounting: room true, the card 11939 MB in use of a budget of 14124 MB; … alive 2902 MB, of which 961 MB are levels whose title memory is not mapped … weighed by the levels each copy holds: 2095 copies 240 MB with no held level mapped, 58305 copies 1849 MB with every held level mapped`. Build: `main` at 41adb551 with this change, release, RTX 4080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Series X profile, DLSS Performance through Streamline (1080p rendered, 3840x2160 output), ray tracing off, frame generation off, warm pipeline cache from an earlier run, the 375 s Chapter 1 route (interrogation, therapist, flyover, boat, shore) driven by `VICTORY_KEYS`. - GPU and profile: RTX 4080, 32 GB RAM, Series X profile, 1080p rendered to 4K with DLSS, Chapter 1 flyover. Measured first on our fork's build (figures below); the in-game check on this branch is above. - Before: the line reported 3,100–4,600 MB of about 7,000 MB of host copies as levels not mapped. - After: weighed by held levels, the same scene reports 2,900 MB. The new tail of the line reported 1,686–1,779 MB in copies with no held level mapped. - For shader changes, the wave sizes tested: n/a - `cargo test` passed for the crates it touches: yes. `cargo test -p victory-gpu --lib card_accounting` gave 1 passed. Clippy for `victory-gpu` (`--all-targets`, and again with `--all-features`) added no new warnings. Pristine `main` already fails `-D warnings`: `victory-shader` has 3 errors, and `victory-gpu` has 25 pre-existing warnings. None of them are in this change. `cargo xtask policy --staged` passed. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none found. Searches for "card accounting" and `held_only` turned up #3454, #2986 and #2538, which change card admission and eviction, not this diagnostic's arithmetic. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A copy of the levels viewed holds the title's levels from its base on
(held_only), but the walk shared its bytes over every level of the
description and overstated the MB of levels not mapped: the larger levels
it never held, not mapped, counted as most of them (3,100-4,600 MB of
7,000 where the held levels alone say 2,900). Only held levels are weighed
now (held_levels, with a test), copies whose held levels are all mapped no
longer count as partly mapped, and the line ends with the copies and MB
with no held level mapped and with every held level mapped.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 05:57:26 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-30 06:10 UTC · original · approved these changes

Tested locally merged onto main (41adb551).

  • Merge: Clean merge in crates/victory-gpu/src/resource.rs.
  • Tests (RTX 5090): cargo test -p victory-gpu --lib resource:: passed (45 passed; 0 failed; 1 ignored, including the new card_accounting_weighs_only_the_levels_a_host_copy_holds test) with 0 new warnings.

Accurate VRAM accounting weighing only the mip levels a host copy actually holds. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-30 06:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3751#pullrequestreview-6107607444) · **approved these changes** Tested locally merged onto `main` (`41adb551`). - **Merge**: Clean merge in `crates/victory-gpu/src/resource.rs`. - **Tests (RTX 5090)**: `cargo test -p victory-gpu --lib resource::` passed (`45 passed; 0 failed; 1 ignored`, including the new `card_accounting_weighs_only_the_levels_a_host_copy_holds` test) with 0 new warnings. Accurate VRAM accounting weighing only the mip levels a host copy actually holds. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
`held_levels` set `largest_missing` only in the loop over levels before
the tail, so a host copy whose `base` lies in the mip tail, with the
tail not mapped, did not count its largest level as missing. Test cases
added to `card_accounting_weighs_only_the_levels_a_host_copy_holds`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 14:44 UTC · original

Small follow-up 955b5540: held_levels set largest_missing only for levels before the mip tail. A host copy whose base lies inside the tail, with the tail not mapped, therefore did not count its largest level as missing; now it does. I added two cases to card_accounting_weighs_only_the_levels_a_host_copy_holds (passes) and found no new clippy warnings. Still merges cleanly with main.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 14:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3751#issuecomment-7281852946) Small follow-up `955b5540`: `held_levels` set `largest_missing` only for levels before the mip tail. A host copy whose `base` lies inside the tail, with the tail not mapped, therefore did not count its largest level as missing; now it does. I added two cases to `card_accounting_weighs_only_the_levels_a_host_copy_holds` (passes) and found no new clippy warnings. Still merges cleanly with `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3751'
git switch 'github-bot/gh-3751'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3751'
git switch 'github-bot/gh-3751'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3751'
git switch 'main'
git merge --squash 'github-bot/gh-3751'
git switch 'main'
git merge --ff-only 'github-bot/gh-3751'
git switch 'main'
git merge 'github-bot/gh-3751'
git push origin 'main'
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!3751
No description provided.