Formats: reject texture mip counts beyond the full chain #1791

Open
VlREX wants to merge 2 commits from upstream-pr/1792 into main
VlREX commented 2026-11-24 22:40:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-24T22:40:06Z.


No description provided.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6592844645 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1792). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-24T22:40:06Z. --- _No description provided._
dcastell1 commented 2026-11-24 23:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T22:41:37Z.


Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace
343 passed; 0 failed; 6 ignored   (exit 0)

One more passing test than the baseline; rejecting mip counts beyond the full pyramid is exercised and green.

Tree restored afterwards; no game data. AI-assisted (opencode).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146533170 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1792#issuecomment-7146533170). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T22:41:37Z. --- Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace 343 passed; 0 failed; 6 ignored (exit 0) ``` One more passing test than the baseline; rejecting mip counts beyond the full pyramid is exercised and green. Tree restored afterwards; no game data. AI-assisted (opencode).
catminou4 commented 2026-11-25 00:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:05:46Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae).

cargo test -p victory-formats --locked → 24 passed, 0 failed. texture_mip_count_is_bounded_by_spatial_extent rejects mip counts beyond the full chain — clean validation fix.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048825611 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1792#pullrequestreview-6048825611). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:05:46Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae). cargo test -p victory-formats --locked → 24 passed, 0 failed. texture_mip_count_is_bounded_by_spatial_extent rejects mip counts beyond the full chain — clean validation fix.
Marvisak commented 2026-11-25 07:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:23:41Z.


Automated triage for the maintainers.

Needs work: evidence needed. Texture::new in crates/victory-formats/src/texture.rs returns Error::Invalid when mips is larger than the full chain. On main it lays out the extra 1×1 levels instead. This is shared layout code: victory-hle's xg.rs (the layout the title asks the console library for) and victory-gpu's resource.rs both call it. So for such a description the XG call would now fail where it used to return a layout.

Since the last review, a second commit (ea9ada0) adds a test for a 7×5 BC7 chain and for oversized counts up to u32::MAX. The test is correct: it gives 3 levels, and the cap uses the texel extent, not the block extent. But a test does not answer the two open points:

  • Evidence of what the console library does with such a description: whether it refuses it or what it returns. Its observed behaviour, the title's own code, or public documentation would do. PC D3D12 refusing MipLevels beyond the chain is a hint, not the console's library.
  • A case where it matters. No title call or failure is named. If the title never passes such a count, this guards a case that does not occur.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154745055 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1792#issuecomment-7154745055). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:23:41Z. --- <!-- victory-triage v1 head=ea9ada0cad93d0dd37cb35e307d5fa24d1d0e971 verdict=needs-work at=2026-11-25T16:45:09Z --> Automated triage for the maintainers. **Needs work: evidence needed.** `Texture::new` in `crates/victory-formats/src/texture.rs` returns `Error::Invalid` when `mips` is larger than the full chain. On `main` it lays out the extra 1×1 levels instead. This is shared layout code: `victory-hle`'s `xg.rs` (the layout the title asks the console library for) and `victory-gpu`'s `resource.rs` both call it. So for such a description the XG call would now fail where it used to return a layout. Since the last review, a second commit (`ea9ada0`) adds a test for a 7×5 BC7 chain and for oversized counts up to `u32::MAX`. The test is correct: it gives 3 levels, and the cap uses the texel extent, not the block extent. But a test does not answer the two open points: - **Evidence** of what the console library does with such a description: whether it refuses it or what it returns. Its observed behaviour, the title's own code, or public documentation would do. PC D3D12 refusing `MipLevels` beyond the chain is a hint, not the console's library. - **A case where it matters.** No title call or failure is named. If the title never passes such a count, this guards a case that does not occur. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1792:upstream-pr/1792'
git switch 'upstream-pr/1792'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1792'
git switch 'upstream-pr/1792'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1792'
git switch 'upstream-pr/1792'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1792'
git switch 'main'
git merge --squash 'upstream-pr/1792'
git switch 'main'
git merge --ff-only 'upstream-pr/1792'
git switch 'main'
git merge 'upstream-pr/1792'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1791
No description provided.