gpu(native): VICTORY_TRACE_UNMAPPED_LEVELS=1 — host bytes of wholly unmapped mip levels (#458 measure-first) #496

Open
AnastasisKon wants to merge 2 commits from upstream-pr/496 into main
AnastasisKon commented 2026-11-27 22:15:33 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T22:15:33Z.


What this changes

Refs #458, the measure-first step only (no behaviour change; the levels-on-demand remake stays for after the measurement).

  • PoolTable::mapped_len(addr, len): bytes of a range currently mapped in a live pool, coalescing adjacent mappings like read_mapped_with. Pinned by mapped_len_sums_overlaps_and_ignores_gaps_and_dead_pools.
  • VICTORY_TRACE_UNMAPPED_LEVELS=1 (off by default, documented in docs/native-host.md): every 64 submissions, one line unmapped levels: <MB>MB in <n> levels of <n> textures (f<fmt>=<MB>MB …) — the bytes of mip levels whose title pages are all unmapped, total and per format (six largest). Title-level bytes stand in for host bytes (same texel count); slice 0's range stands in for every slice's — both noted in the doc entry. The per-texture aggregation is the pure unmapped_level_bytes, pinned by unmapped_level_bytes_counts_only_wholly_unmapped_levels.

Off, the cost is one OnceLock read of the switch per submission.

How it was tested

  • cargo test -p victory-gpu — 414 passed (incl. the 2 new tests), 0 failed, arm64 host with the Metal Shader Converter present
  • cargo test -p victory-hle -p victory -p xtask — pass
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — pass (RC=0, 0 errors)
  • cargo xtask policy — pass (398 files ok)
  • Ran the game: not needed for the switch itself; the follow-up is a world run with VICTORY_TRACE_UNMAPPED_LEVELS=1 on a machine with a game copy, read with run-summary.sh

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked — n/a, diagnostic only; the byte approximations are documented in the native-host.md entry
  • New diagnostics are behind a VICTORY_* variable (VICTORY_TRACE_UNMAPPED_LEVELS) and documented in docs/native-host.md
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5533793848 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/496). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T22:15:33Z. --- ## What this changes Refs #458, the measure-first step only (no behaviour change; the levels-on-demand remake stays for after the measurement). - `PoolTable::mapped_len(addr, len)`: bytes of a range currently mapped in a live pool, coalescing adjacent mappings like `read_mapped_with`. Pinned by `mapped_len_sums_overlaps_and_ignores_gaps_and_dead_pools`. - `VICTORY_TRACE_UNMAPPED_LEVELS=1` (off by default, documented in docs/native-host.md): every 64 submissions, one line `unmapped levels: <MB>MB in <n> levels of <n> textures (f<fmt>=<MB>MB …)` — the bytes of mip levels whose title pages are all unmapped, total and per format (six largest). Title-level bytes stand in for host bytes (same texel count); slice 0's range stands in for every slice's — both noted in the doc entry. The per-texture aggregation is the pure `unmapped_level_bytes`, pinned by `unmapped_level_bytes_counts_only_wholly_unmapped_levels`. Off, the cost is one `OnceLock` read of the switch per submission. ## How it was tested - [x] `cargo test -p victory-gpu` — 414 passed (incl. the 2 new tests), 0 failed, arm64 host with the Metal Shader Converter present - [x] `cargo test -p victory-hle -p victory -p xtask` — pass - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — pass (RC=0, 0 errors) - [x] `cargo xtask policy` — pass (398 files ok) - [x] Ran the game: not needed for the switch itself; the follow-up is a world run with `VICTORY_TRACE_UNMAPPED_LEVELS=1` on a machine with a game copy, read with run-summary.sh ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked — n/a, diagnostic only; the byte approximations are documented in the native-host.md entry - [x] New diagnostics are behind a `VICTORY_*` variable (`VICTORY_TRACE_UNMAPPED_LEVELS`) and documented in docs/native-host.md
Olima34 commented 2026-11-28 00:37:21 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:37:21Z.

