XG: preserve packed mip positions and correct array subresource tiling #2400
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#2400
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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_positiononly 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
AnyXboxX mip_out
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:
Implementation | Returned count | Valid output indices -- | -- | -- Upstream | 4 | 0, 1 AnyXboxX | 3 | 0, 1, 7Array slices: 3
Mips per slice: 7
Standard mips per slice: 2
First subresource: 0
Requested entries: 8
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.zipcontains: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>## SummaryWhile 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:tail_positiononly 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:
github.com/Marvisak/VIctory@940d32f/crates/victory-hle/src/modules/xg.rs (L233-L277))github.com/LooperSalty/victory@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:
Source comparison:
github.com/Marvisak/VIctory@940d32f/crates/victory-hle/src/modules/xg.rs (L470-L542))github.com/LooperSalty/victory@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.
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:
[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.zipcontains: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
@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 incrates/victory-hle/src/modules/xg.rsalong with the requested regression tests. Will open a PR shortly.@Marvisak on GitHub · 2026-11-25 16:02 UTC · original
Automated triage for the maintainers.
The description of main (
da82e44) is accurate:mip_outincrates/victory-hle/src/modules/xg.rsreports a tail mip withtail_swizzle(...)rather than the parent's swizzle, and setstail_positiononly 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