fix: avoid unnecessary VIctory tile heap allocations #316

Open
github-bot wants to merge 3 commits from github-bot/gh-316 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 02:32 UTC · original
mauroalvare:codex/victory-tile-pool-fit → main · +282 −13 · 2 files · 3 commits · open

Change

Neptune's levels-on-demand texture path maps mips into a pool of 64 MiB D3D12 heaps. The first heap with enough total free tiles can have the only space available for a large mip. If a smaller mip takes that space, the large one needs a new heap even when the smaller mip could have used a tighter fit.

Pick the existing heap with the fewest free tiles that can satisfy the request. Stop looking at an exact fit and maintain the free count under the pool lock so selection does not have to sum each heap's free ranges. Texture levels still map using the tile ranges selected by the allocator. D3D12 tile mappings

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880. The same test was built on the base and on the fix in the release profile with diagnostics for adapter selection.

cd third_party/victory
cargo test --locked --offline --release -j 2 -p victory-gpu --features diagnostics mixed_mip_sizes_reuse_two_heaps -- --ignored --nocapture --test-threads=1

Two heaps start with 768 and 256 tiles free. The larger free space spans two separate ranges. Each of eight rounds maps a 256-tile mip followed by a 768-tile mip and releases both. The test writes both textures before reading three RGBA markers from each, including the far corner of the large mip in the second range. The base passes marker readback and fails the two-heap bound. The fix passes both checks on the RTX 5070 Ti and on WARP.

RTX 5070 Ti, driver 621.40. Five alternating pairs after one warm-up pair, with a fresh process and tile pool for each run. Heap bytes are the pool's D3D12 heap sizes. CPU time is the median for reservation and mapping across all eight rounds.

Synthetic measurement Base Fix
Peak tile heap bytes 192 MiB 128 MiB
Heaps created, including the two initial heaps 10 2
Heaps returned during the rounds 8 0
CPU reservation and mapping time 10.69 ms 1.12 ms
  • The existing tiles::tests::levels_on_demand_on_the_card fixture also passed on WARP when run by name with --ignored --nocapture --test-threads=1.
  • The complete victory-gpu release test binaries with --test-threads=1 both reported 196 passed, 3 failed and 4 ignored. The same three failures reproduce on the base: spans_say_the_next_start_and_the_lowest_level_viewed, warp_card_fetch_copies_flagged_pieces_to_their_slots, and warp_card_patch_writes_the_masked_bytes_and_no_others.
  • cargo xtask policy — 200 files OK.
  • python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools — All checks passed.
  • python -m pytest -ra with ANYXBOXX_REQUIRE_RUNTIME=1 — 1665 passed in 89.83 s, zero skipped. Reused the C++, Rust and TomBox binaries built from the same source inputs.

Oracle and test data

The fixture generates the RGBA markers from the round and sample indices and reads them back byte for byte through D3D12. The reservations and textures are synthetic. AI-assisted with OpenAI Codex.

**@⁠mauroalvare** on GitHub · 2026-11-26 02:32 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/316) `mauroalvare:codex/victory-tile-pool-fit` → `main` · +282 −13 · 2 files · 3 commits · open ## Change Neptune's levels-on-demand texture path maps mips into a pool of 64 MiB D3D12 heaps. The first heap with enough total free tiles can have the only space available for a large mip. If a smaller mip takes that space, the large one needs a new heap even when the smaller mip could have used a tighter fit. Pick the existing heap with the fewest free tiles that can satisfy the request. Stop looking at an exact fit and maintain the free count under the pool lock so selection does not have to sum each heap's free ranges. Texture levels still map using the tile ranges selected by the allocator. [D3D12 tile mappings](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12commandqueue-updatetilemappings) ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880`. The same test was built on the base and on the fix in the release profile with diagnostics for adapter selection. ```powershell cd third_party/victory cargo test --locked --offline --release -j 2 -p victory-gpu --features diagnostics mixed_mip_sizes_reuse_two_heaps -- --ignored --nocapture --test-threads=1 ``` Two heaps start with 768 and 256 tiles free. The larger free space spans two separate ranges. Each of eight rounds maps a 256-tile mip followed by a 768-tile mip and releases both. The test writes both textures before reading three RGBA markers from each, including the far corner of the large mip in the second range. The base passes marker readback and fails the two-heap bound. The fix passes both checks on the RTX 5070 Ti and on WARP. RTX 5070 Ti, driver 621.40. Five alternating pairs after one warm-up pair, with a fresh process and tile pool for each run. Heap bytes are the pool's D3D12 heap sizes. CPU time is the median for reservation and mapping across all eight rounds. | Synthetic measurement | Base | Fix | | --- | ---: | ---: | | Peak tile heap bytes | 192 MiB | 128 MiB | | Heaps created, including the two initial heaps | 10 | 2 | | Heaps returned during the rounds | 8 | 0 | | CPU reservation and mapping time | 10.69 ms | 1.12 ms | - The existing `tiles::tests::levels_on_demand_on_the_card` fixture also passed on WARP when run by name with `--ignored --nocapture --test-threads=1`. - The complete `victory-gpu` release test binaries with `--test-threads=1` both reported 196 passed, 3 failed and 4 ignored. The same three failures reproduce on the base: `spans_say_the_next_start_and_the_lowest_level_viewed`, `warp_card_fetch_copies_flagged_pieces_to_their_slots`, and `warp_card_patch_writes_the_masked_bytes_and_no_others`. - `cargo xtask policy` — 200 files OK. - `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` — All checks passed. - `python -m pytest -ra` with `ANYXBOXX_REQUIRE_RUNTIME=1` — 1665 passed in 89.83 s, zero skipped. Reused the C++, Rust and TomBox binaries built from the same source inputs. ## Oracle and test data The fixture generates the RGBA markers from the round and sample indices and reads them back byte for byte through D3D12. The reservations and textures are synthetic. AI-assisted with OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:42:50 +00:00
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/316/head:github-bot/gh-316'
git switch 'github-bot/gh-316'

Merge

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