Texture layouts: mips in the tail report the surface's swizzle mode, as they are addressed #902

Manually merged
github merged 1 commit from github-bot/gh-902 into main 2026-11-28 19:42:52 +00:00 AGit
Owner

@⁠wildheathen on GitHub · 2026-11-28 08:52 UTC · original
wildheathen:xg-tail-swizzle → main · +5 −13 · 1 files · 1 commits · merged 2026-11-28 19:39 UTC

Change

XGCreateTextureComputer's layout reported the mips in the tail in a 256-byte mode (SW_256B_S, SW_256B_D, or 3 for the render modes) while every mip above the tail reported the surface's own mode. Now every mip reports the surface's mode.

Why

A mip tail is not a separate surface: the small mips sit inside one block of the surface's own swizzle mode, at fixed positions within it (addrlib's GetMipTailDim and the mip tail offsets in ComputeSurfaceAddrFromCoordMacroTiled). Layout::offset already addresses them that way: row and column shift the coordinate by the mip's tail position and apply the surface's pattern. The computer's output told a caller the opposite, so anything computing addresses from a mip's mode would use a pattern the data is not stored in.

Impact

None visible today, as far as we know: the title reads offsets 0x00, 0x08, 0x10 and 0x1c of each mip (see the comment on MipOut), not the mode. This makes the layout agree with the addresses the same object gives.

Tests

  • layout_and_copies_through_the_object now also checks that all 9 mips of a 256x256 BC7 texture in SW_64KB_D (8 of them in the tail) report mode 10.
  • cargo test -p victory-hle --lib modules::xg: 23 passed.
  • Clippy on victory-hle: nothing in the changed lines (the two existing warnings are in shadow.rs and gameinput.rs).

Not run with the game.

**@⁠wildheathen** on GitHub · 2026-11-28 08:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/902) `wildheathen:xg-tail-swizzle` → `main` · +5 −13 · 1 files · 1 commits · merged 2026-11-28 19:39 UTC ## Change `XGCreateTextureComputer`'s layout reported the mips in the tail in a 256-byte mode (`SW_256B_S`, `SW_256B_D`, or 3 for the render modes) while every mip above the tail reported the surface's own mode. Now every mip reports the surface's mode. ## Why A mip tail is not a separate surface: the small mips sit inside one block of the surface's own swizzle mode, at fixed positions within it (addrlib's `GetMipTailDim` and the mip tail offsets in `ComputeSurfaceAddrFromCoordMacroTiled`). `Layout::offset` already addresses them that way: `row` and `column` shift the coordinate by the mip's tail position and apply the surface's pattern. The computer's output told a caller the opposite, so anything computing addresses from a mip's mode would use a pattern the data is not stored in. ## Impact None visible today, as far as we know: the title reads offsets 0x00, 0x08, 0x10 and 0x1c of each mip (see the comment on `MipOut`), not the mode. This makes the layout agree with the addresses the same object gives. ## Tests - `layout_and_copies_through_the_object` now also checks that all 9 mips of a 256x256 BC7 texture in `SW_64KB_D` (8 of them in the tail) report mode 10. - `cargo test -p victory-hle --lib modules::xg`: 23 passed. - Clippy on `victory-hle`: nothing in the changed lines (the two existing warnings are in `shadow.rs` and `gameinput.rs`). Not run with the game.
A mip in the tail lives inside one block of the surface's own mode, and
Layout::offset addresses it with that mode's pattern. The texture
computer reported tail mips in a 256-byte mode (or 3 for the render
modes) instead, so a caller computing addresses from the mip's mode
would use a different pattern from the one the data is stored in.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:29:51 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 09:33 UTC · original · approved these changes

Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge in crates/victory-hle/src/modules/xg.rs; cargo xtask policy passed (294 files ok).
  • Tests:
    • cargo test -p victory-hle --lib xg:: passed (4 passed; 0 failed).
    • cargo test -p victory-formats --lib texture:: passed (22 passed; 0 failed).
  • Compiled with 0 warnings.

Consistent swizzle-mode reporting for tail mips matching actual addressing. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-28 09:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/902#pullrequestreview-6096994988) · **approved these changes** Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge in `crates/victory-hle/src/modules/xg.rs`; `cargo xtask policy` passed (`294 files ok`). - **Tests**: - `cargo test -p victory-hle --lib xg::` passed (`4 passed; 0 failed`). - `cargo test -p victory-formats --lib texture::` passed (`22 passed; 0 failed`). - Compiled with 0 warnings. Consistent swizzle-mode reporting for tail mips matching actual addressing. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot referenced this pull request from a commit 2026-11-28 19:41:56 +00:00
github manually merged commit 24848b85bf into main 2026-11-28 19:42:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!902
No description provided.