gpu(native): resolve buffer ranges that run over adjacent pool mappings #53

Manually merged
github merged 4 commits from gh-pr/53/head into gh-pr/53/base 2026-11-26 14:44:07 +00:00
Owner

@⁠Sandile-0511 on GitHub · 2026-11-26 11:34 UTC · original
Sandile-0511:fix/pool-ranges-across-mappings → main · +63 −5 · 2 files · 4 commits · merged 2026-11-26 12:54 UTC

What this changes

PoolTable::resolve refused any range that crossed from one mapping into the next, and its own comment said to merge them "if a title builds a buffer view across a map boundary". The HLE side reports the pages of one allocation one 64 KiB mapping at a time, so every buffer view that crosses a page edge was refused, and its heap entry was left unwritten ("a descriptor was not mirrored ... is not in a mapped pool").

resolve now follows mappings that continue each other both in title memory and in the same pool. A range over a gap, over two pools, or over mappings that are not next to each other in the pool is still refused, since one pointer cannot show it.

Related: the story-mode load in #15 and my tester report #13.

How it was tested

  • cargo test -p victory-gpu --lib on arm64: 146 passed, 0 failed, 1 ignored. New test a_range_over_adjacent_mappings_resolves_when_the_pool_continues (three pages in pool order, a non-contiguous next page, another pool, a wrapping length).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings (clean, run on a Mac)
  • cargo xtask policy (365 files ok)
  • Ran the game, as part of a combined local build (base M5, 24 GB, Series X mode, base 9733707): "a descriptor was not mirrored" lines fell from 2,417 to 33 in a 170 s run, and the run went from sitting on the loading screen after Confirm to reading story data again and binding the first world pipelines. Not run with this change alone on current main.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none made)
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Sandile-0511** on GitHub · 2026-11-26 11:34 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/53) `Sandile-0511:fix/pool-ranges-across-mappings` → `main` · +63 −5 · 2 files · 4 commits · merged 2026-11-26 12:54 UTC ## What this changes `PoolTable::resolve` refused any range that crossed from one mapping into the next, and its own comment said to merge them "if a title builds a buffer view across a map boundary". The HLE side reports the pages of one allocation one 64 KiB mapping at a time, so every buffer view that crosses a page edge was refused, and its heap entry was left unwritten ("a descriptor was not mirrored ... is not in a mapped pool"). `resolve` now follows mappings that continue each other both in title memory and in the same pool. A range over a gap, over two pools, or over mappings that are not next to each other in the pool is still refused, since one pointer cannot show it. Related: the story-mode load in #15 and my tester report #13. ## How it was tested - [x] `cargo test -p victory-gpu --lib` on arm64: 146 passed, 0 failed, 1 ignored. New test `a_range_over_adjacent_mappings_resolves_when_the_pool_continues` (three pages in pool order, a non-contiguous next page, another pool, a wrapping length). - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` (clean, run on a Mac) - [x] `cargo xtask policy` (365 files ok) - [x] Ran the game, as part of a combined local build (base M5, 24 GB, Series X mode, base `9733707`): "a descriptor was not mirrored" lines fell from 2,417 to 33 in a 170 s run, and the run went from sitting on the loading screen after Confirm to reading story data again and binding the first world pipelines. Not run with this change alone on current `main`. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none made) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:44:07 +00:00
github manually merged commit 6064f0b58c into gh-pr/53/base 2026-11-26 14:44:07 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 11:51 UTC · original · requested changes

Thanks for covering both title-address and pool-offset continuity. Please reject zero-length mappings or make the walk stop on one. A zero-length entry at the next address with the expected pool and offset currently hangs resolve under the table lock (crates/victory-gpu/src/native/memory.rs ~115). Please also update the size guidance in docs/native-host.md (~239) to describe when a range can span title mappings.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 11:51 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/53#pullrequestreview-6073656216) · **requested changes** Thanks for covering both title-address and pool-offset continuity. Please reject zero-length mappings or make the walk stop on one. A zero-length entry at the next address with the expected pool and offset currently hangs `resolve` under the table lock (`crates/victory-gpu/src/native/memory.rs` ~115). Please also update the size guidance in `docs/native-host.md` (~239) to describe when a range can span title mappings.
Author
Owner

@⁠Sandile-0511 on GitHub · 2026-11-26 12:30 UTC · original

Thanks, that was a real hang. The walk now stops at an empty mapping (next.len == 0 returns None), and an_empty_mapping_ends_the_walk covers a zero-length entry at the next address with the pool and offset that would continue the first. Without the guard that test spins and never returns. I also extended item 5 under "Interfaces for the Metal backend" in docs/native-host.md to say when a range can run over several title mappings and when it is refused.

**@⁠Sandile-0511** on GitHub · 2026-11-26 12:30 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/53#issuecomment-7192092398) Thanks, that was a real hang. The walk now stops at an empty mapping (`next.len == 0` returns `None`), and `an_empty_mapping_ends_the_walk` covers a zero-length entry at the next address with the pool and offset that would continue the first. Without the guard that test spins and never returns. I also extended item 5 under "Interfaces for the Metal backend" in `docs/native-host.md` to say when a range can run over several title mappings and when it is refused.
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 12:48 UTC · original · approved these changes

Thanks, the earlier requests are addressed and the checks pass (tests incl. Metal, Windows clippy, policy). Approved.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 12:48 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/53#pullrequestreview-6074381311) · **approved these changes** Thanks, the earlier requests are addressed and the checks pass (tests incl. Metal, Windows clippy, policy). Approved.
This discussion has been locked. Commenting is limited to contributors.
No description provided.