XG: preserve packed mip positions and correct array subresource tiling #2400

Open
opened 2026-11-26 05:04:42 +00:00 by github-bot · 2 comments
Owner

@⁠FunWithFlagsDev on GitHub · 2026-11-25 12:52 UTC · original

<html>

Summary

While comparing upstream VIctory with the AnyXboxX fork, I identified two XG texture-layout corrections already implemented by @⁠LooperSalty that appear to be missing from upstream main (940d32f).

I suggest bringing these focused corrections upstream, preserving their original authorship and extending their regression coverage.

1. Packed mip-tail metadata

The upstream mip_out() implementation:

  • Substitutes the original swizzle mode with a smaller-block mode for packed mips.

  • Reports tail_position only for thick layouts.

The AnyXboxX implementation instead preserves the parent texture's swizzle mode and reports the packed mip's position for both 2D and 3D layouts.

Source comparison:

2. Array subresource tiling

The upstream implementation indexes array subresources using the number of standard mips rather than the total number of mips. It also limits arrays with packed mips to two slices and zeroes entries belonging to subsequent slices.

The AnyXboxX implementation preserves the complete subresource index space, zeroes packed mip entries, and counts standard mip entries without losing their original positions.

Minimal regression case, adapted from the existing fork test:

  • Array slices: 3

  • Mips per slice: 7

  • Standard mips per slice: 2

  • First subresource: 0

  • Requested entries: 8

Implementation | Returned count | Valid output indices -- | -- | -- Upstream | 4 | 0, 1 AnyXboxX | 3 | 0, 1, 7

All six regression tests passed.

These results describe synthetic indexing states, not the frequency of incorrect texture layouts during gameplay.

4. Additional regression coverage

The AnyXboxX fork reports comparisons against Microsoft's original XG library for 54 texture descriptions.

During my review, I noticed that the comparison helpers truncate their output vectors to the returned standard-mip count. This can omit valid entries located beyond that prefix.

For the example above, a three-entry comparison does not validate the standard mip at output index 7.

The fork already checks this position in a separate synthetic test. However, I suggest strengthening the native comparison by:

  • Comparing the entire written output window.

  • Initializing outputs with sentinel values.

  • Checking untouched entries.

  • Testing nonzero first-subresource indices across array boundaries.

  • Including arrays with more than two slices.

  • Including XOR swizzle modes in future coverage.

Existing fork tests

Proposed action

Integrate the two focused XG corrections from AnyXboxX without modifying the underlying texture allocation geometry.

These changes may improve texture-layout compatibility, particularly for arrays and packed mip chains. Their isolated gameplay impact remains unmeasured.

Attachment

xg_tiling_audit.zip contains:

  • Technical source audit.

  • Six executable Python regression tests.

  • Recorded results.

  • Recommendations for stronger native regression coverage.

Credits and limitations

Full credit to @⁠LooperSalty and the AnyXboxX contributors for the existing corrections and reported native library comparisons.

My contribution is the independent source review, synthetic verification and identification of the regression-coverage limitation.

I have not independently executed Microsoft's XG library, compiled the Rust changes, or tested them on a GPU.

No game files, proprietary assets or SDK binaries were used.

AI-assisted source audit and synthetic verification.

</html>## Summary

While comparing upstream VIctory with the AnyXboxX fork, I identified two XG texture-layout corrections already implemented by @⁠LooperSalty that appear to be missing from upstream main (940d32f).

I suggest bringing these focused corrections upstream, preserving their original authorship and extending their regression coverage.

1. Packed mip-tail metadata

The upstream mip_out() implementation:

  • Substitutes the original swizzle mode with a smaller-block mode for packed mips.
  • Reports tail_position only for thick layouts.

The AnyXboxX implementation instead preserves the parent texture's swizzle mode and reports the packed mip's position for both 2D and 3D layouts.

Source comparison:

2. Array subresource tiling

The upstream implementation indexes array subresources using the number of standard mips rather than the total number of mips. It also limits arrays with packed mips to two slices and zeroes entries belonging to subsequent slices.

The AnyXboxX implementation preserves the complete subresource index space, zeroes packed mip entries, and counts standard mip entries without losing their original positions.

Minimal regression case, adapted from the existing fork test:

  • Array slices: 3
  • Mips per slice: 7
  • Standard mips per slice: 2
  • First subresource: 0
  • Requested entries: 8
