perf: land packed linear VIctory texture readbacks directly #312

Manually merged
github merged 1 commit from github-bot/gh-312 into main 2026-11-26 14:23:03 +00:00 AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 02:16 UTC · original
mauroalvare:codex/victory-linear-readback → main · +320 −21 · 2 files · 1 commits · merged 2026-11-26 14:21 UTC

Change

The Neptune launcher enables ocean texture copy-back. When a GPU readback lands, texback::land copies title memory into a temporary buffer, tiles the readback into it, and copies the buffer back. A tightly packed linear 2D texture with one subresource already has the title's layout in the mapped readback.

Use the existing guarded title-memory copy directly for that case. Use the D3D12 unpadded row size and check both layouts, offsets and extents before selecting it. Padded rows and tiled layouts use the tiler to preserve bytes outside the texels. D3D12 copyable footprints

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880, tested with the same regression and test-only scratch counter. Release build with diagnostics for adapter selection.

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

Two 256×256 textures (R32_FLOAT and R32G32_FLOAT) receive a different row pattern on each of 64 submissions. The fixture records real GPU readbacks and checks every landed byte after the GPU finishes. A separate 65×64 fixture checks the padded rows and the guard bytes after the texture. The base passes the byte checks and fails the scratch-byte assertion. The fix passes both tests on the RTX 5070 Ti and on WARP.

RTX 5070 Ti driver 621.40, VICTORY_TEXTURE_BACK_MODES=0, five alternating pairs after one warm-up pair. Each run lands 128 readbacks. Time is the median spent in CPU copy-back after the GPU has finished. The copy volume sums the explicit CPU copies from the path and the measured scratch size.

Synthetic measurement Base Fix
CPU copy volume 144 MiB 48 MiB
Total CPU scratch allocated 48 MiB 0 bytes
Peak CPU scratch per readback 512 KiB 0 bytes
CPU copy-back time 4.00 ms 1.48 ms
  • Full victory-gpu release test binaries with --test-threads=1 — base 197 passed, 4 failed, 3 ignored. Fix 198 passed, 3 failed, 3 ignored. The three failures in both are 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 192.97 s, zero skipped. Reused the C++, Rust and TomBox builds whose source inputs match this branch.

Oracle and test data

The test generates the texture contents from integer row and frame patterns and compares them byte for byte after the D3D12 readback. It uses synthetic resources throughout. AI-assisted with OpenAI Codex.

**@⁠mauroalvare** on GitHub · 2026-11-26 02:16 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/312) `mauroalvare:codex/victory-linear-readback` → `main` · +320 −21 · 2 files · 1 commits · merged 2026-11-26 14:21 UTC ## Change The Neptune launcher enables ocean texture copy-back. When a GPU readback lands, `texback::land` copies title memory into a temporary buffer, tiles the readback into it, and copies the buffer back. A tightly packed linear 2D texture with one subresource already has the title's layout in the mapped readback. Use the existing guarded title-memory copy directly for that case. Use the D3D12 unpadded row size and check both layouts, offsets and extents before selecting it. Padded rows and tiled layouts use the tiler to preserve bytes outside the texels. [D3D12 copyable footprints](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getcopyablefootprints) ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880`, tested with the same regression and test-only scratch counter. Release build with diagnostics for adapter selection. ```powershell cd third_party/victory cargo test --locked --offline --release -j 2 -p victory-gpu --features diagnostics texback::tests:: -- --nocapture --test-threads=1 ``` Two 256×256 textures (`R32_FLOAT` and `R32G32_FLOAT`) receive a different row pattern on each of 64 submissions. The fixture records real GPU readbacks and checks every landed byte after the GPU finishes. A separate 65×64 fixture checks the padded rows and the guard bytes after the texture. The base passes the byte checks and fails the scratch-byte assertion. The fix passes both tests on the RTX 5070 Ti and on WARP. RTX 5070 Ti driver 621.40, `VICTORY_TEXTURE_BACK_MODES=0`, five alternating pairs after one warm-up pair. Each run lands 128 readbacks. Time is the median spent in CPU copy-back after the GPU has finished. The copy volume sums the explicit CPU copies from the path and the measured scratch size. | Synthetic measurement | Base | Fix | | --- | ---: | ---: | | CPU copy volume | 144 MiB | 48 MiB | | Total CPU scratch allocated | 48 MiB | 0 bytes | | Peak CPU scratch per readback | 512 KiB | 0 bytes | | CPU copy-back time | 4.00 ms | 1.48 ms | - Full `victory-gpu` release test binaries with `--test-threads=1` — base 197 passed, 4 failed, 3 ignored. Fix 198 passed, 3 failed, 3 ignored. The three failures in both are `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 192.97 s, zero skipped. Reused the C++, Rust and TomBox builds whose source inputs match this branch. ## Oracle and test data The test generates the texture contents from integer row and frame patterns and compares them byte for byte after the D3D12 readback. It uses synthetic resources throughout. AI-assisted with OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:42:43 +00:00
github manually merged commit a4dabd1b6d into main 2026-11-26 14:23:03 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.