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

Open
Mikey970 wants to merge 2 commits from upstream-pr/3751 into main
Mikey970 commented 2026-11-30 05:57:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Mikey970 on 2026-11-30T05:57:02Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5559896428 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3751). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-30T05:57:02Z. --- **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)
Dukestar69 commented 2026-11-30 06:10:25 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-30T06:10:25Z.

Review: APPROVED


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).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6107607444 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3751#pullrequestreview-6107607444). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-30T06:10:25Z. **Review:** APPROVED --- 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).
Mikey970 commented 2026-11-30 14:44:22 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Mikey970 on 2026-11-30T14:44:22Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7281852946 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3751#issuecomment-7281852946). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-30T14:44:22Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3751:upstream-pr/3751'
git switch 'upstream-pr/3751'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3751'
git switch 'upstream-pr/3751'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3751'
git switch 'upstream-pr/3751'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3751'
git switch 'main'
git merge --squash 'upstream-pr/3751'
git switch 'main'
git merge --ff-only 'upstream-pr/3751'
git switch 'main'
git merge 'upstream-pr/3751'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

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