Implementation Returned count Valid output indices
Upstream 4 0, 1
AnyXboxX 3 0, 1, 7

Source comparison:

3. Independent synthetic verification

I reproduced both indexing algorithms in Python and compared them against a flattened subresource reference model based on the fork's implementation.

Implementation Divergences across 155,232 abstract cases
Upstream 92,960
AnyXboxX 0

All six regression tests passed.

These results describe synthetic indexing states, not the frequency of incorrect texture layouts during gameplay.

4. Additional regression coverage

The AnyXboxX fork reports comparisons against Microsoft's original XG library for 54 texture descriptions.

During my review, I noticed that the comparison helpers truncate their output vectors to the returned standard-mip count. This can omit valid entries located beyond that prefix.

For the example above, a three-entry comparison does not validate the standard mip at output index 7.

The fork already checks this position in a separate synthetic test. However, I suggest strengthening the native comparison by:

  • Comparing the entire written output window.
  • Initializing outputs with sentinel values.
  • Checking untouched entries.
  • Testing nonzero first-subresource indices across array boundaries.
  • Including arrays with more than two slices.
  • Including XOR swizzle modes in future coverage.

[Existing fork tests](github.com/LooperSalty/victory@80d58f8/crates/victory-hle/src/modules/xg.rs (L950-L1100))

Proposed action

Integrate the two focused XG corrections from AnyXboxX without modifying the underlying texture allocation geometry.

These changes may improve texture-layout compatibility, particularly for arrays and packed mip chains. Their isolated gameplay impact remains unmeasured.

Attachment

xg_tiling_audit.zip contains:

  • Technical source audit.
  • Six executable Python regression tests.
  • Recorded results.
  • Recommendations for stronger native regression coverage.

Credits and limitations

Full credit to @⁠LooperSalty and the AnyXboxX contributors for the existing corrections and reported native library comparisons.

My contribution is the independent source review, synthetic verification and identification of the regression-coverage limitation.

I have not independently executed Microsoft's XG library, compiled the Rust changes, or tested them on a GPU.

No game files, proprietary assets or SDK binaries were used.

AI-assisted source audit and synthetic verification.

xg_tiling_audit.zip

