Textures: wide non-XOR textures detiled a few block columns at a time #4546

Open
github-bot wants to merge 1 commit from github-bot/gh-4545 into main AGit
Owner

@⁠Alilou92 on GitHub · 2026-11-30 22:15 UTC · original
Alilou92:perf/detile-block-order → main · +90 −33 · 1 files · 1 commits · open

What it changes

CPU detiling of the non-XOR modes (walk). The XOR modes (walk_xor, #2543) are untouched.

walk copied one full row of a mip at a time. On a wide texture a row of 64 KiB blocks is about 2 MB (4096 × 128 × 4 bytes), so a block's cache lines were evicted before the next row came back to them. Rows of blocks larger than 512 KiB are now walked a band of block rows at a time, about 256 KiB of block columns per pass; smaller ones keep the row order. Equal runs are kept as u32 chunk numbers instead of 24-byte (usize, usize, usize) tuples, and 4-byte runs (3D textures of 1- and 2-byte elements) get a fixed-size copy like the 8, 16 and 32-byte ones. Every run is still copied once, to the same place.

#623 worked on this path too (an AVX2 transpose); it was closed without merging, so there is no overlap now.

How it was tested

  • GPU and profile: not applicable (CPU-side, no game run)
  • Byte-identical with main (e1251c31), both detile and tile: 16,132 random layouts (odd sizes, mips and tails, arrays, 3D, padded pitches)
  • cargo test -p victory-formats: 85 passed; clippy clean; the changed lines need no rustfmt change; cargo xtask policy --staged ok
  • 4096×4096 throughput (Linux VM, 2 vCPU, ±10-20 % between runs):
Direction Mode Before (GB/s) After (GB/s) Change
detile RGBA8 64KB_S 3.37 4.98 +48 %
tile RGBA8 64KB_S 3.12 4.10 +32 %
detile RGBA16F 64KB_D 4.39 5.73 +31 %
detile R8 64KB_S 8.30 10.34 +25 %
detile BC7 64KB_D 11.40 12.98 +14 %
tile BC7 64KB_D 9.21 10.44 +13 %
detile R8 3D 256×256×64 1.70 4.00 +134 %
detile R16 3D 256×256×64 1.44 2.17 +50 %

BC1 64KB_S, RGBA8 4KB_D and RGBA8 3D are within noise (−4 to +9 %); 2048² and below are neutral.

Not measured in game: the texture detiling per frame log line gives the MB per frame by swizzle mode, which would show how much of the load these modes carry.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #623 (closed, same path), #2543 (XOR path, merged)

🤖 Generated with Claude Code

**@⁠Alilou92** on GitHub · 2026-11-30 22:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4545) `Alilou92:perf/detile-block-order` → `main` · +90 −33 · 1 files · 1 commits · open ## What it changes CPU detiling of the non-XOR modes (`walk`). The XOR modes (`walk_xor`, #2543) are untouched. `walk` copied one full row of a mip at a time. On a wide texture a row of 64 KiB blocks is about 2 MB (4096 × 128 × 4 bytes), so a block's cache lines were evicted before the next row came back to them. Rows of blocks larger than 512 KiB are now walked a band of block rows at a time, about 256 KiB of block columns per pass; smaller ones keep the row order. Equal runs are kept as `u32` chunk numbers instead of 24-byte `(usize, usize, usize)` tuples, and 4-byte runs (3D textures of 1- and 2-byte elements) get a fixed-size copy like the 8, 16 and 32-byte ones. Every run is still copied once, to the same place. #623 worked on this path too (an AVX2 transpose); it was closed without merging, so there is no overlap now. ## How it was tested - GPU and profile: not applicable (CPU-side, no game run) - Byte-identical with `main` (e1251c31), both `detile` and `tile`: 16,132 random layouts (odd sizes, mips and tails, arrays, 3D, padded pitches) - `cargo test -p victory-formats`: 85 passed; clippy clean; the changed lines need no rustfmt change; `cargo xtask policy --staged` ok - 4096×4096 throughput (Linux VM, 2 vCPU, ±10-20 % between runs): | Direction | Mode | Before (GB/s) | After (GB/s) | Change | |---|---|---|---|---| | detile | RGBA8 64KB_S | 3.37 | 4.98 | +48 % | | tile | RGBA8 64KB_S | 3.12 | 4.10 | +32 % | | detile | RGBA16F 64KB_D | 4.39 | 5.73 | +31 % | | detile | R8 64KB_S | 8.30 | 10.34 | +25 % | | detile | BC7 64KB_D | 11.40 | 12.98 | +14 % | | tile | BC7 64KB_D | 9.21 | 10.44 | +13 % | | detile | R8 3D 256×256×64 | 1.70 | 4.00 | +134 % | | detile | R16 3D 256×256×64 | 1.44 | 2.17 | +50 % | BC1 64KB_S, RGBA8 4KB_D and RGBA8 3D are within noise (−4 to +9 %); 2048² and below are neutral. Not measured in game: the `texture detiling per frame` log line gives the MB per frame by swizzle mode, which would show how much of the load these modes carry. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #623 (closed, same path), #2543 (XOR path, merged) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
walk copied one full row of a mip at a time. On a wide texture a row of
64 KiB blocks is about 2 MB (4096 x 128 x 4 bytes), so a block's cache
lines were evicted before the next row came back to them. Rows of
blocks larger than 512 KiB are now walked a band of block rows at a
time, about 256 KiB of block columns per pass; smaller ones keep the
row order. Equal runs are kept as u32 chunk numbers instead of 24-byte
(usize, usize, usize) tuples, and 4-byte runs (3D textures of 1- and
2-byte elements) get a fixed-size copy like the 8, 16 and 32-byte ones.
Every run is still copied once, to the same place; walk_xor is
untouched.

Byte for byte as before, detile and tile, on 16,132 random layouts.
4096x4096 on a 2-vCPU VM: RGBA8 64KB_S detile 3.37 to 4.98 GB/s, tile
3.12 to 4.10; RGBA16F 64KB_D 4.39 to 5.73; R8 64KB_S 8.30 to 10.34;
BC7 64KB_D 11.40 to 12.98; R8 3D 256x256x64 1.70 to 4.00. BC1, RGBA8
4KB_D and RGBA8 3D within noise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UjaiBc7hr6kH3FowMKVt6Y
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:19:12 +00:00
github-bot force-pushed github-bot/gh-4545 from c9923871ca to b7149af743 2026-12-01 06:03:54 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4546/head:github-bot/gh-4545'
git switch 'github-bot/gh-4545'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4545'
git switch 'github-bot/gh-4545'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4545'
git switch 'github-bot/gh-4545'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4545'
git switch 'main'
git merge --squash 'github-bot/gh-4545'
git switch 'main'
git merge --ff-only 'github-bot/gh-4545'
git switch 'main'
git merge 'github-bot/gh-4545'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!4546
No description provided.