fix: reuse zeroed upload buffers for VIctory mip initialization #325

Open
github-bot wants to merge 1 commit from github-bot/gh-325 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 03:19 UTC · original
mauroalvare:codex/victory-mip-zero-upload → main · +328 −27 · 3 files · 1 commits · open

Change

tools/lancer_victory.ps1 enables levels on demand. When VIctory records a clear for a newly mapped mip in texture::card_writes, it used to create a D3D12 upload buffer and fill the entire footprint with zeros. Successive mips need identical source bytes.

Share one immutable zero source per host device. The cache grows up to 4 MiB. Each command list retains the source it recorded through submission, so a larger request can replace the cached buffer while an older source is still in use. Larger footprints use a dedicated upload buffer.

Verification

Windows x64 MSVC debug builds on the RTX 5070 Ti with driver 621.40. Baseline c4c93bdc413191a9dc909998d2d53080a3f0c880 uses the extracted clear helper and the same test fixture, with a dedicated upload buffer per clear.

Run from third_party/victory.

cargo test --locked --offline -j 2 -p victory-gpu --lib texture::zero_upload_tests::fresh_mips_share_zero_uploads -- --exact --nocapture --test-threads=1
Synthetic measurement Base Fix
Mips cleared 18 18
D3D12 upload buffers created for the clears 18 2
Bytes the CPU filled with zeros 7.875 MiB 1.25 MiB
Texture bytes verified by GPU readback 7.875 MiB 7.875 MiB

Three fresh-process A/B pairs reproduced the allocation assertion failing on the base and passing with the fix.

Command Result
baseline-test.exe --test-threads=1 183 passed, 4 failed, 3 ignored
fixed-test.exe --test-threads=1 184 passed, 3 failed, 3 ignored
cargo test --locked --offline -j 2 -p victory-loader --test load_probe 2 passed
cargo xtask policy 200 files passed
cargo test --release --manifest-path rust/Cargo.toml --locked --offline -j 1 12 passed using the matching Rust workspace
python -m pytest -ra 1,665 passed with the required runtime and the RTX 5070 Ti
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools All checks passed
git diff --check Passed

The full victory-gpu runs used the captured Cargo test binaries. Three assertions reproduced on both builds.

  • descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed got None where it expected Some(1).
  • indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots got 0 where it expected 1 in the first result slot on WARP.
  • indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others reported the first differing offsets at 0 through 7 on WARP.

Oracle and test data

The fixture creates six D3D12 textures with three mips each. It fills every mip with a generated marker byte, records the production clear, then writes a single row and verifies every byte of the readback. It records the lists before submitting, so the first source must survive cache growth. D3D12 heap types

Codex provided AI assistance with the investigation, implementation, and validation.

**@⁠mauroalvare** on GitHub · 2026-11-26 03:19 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/325) `mauroalvare:codex/victory-mip-zero-upload` → `main` · +328 −27 · 3 files · 1 commits · open ## Change `tools/lancer_victory.ps1` enables levels on demand. When VIctory records a clear for a newly mapped mip in `texture::card_writes`, it used to create a D3D12 upload buffer and fill the entire footprint with zeros. Successive mips need identical source bytes. Share one immutable zero source per host device. The cache grows up to 4 MiB. Each command list retains the source it recorded through submission, so a larger request can replace the cached buffer while an older source is still in use. Larger footprints use a dedicated upload buffer. ## Verification Windows x64 MSVC debug builds on the RTX 5070 Ti with driver 621.40. Baseline `c4c93bdc413191a9dc909998d2d53080a3f0c880` uses the extracted clear helper and the same test fixture, with a dedicated upload buffer per clear. Run from `third_party/victory`. ```powershell cargo test --locked --offline -j 2 -p victory-gpu --lib texture::zero_upload_tests::fresh_mips_share_zero_uploads -- --exact --nocapture --test-threads=1 ``` | Synthetic measurement | Base | Fix | | --- | ---: | ---: | | Mips cleared | 18 | 18 | | D3D12 upload buffers created for the clears | 18 | 2 | | Bytes the CPU filled with zeros | 7.875 MiB | 1.25 MiB | | Texture bytes verified by GPU readback | 7.875 MiB | 7.875 MiB | Three fresh-process A/B pairs reproduced the allocation assertion failing on the base and passing with the fix. | Command | Result | | --- | --- | | `baseline-test.exe --test-threads=1` | 183 passed, 4 failed, 3 ignored | | `fixed-test.exe --test-threads=1` | 184 passed, 3 failed, 3 ignored | | `cargo test --locked --offline -j 2 -p victory-loader --test load_probe` | 2 passed | | `cargo xtask policy` | 200 files passed | | `cargo test --release --manifest-path rust/Cargo.toml --locked --offline -j 1` | 12 passed using the matching Rust workspace | | `python -m pytest -ra` | 1,665 passed with the required runtime and the RTX 5070 Ti | | `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` | All checks passed | | `git diff --check` | Passed | The full `victory-gpu` runs used the captured Cargo test binaries. Three assertions reproduced on both builds. - `descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed` got `None` where it expected `Some(1)`. - `indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots` got `0` where it expected `1` in the first result slot on WARP. - `indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others` reported the first differing offsets at 0 through 7 on WARP. ## Oracle and test data The fixture creates six D3D12 textures with three mips each. It fills every mip with a generated marker byte, records the production clear, then writes a single row and verifies every byte of the readback. It records the lists before submitting, so the first source must survive cache growth. [D3D12 heap types](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_type) Codex provided AI assistance with the investigation, implementation, and validation.
Use an immutable per-device source for repeated fresh-mip clears and keep older sources alive in the lists that recorded them. Bound the cached buffer size and verify the clear and partial write against GPU readback.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:43:09 +00:00
This pull request can be merged automatically.
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/325/head:github-bot/gh-325'
git switch 'github-bot/gh-325'

Merge

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