**@⁠FunWithFlagsDev** on GitHub · 2026-11-25 12:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/2400) <html> <body> <!--StartFragment--><h2><span>Summary</span></h2><p><span>While comparing upstream VIctory with the AnyXboxX fork, I identified two XG texture-layout corrections already implemented by @⁠LooperSalty that appear to be missing from upstream </span><code><span>main</span></code><span> (</span><code><span>940d32f</span></code><span>).</span></p><p><span>I suggest bringing these focused corrections upstream, preserving their original authorship and extending their regression coverage.</span></p><h2><span>1. Packed mip-tail metadata</span></h2><p><span>The upstream </span><code><span>mip_out()</span></code><span> implementation:</span></p><ul><li><p><span>Substitutes the original swizzle mode with a smaller-block mode for packed mips.</span></p></li><li><p><span>Reports </span><code><span>tail_position</span></code><span> only for thick layouts.</span></p></li></ul><p><span>The AnyXboxX implementation instead preserves the parent texture's swizzle mode and reports the packed mip's position for both 2D and 3D layouts.</span></p><p><span>Source comparison:</span></p><ul><li><p><a href="https://github.com/Marvisak/VIctory/blob/940d32f/crates/victory-hle/src/modules/xg.rs#L233-L277"><span>Upstream mip_out</span></a></p></li><li><p><a href="https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L268-L312"><span>AnyXboxX mip_out</span></a></p></li></ul><h2><span>2. Array subresource tiling</span></h2><p><span>The upstream implementation indexes array subresources using the number of standard mips rather than the total number of mips. It also limits arrays with packed mips to two slices and zeroes entries belonging to subsequent slices.</span></p><p><span>The AnyXboxX implementation preserves the complete subresource index space, zeroes packed mip entries, and counts standard mip entries without losing their original positions.</span></p><p><span>Minimal regression case, adapted from the existing fork test:</span></p><ul><li><p><span>Array slices: 3</span></p></li><li><p><span>Mips per slice: 7</span></p></li><li><p><span>Standard mips per slice: 2</span></p></li><li><p><span>First subresource: 0</span></p></li><li><p><span>Requested entries: 8</span></p></li></ul> Implementation | Returned count | Valid output indices -- | -- | -- Upstream | 4 | 0, 1 AnyXboxX | 3 | 0, 1, 7 <p><span>All six regression tests passed.</span></p><p><span>These results describe synthetic indexing states, not the frequency of incorrect texture layouts during gameplay.</span></p><h2><span>4. Additional regression coverage</span></h2><p><span>The AnyXboxX fork reports comparisons against Microsoft's original XG library for 54 texture descriptions.</span></p><p><span>During my review, I noticed that the comparison helpers truncate their output vectors to the returned standard-mip count. This can omit valid entries located beyond that prefix.</span></p><p><span>For the example above, a three-entry comparison does not validate the standard mip at output index 7.</span></p><p><span>The fork already checks this position in a separate synthetic test. However, I suggest strengthening the native comparison by:</span></p><ul><li><p><span>Comparing the entire written output window.</span></p></li><li><p><span>Initializing outputs with sentinel values.</span></p></li><li><p><span>Checking untouched entries.</span></p></li><li><p><span>Testing nonzero first-subresource indices across array boundaries.</span></p></li><li><p><span>Including arrays with more than two slices.</span></p></li><li><p><span>Including XOR swizzle modes in future coverage.</span></p></li></ul><p><a href="https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L950-L1100"><span>Existing fork tests</span></a></p><h2><span>Proposed action</span></h2><p><span>Integrate the two focused XG corrections from AnyXboxX without modifying the underlying texture allocation geometry.</span></p><p><span>These changes may improve texture-layout compatibility, particularly for arrays and packed mip chains. Their isolated gameplay impact remains unmeasured.</span></p><h2><span>Attachment</span></h2><p><code><span>xg_tiling_audit.zip</span></code><span> contains:</span></p><ul><li><p><span>Technical source audit.</span></p></li><li><p><span>Six executable Python regression tests.</span></p></li><li><p><span>Recorded results.</span></p></li><li><p><span>Recommendations for stronger native regression coverage.</span></p></li></ul><h2><span>Credits and limitations</span></h2><p><span>Full credit to @⁠LooperSalty and the AnyXboxX contributors for the existing corrections and reported native library comparisons.</span></p><p><span>My contribution is the independent source review, synthetic verification and identification of the regression-coverage limitation.</span></p><p><span>I have not independently executed Microsoft's XG library, compiled the Rust changes, or tested them on a GPU.</span></p><p><span>No game files, proprietary assets or SDK binaries were used.</span></p><p><span>AI-assisted source audit and synthetic verification.</span></p><!--EndFragment--> </body> </html>## Summary While comparing upstream VIctory with the AnyXboxX fork, I identified two XG texture-layout corrections already implemented by @⁠LooperSalty that appear to be missing from upstream `main` (`940d32f`). I suggest bringing these focused corrections upstream, preserving their original authorship and extending their regression coverage. ## 1. Packed mip-tail metadata The upstream `mip_out()` implementation: - Substitutes the original swizzle mode with a smaller-block mode for packed mips. - Reports `tail_position` only for thick layouts. The AnyXboxX implementation instead preserves the parent texture's swizzle mode and reports the packed mip's position for both 2D and 3D layouts. Source comparison: - [[Upstream mip_out](https://github.com/Marvisak/VIctory/blob/940d32f/crates/victory-hle/src/modules/xg.rs#L233-L277)](https://github.com/Marvisak/VIctory/blob/940d32f/crates/victory-hle/src/modules/xg.rs#L233-L277) - [[AnyXboxX mip_out](https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L268-L312)](https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L268-L312) ## 2. Array subresource tiling The upstream implementation indexes array subresources using the number of standard mips rather than the total number of mips. It also limits arrays with packed mips to two slices and zeroes entries belonging to subsequent slices. The AnyXboxX implementation preserves the complete subresource index space, zeroes packed mip entries, and counts standard mip entries without losing their original positions. Minimal regression case, adapted from the existing fork test: - Array slices: 3 - Mips per slice: 7 - Standard mips per slice: 2 - First subresource: 0 - Requested entries: 8 | Implementation | Returned count | Valid output indices | |---|---:|---| | Upstream | 4 | 0, 1 | | AnyXboxX | 3 | 0, 1, 7 | Source comparison: - [[Upstream tiling](https://github.com/Marvisak/VIctory/blob/940d32f/crates/victory-hle/src/modules/xg.rs#L470-L542)](https://github.com/Marvisak/VIctory/blob/940d32f/crates/victory-hle/src/modules/xg.rs#L470-L542) - [[AnyXboxX tiling](https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L562-L634)](https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L562-L634) ## 3. Independent synthetic verification I reproduced both indexing algorithms in Python and compared them against a flattened subresource reference model based on the fork's implementation. | Implementation | Divergences across 155,232 abstract cases | |---|---:| | Upstream | 92,960 | | AnyXboxX | 0 | All six regression tests passed. These results describe synthetic indexing states, not the frequency of incorrect texture layouts during gameplay. ## 4. Additional regression coverage The AnyXboxX fork reports comparisons against Microsoft's original XG library for 54 texture descriptions. During my review, I noticed that the comparison helpers truncate their output vectors to the returned standard-mip count. This can omit valid entries located beyond that prefix. For the example above, a three-entry comparison does not validate the standard mip at output index 7. The fork already checks this position in a separate synthetic test. However, I suggest strengthening the native comparison by: - Comparing the entire written output window. - Initializing outputs with sentinel values. - Checking untouched entries. - Testing nonzero first-subresource indices across array boundaries. - Including arrays with more than two slices. - Including XOR swizzle modes in future coverage. [[Existing fork tests](https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L950-L1100)](https://github.com/LooperSalty/victory/blob/80d58f8/crates/victory-hle/src/modules/xg.rs#L950-L1100) ## Proposed action Integrate the two focused XG corrections from AnyXboxX without modifying the underlying texture allocation geometry. These changes may improve texture-layout compatibility, particularly for arrays and packed mip chains. Their isolated gameplay impact remains unmeasured. ## Attachment `xg_tiling_audit.zip` contains: - Technical source audit. - Six executable Python regression tests. - Recorded results. - Recommendations for stronger native regression coverage. ## Credits and limitations Full credit to @⁠LooperSalty and the AnyXboxX contributors for the existing corrections and reported native library comparisons. My contribution is the independent source review, synthetic verification and identification of the regression-coverage limitation. I have not independently executed Microsoft's XG library, compiled the Rust changes, or tested them on a GPU. No game files, proprietary assets or SDK binaries were used. AI-assisted source audit and synthetic verification. [xg_tiling_audit.zip](https://github.com/user-attachments/files/35412201/xg_tiling_audit.zip)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:42 +00:00
Author
Owner

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

