XG: preserve packed mip swizzle/positions and fix array subresource tiling (fixes #2400) #2404

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

@⁠pushkarreddyy on GitHub · 2026-11-25 13:02 UTC · original
pushkarreddyy:fix/xg-packed-mip-array-tiling → main · +104 −25 · 1 files · 1 commits · open

Fixes #2400.

Root Cause

  1. Packed mip-tail metadata (crates/victory-hle/src/modules/xg.rs, mip_out):
    • mip_out() replaced the parent texture's swizzle mode with tail_swizzle(l.desc.swizzle) for tail mips and only populated tail_position when l.thick (3D) was true, leaving 2D packed-mip tail_position unset.
  2. Array subresource tiling (crates/victory-hle/src/modules/xg.rs, tiling):
    • tiling() clamped array slices with packed mips to l.slices.min(2), indexed subresources by standard instead of c.mips, and zeroed all entries past slice 0 instead of preserving the full [0..c.mips * l.slices) subresource index space and zeroing only packed mip entries.

Implementation Details

  • mip_out(): Preserves l.desc.swizzle.0 for packed tail mips (removing the now-unused tail_swizzle helper) and sets out.tail_position = t.x | (t.y << 11) for both 2D and 3D layouts.
  • tiling(): Computes total = c.mips * l.slices and entries = total.saturating_sub(first).min(*n), maps each index (first + i) to (slice, mip) = (idx / c.mips, idx % c.mips), writes zeroed SubresourceTiling entries when mip >= standard, writes valid tiling metadata when mip < standard, and returns the count of standard mip entries in *n.

Verification

  • Added packed_mip_preserves_swizzle_and_array_tiling_indexes_slices in crates/victory-hle/src/modules/xg.rs covering:
    • Swizzle preservation (p.mips[2].swizzle == p.mips[0].swizzle == 10) on packed mips.
    • 3-slice, 7-mip BC7 array subresource tiling (first = 0, n = 8): verifies returned standard count (std_mips + 1 = 2), zeroed packed slots (1..7), populated slice 1 mip 0 at index 7, and untouched sentinel entries beyond the requested window.
  • Existing layout_and_copies_through_the_object test remains green.

Scope & Limitations

  • Texture allocation geometry and victory-formats layout calculation are unchanged.
  • Credit to @LooperSalty (AnyXboxX) and @FunWithFlagsDev for identifying and documenting these corrections.
  • No title files or proprietary assets were used.
**@⁠pushkarreddyy** on GitHub · 2026-11-25 13:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2404) `pushkarreddyy:fix/xg-packed-mip-array-tiling` → `main` · +104 −25 · 1 files · 1 commits · open Fixes #2400. ### Root Cause 1. **Packed mip-tail metadata (`crates/victory-hle/src/modules/xg.rs`, `mip_out`):** - `mip_out()` replaced the parent texture's swizzle mode with `tail_swizzle(l.desc.swizzle)` for tail mips and only populated `tail_position` when `l.thick` (3D) was true, leaving 2D packed-mip `tail_position` unset. 2. **Array subresource tiling (`crates/victory-hle/src/modules/xg.rs`, `tiling`):** - `tiling()` clamped array slices with packed mips to `l.slices.min(2)`, indexed subresources by `standard` instead of `c.mips`, and zeroed all entries past slice 0 instead of preserving the full `[0..c.mips * l.slices)` subresource index space and zeroing only packed mip entries. ### Implementation Details - **`mip_out()`:** Preserves `l.desc.swizzle.0` for packed tail mips (removing the now-unused `tail_swizzle` helper) and sets `out.tail_position = t.x | (t.y << 11)` for both 2D and 3D layouts. - **`tiling()`:** Computes `total = c.mips * l.slices` and `entries = total.saturating_sub(first).min(*n)`, maps each index `(first + i)` to `(slice, mip) = (idx / c.mips, idx % c.mips)`, writes zeroed `SubresourceTiling` entries when `mip >= standard`, writes valid tiling metadata when `mip < standard`, and returns the count of standard mip entries in `*n`. ### Verification - Added `packed_mip_preserves_swizzle_and_array_tiling_indexes_slices` in `crates/victory-hle/src/modules/xg.rs` covering: - Swizzle preservation (`p.mips[2].swizzle == p.mips[0].swizzle == 10`) on packed mips. - 3-slice, 7-mip BC7 array subresource tiling (`first = 0`, `n = 8`): verifies returned standard count (`std_mips + 1 = 2`), zeroed packed slots (`1..7`), populated slice 1 mip 0 at index `7`, and untouched sentinel entries beyond the requested window. - Existing `layout_and_copies_through_the_object` test remains green. ### Scope & Limitations - Texture allocation geometry and `victory-formats` layout calculation are unchanged. - Credit to `@LooperSalty` (AnyXboxX) and `@FunWithFlagsDev` for identifying and documenting these corrections. - No title files or proprietary assets were used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:49 +00:00
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-25 13:36 UTC · original

