Textures: XOR modes detiled from one address part per axis (x3.8-4.5) #2543
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2543"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by Alilou92 on 2026-11-29T14:02:03Z.
What it changes
CPU detiling of the XOR modes (
walk_xor). They always take the PC path: the card detiling (VICTORY_GPU_DETILE) does not handle them.Each 16-byte run recomputed its whole address with
xor_offset, a 16-step parity loop. An address bit is the parity of masked x, y and z bits, so the offset is the XOR of one part per axis: z's once a slice, y's once a row, x's from two 256-entry tables (XorAxes). Nearly every run of these modes is 16 bytes, so those take a fixed copy (copy_fixed), and the loop shifts and masks instead of dividing (block widths and runs are powers of two). Every run is still copied once, to the same place.Only
walk_xorand two helpers; the other modes are untouched (#623 works on those).How it was tested
main, bothdetileandtile: 20,436 random layouts, 16,490 of them XOR (both consoles' pipe configurations, odd sizes, mips and tails, arrays, 3D)cargo test -p victory-formats: texture tests pass (the 3 BCPack oracle failures onmainare fixed in #2419); clippy clean; the changed lines need no rustfmt change;cargo xtask policyoktexture.rsNot measured in game. Could someone with the game paste a few
texture detiling per framelines from their play log, before and after (ideally while driving)? They give the ms and MB per frame by swizzle mode, so the real gain.Checked for overlap
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by davemathews12 on 2026-11-30T05:14:32Z.
I read the change against the per-bit
xor_offsetand the change looks correct:xor_offset(x, y, z) == part_x ^ part_y ^ part_z.tail_x/tail_yare added before both parts, asxor_addressdoes.first + z).u16, so no higher bit matters.Two suggestions:
Tests. The PR changes the XOR copy path but adds no test for it. Two tests that pin it are attached below:
xor_tables_split_the_address_by_axis: the split, checked for every pattern of both consoles at every element size.xor_copies_match_offset_for_every_mode_and_element_size: detile and tile checked element by element againstoffset(). It covers every XOR mode × both consoles × 1–16-byte elements, 2D arrays and 3D, full mip chains, and padded pitches.Both tests are planted-bug-checked: dropping the tail's y, or using
|for^, makes them fail.Build
XorAxesonce per layout, not once per call.walk_xorruns once per mip, and each call fills two 256-entry tables. The tables depend only on(pattern, bits), soconfigure_xorcould build them once and theLayoutcould keep them.For scale: the same per-axis idea as a column table, measured on a 4-vCPU Xeon (Linux, synthetic textures, whole mip chains) against
main:64KB_S_X, 5–7× for RGBA8 2048²64KB_R_X.Note that #3524 rewrites the same function, so only one of the two can merge as is.
The two tests (paste into texture.rs's
mod tests)Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T05:50:00Z.
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch
janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with--profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Alilou92 on 2026-11-30T10:15:01Z.
Review: COMMENTED
Thanks for the review and for the independent numbers.
Reproduced here (2048², detile, Linux VM, 2 vCPU, best of 10, byte-identical outputs):
On fixed-size copies, this machine sees a steady gain: +12 to +21 % over the plain copy in all 8 cases. It likely depends on the CPU (fast short
rep movsb/memcpy would close the gap), so I'd keep it since it costs nothing where it doesn't help.I'll add the two tests you suggested and build the XOR tables once per pattern (a static cache, as
shared_patterndoes for the other modes).On #3524: it uses the same factorisation, bundled with four unrelated changes. This PR is only
walk_xor(one file), opened earlier, with byte-for-byte checks on 20,436 layouts. Happy to go with whichever the maintainer prefers.@dyshay thanks for queuing the 4090 run, looking forward to the frame times.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Alilou92 on 2026-11-30T21:59:11Z.
Thanks for merging! The first commit is in main (
5b436841). The second one,ad8eb45, still applies cleanly on main: it builds the XOR tables once per pattern (RGBA8 64×6464KB_S_X3.50 → 5.09 GB/s, 128×128 4.13 → 4.65; 256×256 and up unchanged) and adds the two tests suggested in review (every XOR pattern of both consoles against the untouchedxor_offset; every mode, element size and console againstoffset, 880 subresources). Happy to open it as a separate PR if that's easier.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.