Claiming this issue — implementing the mip_out() packed-mip metadata fix and array subresource tiling fix in crates/victory-hle/src/modules/xg.rs along with the requested regression tests. Will open a PR shortly.

**@⁠pushkarreddyy** on GitHub · 2026-11-25 13:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/2400#issuecomment-7163153822) Claiming this issue — implementing the `mip_out()` packed-mip metadata fix and array subresource tiling fix in `crates/victory-hle/src/modules/xg.rs` along with the requested regression tests. Will open a PR shortly.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:02 UTC · original

Automated triage for the maintainers.

The description of main (da82e44) is accurate: mip_out in crates/victory-hle/src/modules/xg.rs reports a tail mip with tail_swizzle(...) rather than the parent's swizzle, and sets tail_position only for thick (3D) layouts. Reading the code cannot tell which behaviour the console's runtime has; the evidence offered is a fork's comparison, so a maintainer needs to judge it. Open PR #2404 carries both changes. Please do not post or link SDK binaries or reference output from them here.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 16:02 UTC · [original](https://github.com/Marvisak/VIctory/issues/2400#issuecomment-7167534582) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T13:00:13Z at=2026-11-25T16:01:57Z --> Automated triage for the maintainers. The description of main (da82e44) is accurate: `mip_out` in `crates/victory-hle/src/modules/xg.rs` reports a tail mip with `tail_swizzle(...)` rather than the parent's swizzle, and sets `tail_position` only for thick (3D) layouts. Reading the code cannot tell which behaviour the console's runtime has; the evidence offered is a fork's comparison, so a maintainer needs to judge it. Open PR #2404 carries both changes. Please do not post or link SDK binaries or reference output from them here. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#2400
No description provided.