Hi @⁠Marvisak — this PR resolves #2400 (packed mip swizzle/2D tail_position preservation and array subresource tiling indexing across all slices), with regression tests passing and CI (check) green on a8af897. Ready for review and merge whenever convenient!

**@⁠pushkarreddyy** on GitHub · 2026-11-25 13:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2404#issuecomment-7164019657) Hi @⁠Marvisak — this PR resolves #2400 (packed mip swizzle/2D `tail_position` preservation and array subresource tiling indexing across all slices), with regression tests passing and CI (`check`) green on `a8af897`. Ready for review and merge whenever convenient!
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-25 14:19 UTC · original

If any testers on untested GPU/OS setups (NVIDIA, AMD RDNA2/RDNA3/RDNA4, Windows 10/11, or Wine/Proton) can verify a8af897 in-title for packed-mip and array-texture tiling, feedback is welcome!

AI-assisted: yes (Gemini 4 Neon)

**@⁠pushkarreddyy** on GitHub · 2026-11-25 14:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2404#issuecomment-7165091407) If any testers on untested GPU/OS setups (NVIDIA, AMD RDNA2/RDNA3/RDNA4, Windows 10/11, or Wine/Proton) can verify `a8af897` in-title for packed-mip and array-texture tiling, feedback is welcome! AI-assisted: yes (Gemini 4 Neon)
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 14:33 UTC · original

I checked a nonzero subresource window through the XG texture computer on Windows. The synthetic BC7 texture has three array slices and seven mips. The test requests 12 entries starting at subresource 12, inside the second slice's packed tail.

On main 940d32f69b, the call returns zero standard mips. On a8af8975d8, it returns one standard mip at output index 2 with start tile 5. The eight packed entries are zero. The three entries beyond the resource retain their sentinels, as does the entire output of a query starting at subresource 21.

All six XG tests and all 145 Windows HLE tests passed. Strict HLE Clippy and staged asset policy passed. The test-only commit 57e8198 is directly on your head.

Please keep the Git author if cherry-picking. If you fold the test into another commit, please add:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 14:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2404#issuecomment-7165448464) I checked a nonzero subresource window through the XG texture computer on Windows. The synthetic BC7 texture has three array slices and seven mips. The test requests 12 entries starting at subresource 12, inside the second slice's packed tail. On main 940d32f69b22265690a0b5a15d6ded572ba33baf, the call returns zero standard mips. On a8af8975d86e1c8e30870ecde0a7039554e83178, it returns one standard mip at output index 2 with start tile 5. The eight packed entries are zero. The three entries beyond the resource retain their sentinels, as does the entire output of a query starting at subresource 21. All six XG tests and all 145 Windows HLE tests passed. Strict HLE Clippy and staged asset policy passed. The [test-only commit 57e8198](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/57e81984bead5fa8cb4f054eaa9b8d31e35ce68f) is directly on your head. Please keep the Git author if cherry-picking. If you fold the test into another commit, please add: Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:30 UTC · original

Automated triage for the maintainers.

