Skip to content

Formats: keep deep 3D mips out of the thick mip tail (VIC-BT-014) - #1499

Closed
tdogghockey wants to merge 2 commits into
Marvisak:mainfrom
tdogghockey:fix/thick-3d-mip-tail-depth
Closed

tdogghockey wants to merge 2 commits into
Marvisak:mainfrom
tdogghockey:fix/thick-3d-mip-tail-depth

Conversation

@tdogghockey

Copy link
Copy Markdown

What

Fixes backlog item VIC-BT-014: thick 3D layouts' mip-tail predicate checked width and height, but not depth. A deep 3D mip (e.g. 16x16x64, Sw64KbS) could therefore wrongly enter the one-block mip tail: its first mip had tail: Some(...) and first_tail_mip == 0.

The condition now also requires mip_depth(i) <= fixed[2] for thick layouts, matching the block's depth limit. This is a one-line behavioral change; no game data, assets or generated data are added.

TDD evidence

  • RED: cargo test -p victory-formats --locked deep_3d_mips_do_not_enter_the_mip_tail failed before the fix with mip 0 has 64 slices and cannot fit one tail block: Mip { ... tail: Some(Tail { offset: 8192, x: 16, y: 0 }) }.
  • GREEN: same test passes after the fix; full crate: cargo test -p victory-formats --locked -> 24 passed, 0 failed, 4 ignored (4 pre-existing ignored benchmark/reference tests).
  • Lint: cargo clippy -p victory-formats --all-targets --locked -- -D warnings clean.
  • Asset policy: cargo xtask policy -> 154 files ok.
  • git diff --check clean.

Duplicate check

Checked all open upstream PR titles and changed-file lists (820 open PRs at time of writing). No open PR contains this fix; among the newest PRs touching victory-formats/src/texture.rs, only #1330 appears, and its diff has no mip-tail changes. This fix is also independent of the XMA/SGD5 and Linux-build patches posted on forks.

Limitations

This machine is aarch64 Linux, and the full workspace does not compile here because of the pre-existing non-Windows host_resource cfg issue also covered by #1241; victory-pe's current_exe() tests have the same known host assumption. I verified this crate locally; upstream CI on windows-latest will check the workspace. Windows MSVC cross-check was attempted but cannot run here because ml64.exe is unavailable.

AI use: Claude Code wrote the fix and tests and ran the checks at my request.

RED: cargo test -p victory-formats --locked deep_3d_mips_do_not_enter_the_mip_tail
failed: mip 0 (16x16x64, Sw64KbS) wrongly has tail: Some(Tail { offset: 8192, ... })
and first_tail_mip == 0. Test exercises Layout::new's mip-tail predicate with
a deep 3D mip whose depth exceeds the block's depth.
GREEN: cargo test -p victory-formats --locked
24 passed, 0 failed, 4 ignored (focused reproducer: 1 passed).
cargo clippy -p victory-formats --all-targets --locked -- -D warnings: clean.
cargo xtask policy: 154 files ok.

The tail predicate now also requires mip_depth(i) <= fixed[2] for thick
3D layouts, matching the block's depth limit.
@tdogghockey

Copy link
Copy Markdown
Author

Closing in favour of the earlier PRs #1450 and #1494, which fix the same VIC-BT-014 defect with overlapping tests. My duplicate-check scan was run before those PRs appeared; thanks to the maintainers/reporters.

@tdogghockey
tdogghockey deleted the fix/thick-3d-mip-tail-depth branch November 24, 2026 18:48
nazmi added a commit to nazmi/VIctory that referenced this pull request Nov 24, 2026
64x64x256, 7 mips, SW_4KB_S: the tail must start at mip 5, not 3, because
mips 3 and 4 are deeper than the 4 KiB thick block. The PR (Marvisak#1499) fixed the
predicate but added no test; this pins it, and the numbers come from running
both versions: 5,636,096 bytes before, 5,898,240 after. Verified non-vacuous:
reverting the predicate makes it fail with first_tail_mip 3 != 5.

Under-allocating here is the dangerous direction, so the fix can only make the
layout larger.
nazmi added a commit to nazmi/VIctory that referenced this pull request Nov 24, 2026
Review workers over ~45 more PRs against the merged upstream tree.

Integrated: Marvisak#1394 (antisymmetric XUserCompare), Marvisak#1390 (A8_UNORM is not in
the R8 typeless family), Marvisak#1499 (deep 3D mips stay out of the thick tail,
plus a regression test the PR lacked), Marvisak#1366 (mesh stage I/O does not parse
VS inputs), Marvisak#1594 (the title's exit status reaches the shell), Marvisak#1299 (docs:
validator prerequisite), Marvisak#1515 (dialog commands before init), Marvisak#1424 (empty
submissions skip the lock), Marvisak#1144 (shader differential skips are reported),
Marvisak#1129 (64 MB pipeline-worker stacks), Marvisak#1564/Marvisak#1565/Marvisak#1566 (MakeResident,
Evict and SetStablePowerState succeed as the console's do), Marvisak#1250 (a zero
element count reads to the end of the buffer), Marvisak#1628 (texture-creation
failure logs its states).

Re-applied after the upstream merge dropped them: f32_to_half NaN and
ties-to-even (Marvisak#843), unique-temp library writes (Marvisak#1660),
VICTORY_PIPELINE_WORKERS (Marvisak#1728), VICTORY_MODE (Marvisak#1701).

Removed: the orphaned depth-bounds test file, whose implementation
(9a6d9e6) the merge dropped and which no module compiled.

Refused: Marvisak#1099 (writing 0 for an unpaired p1 interpolation computes wrong
values; two reviewers upstream and one here reached the same conclusion).
Duplicates: Marvisak#1217, Marvisak#529, Marvisak#531, Marvisak#590, Marvisak#1102, Marvisak#398, Marvisak#1150, Marvisak#1220.

Gate at efda2c5: fmt 0 differing, both Clippy gates 0 errors, policy 219
files, workspace 674 passed / 0 failed with the 10 documented pre-existing
GPU skips.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant