Textures: XOR modes detiled from one address part per axis (x3.8-4.5) #2543
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2543
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Alilou92 on GitHub · 2026-11-29 14:02 UTC · original
Alilou92:perf/detile-xor→main· +162 −2 · 1 files · 1 commits · openWhat 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
github-bot referenced this pull request2026-11-30 05:13:30 +00:00
github-bot referenced this pull request2026-11-30 05:13:30 +00:00
@davemathews12 on GitHub · 2026-11-30 05:14 UTC · original
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)@dyshay on GitHub · 2026-11-30 05:50 UTC · original
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.@Alilou92 on GitHub · 2026-11-30 10:15 UTC · original · reviewed
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.
@Alilou92 on GitHub · 2026-11-30 21:59 UTC · original
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.