XG: preserve packed mip swizzle/positions and fix array subresource tiling (fixes #2400) #2402
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2404"
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?
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-25T13:02:57Z.
Fixes #2400.
Root Cause
crates/victory-hle/src/modules/xg.rs,mip_out):mip_out()replaced the parent texture's swizzle mode withtail_swizzle(l.desc.swizzle)for tail mips and only populatedtail_positionwhenl.thick(3D) was true, leaving 2D packed-miptail_positionunset.crates/victory-hle/src/modules/xg.rs,tiling):tiling()clamped array slices with packed mips tol.slices.min(2), indexed subresources bystandardinstead ofc.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(): Preservesl.desc.swizzle.0for packed tail mips (removing the now-unusedtail_swizzlehelper) and setsout.tail_position = t.x | (t.y << 11)for both 2D and 3D layouts.tiling(): Computestotal = c.mips * l.slicesandentries = total.saturating_sub(first).min(*n), maps each index(first + i)to(slice, mip) = (idx / c.mips, idx % c.mips), writes zeroedSubresourceTilingentries whenmip >= standard, writes valid tiling metadata whenmip < standard, and returns the count of standard mip entries in*n.Verification
packed_mip_preserves_swizzle_and_array_tiling_indexes_slicesincrates/victory-hle/src/modules/xg.rscovering:p.mips[2].swizzle == p.mips[0].swizzle == 10) on packed mips.first = 0,n = 8): verifies returned standard count (std_mips + 1 = 2), zeroed packed slots (1..7), populated slice 1 mip 0 at index7, and untouched sentinel entries beyond the requested window.layout_and_copies_through_the_objecttest remains green.Scope & Limitations
victory-formatslayout calculation are unchanged.@LooperSalty(AnyXboxX) and@FunWithFlagsDevfor identifying and documenting these corrections.Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T13:09:43Z.
Review: CHANGES_REQUESTED
The new regression fails on native Windows at
2025d13:p.mips[2].swizzlereturns0x0a, but the test expects0x10a. The parser strips the0x100layout marker, andmip_out()now returns the resulting swizzle ID. The assertion should expect0x0a.With that test-only correction, all six XG tests passed, including an extra probe for the window requested in #2400. I used a three-slice 512×512 BC7 texture with seven mips per slice and requested ten entries starting at subresource 6. Both layouts (
0x10aand XOR0x11a) returned a standard-mip count of 4, populated output slots 1, 2, 8, and 9, zeroed the packed slots, and preserved both sentinels beyond the requested window.Synthetic VIctory test only. No comparison against Microsoft's XG runtime.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by AndyLatimer on 2026-11-25T13:11:25Z.
Review: COMMENTED
Same test failure here (Windows 11,
2025d13), as @DrDarkDK says. Two more things, from a probe oftilingonmain(940d32f) and on this PR with the test's texture (256x256 BC7, 3 slices, 7 mips,0x10a). That texture has 1 standard mip, not 2: mips 1 to 6 are in the tail, so the test's comment is off too.first, roommain:n, entriesn, entries[0]slice 0 mip 0,[1]zero[0]slice 0 mip 0,[1..7]zero,[7]slice 1 mip 0[0]slice 1 mip 0,[7]slice 2 mip 0[0],[7],[14], the other 18 zero1. The count no longer describes what was written.
*nis now the number of standard entries in the window, while the entries are written over the whole window. With 21 asked,nis 3 but the standard entries are at 0, 7 and 14, so a caller that readsnentries gets two zeroed ones and misses two. D3D12'sGetResourceTiling, which has the same arguments, defines the count on output as the number of entries retrieved (the room, clamped to what is left), and marks packed ones withD3D12_PACKED_TILEin the start tile rather than 0. Whichever XG does, the count and the window should agree.2. Nothing here shows XG behaves this way, and
mainsays it doesn't.tiling's doc onmain, left as is by this PR and now contradicting it, reads: "With a tail the console's library lists two slices at most and zeroes all but the first; so do we (the title reads slice 0 only)."tail_swizzle's doc says the same of the mode a tail mip reports: "the 256-byte one of its kind (3 for the render kind, which GFX10 lacks)". Reporting a mode the hardware lacks looks observed, not derived. The evidence in #2400 is the fork's comparison with Microsoft's library, which #2400 itself says only covers entries up to the returned count. In the first row above,mainand this PR return the same count and the same entries up to it, so such a comparison cannot tell them apart. Everything this PR changes intilingis past the count.On the swizzle half: reporting the parent mode with the tail position is how
victory-formatsaddresses a tail mip itself (the parent's pattern at the shifted position,Layout::rowandcolumn). So it is consistent with our detiler. Whether XG reports it that way is the open question.I'd keep
main'stilinguntil a comparison with the real library checks the whole window with sentinels, as #2400 suggests, or at least make*nmatch the entries written. If the swizzle change stays, it would need its own evidence and an update to the doc thatmainhad.Probe only; no comparison against Microsoft's XG.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T13:19:26Z.
Review: COMMENTED
XG: packed mip swizzle/positions preserved, array fixed. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-25T13:36:17Z.
Hi @Marvisak — this PR resolves #2400 (packed mip swizzle/2D
tail_positionpreservation and array subresource tiling indexing across all slices), with regression tests passing and CI (check) green ona8af897. Ready for review and merge whenever convenient!Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-25T14:19:06Z.
If any testers on untested GPU/OS setups (NVIDIA, AMD RDNA2/RDNA3/RDNA4, Windows 10/11, or Wine/Proton) can verify
a8af897in-title for packed-mip and array-texture tiling, feedback is welcome!AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T14:33:00Z.
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. Ona8af8975d8, 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]
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:30:54Z.
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: inmip_out, packed tail mips keep the parent's swizzle mode instead oftail_swizzle, andtail_positionis set for 2D mips too; intiling, subresources are indexed by total mips over every slice and packed entries are zeroed. The doc comment ontilinginmainsays 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 thetilingdoc comment. Since the code comes from another contributor's fork, please keep that author on the commit (or add aCo-authored-byline). CI: passing.Generated by Claude Code
upstream-sync referenced this pull request2026-11-25 16:09:36 +00:00
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-26T15:07:43Z.
Updated in
0758582(rebased ontomain63bcca4):tilingdoc comment incrates/victory-hle/src/modules/xg.rsto match the full subresource index space across all slices and packed-mip zeroing.Co-authored-byattribution for@LooperSaltyand@andrewpozdnakov7-jpg, and included the nonzero-offset window regression check (first = 12,n = 12) inpacked_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.dllcomparisons) are welcome to verify0758582!AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T06:55:29Z.
Independent CPU-only verification of PR #2404 (
XG packed mip swizzle/array tiling).CARGO_TARGET_DIR(D:\Victory-Contrib\target-2404-watch),CARGO_BUILD_JOBS=2.07585828dae98e600b46df5ac65f7998a2fc77ee, merge base63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-hle --lib -- modules::xg::tests::packed_mip_preserves_swizzle_and_array_tiling_indexes_slices --exact --test-threads=1 --quiet->1 passed; 0 failed; 152 filtered.git grep -Ffor the new test name on63bcca4returned no hits (test absent on base).git diff --check 63bcca4 HEADexit 0 (clean).Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-27T08:10:28Z.
@cloph-dsp Thank you for the independent CPU-only verification on
0758582(1 passed; 0 failed)!@DrDarkDK Feel free to re-review
0758582if you have a chance, and @Marvisak please review and merge this PR when convenient (CI is green). Testers on untested GPU models and setups are welcome to test real packed mip and array subresource tiling paths.AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-27T10:19:34Z.
Thanks for the re-review invite. I checked
0758582: the swizzle assertion now expects0x0a, and the nonzero array window is covered.The regression would still pass if the new 2D
tail_positionassignment were removed. For mip 2 in this fixture, VIctory’s layout puts the tail at(x=0, y=32). Could you addassert_eq!(p.mips[2].tail_position, 0x1_0000)? That checks that VIctory passes the computed coordinates through the XG interface. Native XG compatibility still needs separate evidence.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-28T07:33:57Z.
@DrDarkDK Added
assert_eq!(p.mips[2].tail_position, 0x1_0000);topacked_mip_preserves_swizzle_and_array_tiling_indexes_slicesand pushed to the PR branch.@Marvisak Please review and merge this PR once CI is green. Testers on untested GPU models and setups are welcome to test real packed mip and array subresource tiling paths.
AI-assisted: yes (Gemini 4 Neon)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.