Review: CHANGES_REQUESTED


Thanks for this PR! We're helping the maintainer clear the queue tonight, and main has moved a lot (the preview branch landed as 86cefd22, then a batch of PRs; main is now a6a58361). This branch now conflicts with main in docs/native-host.md.

Could you merge current main into the branch (a merge commit is fine, no need to rebase) and resolve the conflict? It's only the docs paragraph. Once GitHub shows it as mergeable and CI is green on the new head, we'll read it through and merge it if it holds up.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6094670152 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/496#pullrequestreview-6094670152). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T00:37:21Z. **Review:** CHANGES_REQUESTED --- Thanks for this PR! We're helping the maintainer clear the queue tonight, and main has moved a lot (the preview branch landed as 86cefd22, then a batch of PRs; main is now a6a58361). This branch now conflicts with main in `docs/native-host.md`. Could you merge current `main` into the branch (a merge commit is fine, no need to rebase) and resolve the conflict? It's only the docs paragraph. Once GitHub shows it as mergeable and CI is green on the new head, we'll read it through and merge it if it holds up.
AnastasisKon commented 2026-11-28 10:18:29 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T10:18:29Z.


Merged current main into the branch and resolved the conflict keeping both sides, as requested. CI is green on the new head and the PR shows mergeable. Ready for re-review.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7237810456 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/496#issuecomment-7237810456). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T10:18:29Z. --- Merged current main into the branch and resolved the conflict keeping both sides, as requested. CI is green on the new head and the PR shows mergeable. Ready for re-review.
AnastasisKon commented 2026-11-28 12:31:51 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:31:51Z.


Re-requesting review: conflicts with current main are resolved, CI is green on the latest head, and the earlier approval was noted as still standing. Ready to merge when you are.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239290633 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/496#issuecomment-7239290633). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:31:51Z. --- Re-requesting review: conflicts with current main are resolved, CI is green on the latest head, and the earlier approval was noted as still standing. Ready to merge when you are.
AnastasisKon commented 2026-11-28 15:27:23 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T15:27:23Z.


The branch is now based on the current public main (26817285), which already contains the #467/#494/#503 merges, and GitHub shows mergeable=true (the earlier conflict was against the newer private main). The requested shape is in place: the `VICTORY_TRACE_UNMAPPED_LEVELS` paragraph in `docs/native-host.md`. Could you re-review when you get a chance?

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7241479707 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/496#issuecomment-7241479707). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T15:27:23Z. --- The branch is now based on the current public `main` (26817285), which already contains the #467/#494/#503 merges, and GitHub shows `mergeable=true` (the earlier conflict was against the newer private main). The requested shape is in place: the \`VICTORY_TRACE_UNMAPPED_LEVELS\` paragraph in \`docs/native-host.md\`. Could you re-review when you get a chance?
AnastasisKon commented 2026-11-28 18:16:48 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T18:16:48Z.


Re-requesting review: the head c8dd335e already merges public main 26817285, and git merge-tree shows no conflicts against current main — the docs/native-host.md paragraph is resolved with main's version plus this PR's section. CI is green on this head. Ready to merge when you are.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7243669162 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/496#issuecomment-7243669162). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T18:16:48Z. --- Re-requesting review: the head c8dd335e already merges public `main` 26817285, and `git merge-tree` shows no conflicts against current `main` — the `docs/native-host.md` paragraph is resolved with main's version plus this PR's section. CI is green on this head. Ready to merge when you are.
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/496:upstream-pr/496'
git switch 'upstream-pr/496'

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/496'
git switch 'upstream-pr/496'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/496'
git switch 'upstream-pr/496'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/496'
git switch 'main'
git merge --squash 'upstream-pr/496'
git switch 'main'
git merge --ff-only 'upstream-pr/496'
git switch 'main'
git merge 'upstream-pr/496'
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
LakshanSivakumar/Native-Victory-macOS!496
No description provided.