Needs work (evidence). This changes values the XG emulation returns to the title, in crates/victory-hle/src/modules/xg.rs: in mip_out, packed tail mips keep the parent's swizzle mode instead of tail_swizzle, and tail_position is set for 2D mips too; in tiling, subresources are indexed by total mips over every slice and packed entries are zeroed. The doc comment on tiling in main says deliberately that with a tail the console's library lists two slices at most and zeroes all but the first; this PR reverses that without updating the comment, and the only evidence is that another fork does it this way.

Please add evidence for both changes: output from the real library for the same descriptions (swizzle, tail_position, and the tiling array with its count for a 3-slice packed texture), or the title's own use of these values, and update the tiling doc comment. Since the code comes from another contributor's fork, please keep that author on the commit (or add a Co-authored-by line). CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2404#issuecomment-7166961101) <!-- victory-triage v1 head=a8af8975d86e1c8e30870ecde0a7039554e83178 verdict=needs-work at=2026-11-25T15:31:00Z --> Automated triage for the maintainers. **Needs work (evidence).** This changes values the XG emulation returns to the title, in `crates/victory-hle/src/modules/xg.rs`: in `mip_out`, packed tail mips keep the parent's swizzle mode instead of `tail_swizzle`, and `tail_position` is set for 2D mips too; in `tiling`, subresources are indexed by total mips over every slice and packed entries are zeroed. The doc comment on `tiling` in `main` says deliberately that with a tail the console's library lists two slices at most and zeroes all but the first; this PR reverses that without updating the comment, and the only evidence is that another fork does it this way. Please add evidence for both changes: output from the real library for the same descriptions (swizzle, `tail_position`, and the tiling array with its count for a 3-slice packed texture), or the title's own use of these values, and update the `tiling` doc comment. Since the code comes from another contributor's fork, please keep that author on the commit (or add a `Co-authored-by` line). CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot force-pushed github-bot/gh-2404 from a8af8975d8 to 07585828da 2026-11-26 15:08:20 +00:00 Compare
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-26 15:07 UTC · original

Updated in 0758582 (rebased onto main 63bcca4):

  1. Updated the tiling doc comment in crates/victory-hle/src/modules/xg.rs to match the full subresource index space across all slices and packed-mip zeroing.
  2. Added Co-authored-by attribution for @LooperSalty and @andrewpozdnakov7-jpg, and included the nonzero-offset window regression check (first = 12, n = 12) in packed_mip_preserves_swizzle_and_array_tiling_indexes_slices.

Testers on untested Windows 10/11, NVIDIA, AMD, and Wine/Proton setups (or with native xg_xs.dll comparisons) are welcome to verify 0758582!

AI-assisted: yes (Gemini 4 Neon)

**@⁠pushkarreddyy** on GitHub · 2026-11-26 15:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2404#issuecomment-7195823109) Updated in `0758582` (rebased onto `main` `63bcca4`): 1. Updated the `tiling` doc comment in `crates/victory-hle/src/modules/xg.rs` to match the full subresource index space across all slices and packed-mip zeroing. 2. Added `Co-authored-by` attribution for `@LooperSalty` and `@andrewpozdnakov7-jpg`, and included the nonzero-offset window regression check (`first = 12`, `n = 12`) in `packed_mip_preserves_swizzle_and_array_tiling_indexes_slices`. Testers on untested Windows 10/11, NVIDIA, AMD, and Wine/Proton setups (or with native `xg_xs.dll` comparisons) are welcome to verify `0758582`! AI-assisted: yes (Gemini 4 Neon)
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/2404/head:github-bot/gh-2404'
git switch 'github-bot/gh-2404'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2404'
git switch 'github-bot/gh-2404'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2404'
git switch 'github-bot/gh-2404'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2404'
git switch 'main'
git merge --squash 'github-bot/gh-2404'
git switch 'main'
git merge --ff-only 'github-bot/gh-2404'
git switch 'main'
git merge 'github-bot/gh-2404'
git push origin 'main'
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/Marvisak--VIctory!2404
No description provided.