Formats: build texture copy runs from swizzle blocks #3706

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3706 into main
andrewpozdnakov7-jpg commented 2026-11-28 09:50:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T09:50:30Z.


Build each tiled row's copy runs by walking slices of the stored column offsets. This computes the tiled base once per swizzle block. Adjacent offsets still join into the same run, including at a block or mip-tail boundary.

The exact old and new walkers produced identical offsets and lengths for 1,680 generated subresources, including 554 mip tails and 60 volume mips with several depth slices. Actual detiling returned identical bytes and padding in four separate fixtures.

Windows release medians across 13 alternating pairs were 9.22 to 3.87 µs for a 1,920×1 strip, 22.88 to 18.39 µs for 1,920×8, 203.36 to 200.59 µs for 640×360, and 0.721 to 0.692 µs for a 32×8 control. These timings measure CPU detiling of generated textures.

The formats suite passed with 46 tests passed and 5 ignored. Strict Clippy and the asset policy passed.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5538913549 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3706). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T09:50:30Z. --- Build each tiled row's copy runs by walking slices of the stored column offsets. This computes the tiled base once per swizzle block. Adjacent offsets still join into the same run, including at a block or mip-tail boundary. The exact old and new walkers produced identical offsets and lengths for 1,680 generated subresources, including 554 mip tails and 60 volume mips with several depth slices. Actual detiling returned identical bytes and padding in four separate fixtures. Windows release medians across 13 alternating pairs were 9.22 to 3.87 µs for a 1,920×1 strip, 22.88 to 18.39 µs for 1,920×8, 203.36 to 200.59 µs for 640×360, and 0.721 to 0.692 µs for a 32×8 control. These timings measure CPU detiling of generated textures. The formats suite passed with 46 tests passed and 5 ignored. Strict Clippy and the asset policy passed. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 09:53:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T09:53:59Z.


Windows CI passed on 92b2f83, including both Clippy configurations and the workspace tests. The old and new walkers emitted identical copy runs for 1,680 generated subresources. The release medians include 9.22 to 3.87 µs for 1,920×1, 22.88 to 18.39 µs for 1,920×8, and 203.36 to 200.59 µs for 640×360.

The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7237539134 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3706#issuecomment-7237539134). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T09:53:59Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46132351687/job/140940071476) passed on `92b2f83`, including both Clippy configurations and the workspace tests. The old and new walkers emitted identical copy runs for 1,680 generated subresources. The release medians include 9.22 to 3.87 µs for 1,920×1, 22.88 to 18.39 µs for 1,920×8, and 203.36 to 200.59 µs for 640×360. The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
Melow-code commented 2026-11-29 08:17:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Melow-code on 2026-11-29T08:17:42Z.

Review: COMMENTED


Checked on Linux, 92b2f839 on main 63bcca43: no objection.

  • column_runs against Layout::offset, element by element, which shares no loop with it: 118,255 random subresources (43,167 in a mip tail, 4,117 volume mips of several slices; the six modes without XOR, element sizes 1 to 16, plain and 4x4 block formats, widths 1 to 2,100). All 4,507,585 runs give the offsets of their elements, cover the row once, and none could be joined with the next.
  • detile and tile of 12,089 of those subresources, with padded rows and slices: the bytes offset names, the padding untouched.
  • With in_block taken from column in place of x (wrong in a mip tail), the check fails, and so does the existing addresses_are_a_bijection_and_copies_round_trip.
  • cargo test -p victory-formats --lib: 46 passed without mine, 0 failed (5 ignored).

Not run: Windows, the timings.

AI-assisted review (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6102051738 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3706#pullrequestreview-6102051738). Originally posted by [Melow-code](https://github.com/Melow-code) on 2026-11-29T08:17:42Z. **Review:** COMMENTED --- Checked on Linux, 92b2f839 on main 63bcca43: no objection. - `column_runs` against `Layout::offset`, element by element, which shares no loop with it: 118,255 random subresources (43,167 in a mip tail, 4,117 volume mips of several slices; the six modes without XOR, element sizes 1 to 16, plain and 4x4 block formats, widths 1 to 2,100). All 4,507,585 runs give the offsets of their elements, cover the row once, and none could be joined with the next. - `detile` and `tile` of 12,089 of those subresources, with padded rows and slices: the bytes `offset` names, the padding untouched. - With `in_block` taken from `column` in place of `x` (wrong in a mip tail), the check fails, and so does the existing `addresses_are_a_bijection_and_copies_round_trip`. - `cargo test -p victory-formats --lib`: 46 passed without mine, 0 failed (5 ignored). Not run: Windows, the timings. AI-assisted review (Claude Code).
kilolimaVI commented 2026-11-29 16:19:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T16:19:53Z.


I ran #2736's detile_throughput benchmark (copied into this branch unchanged) on a Ryzen 7 8845HS, release, median of 5 runs, against main 63bcca4:

case main MB/s #3706 MB/s ×
BC1 64KB_D detile 8,153 5,395 0.66
BC1 64KB_D tile 12,273 10,697 0.87
BC7 64KB_D detile 6,365 6,037 0.95
BC7 64KB_D tile 9,579 8,844 0.92
BC7 64KB_D tail detile 19,903 19,828 1.00
BC7 64KB_D tail tile 18,369 18,517 1.01
BC7 64KB_S detile 7,091 6,118 0.86
BC7 64KB_S tile 8,105 7,411 0.91
RGBA8 3D 4KB_S detile 8,335 8,052 0.97
RGBA8 3D 4KB_S tile 8,194 7,725 0.94
RGBA8 4KB_S detile 8,828 8,158 0.92
RGBA8 4KB_S tile 11,757 10,252 0.87
RGBA8 64KB_D detile 8,979 8,097 0.90
RGBA8 64KB_D tile 11,730 11,053 0.94

On this CPU it is slower than main in 12 of 14 cases (BC1 detile -34%) and even in the other two. #2736 was 1.06 to 2.18x on the same runs. If you have a case where the swizzle-block runs win, a benchmark for it would help compare.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7258807497 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3706#issuecomment-7258807497). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-29T16:19:53Z. --- I ran #2736's `detile_throughput` benchmark (copied into this branch unchanged) on a Ryzen 7 8845HS, release, median of 5 runs, against main 63bcca4: | case | main MB/s | #3706 MB/s | × | |---|---|---|---| | BC1 64KB_D detile | 8,153 | 5,395 | 0.66 | | BC1 64KB_D tile | 12,273 | 10,697 | 0.87 | | BC7 64KB_D detile | 6,365 | 6,037 | 0.95 | | BC7 64KB_D tile | 9,579 | 8,844 | 0.92 | | BC7 64KB_D tail detile | 19,903 | 19,828 | 1.00 | | BC7 64KB_D tail tile | 18,369 | 18,517 | 1.01 | | BC7 64KB_S detile | 7,091 | 6,118 | 0.86 | | BC7 64KB_S tile | 8,105 | 7,411 | 0.91 | | RGBA8 3D 4KB_S detile | 8,335 | 8,052 | 0.97 | | RGBA8 3D 4KB_S tile | 8,194 | 7,725 | 0.94 | | RGBA8 4KB_S detile | 8,828 | 8,158 | 0.92 | | RGBA8 4KB_S tile | 11,757 | 10,252 | 0.87 | | RGBA8 64KB_D detile | 8,979 | 8,097 | 0.90 | | RGBA8 64KB_D tile | 11,730 | 11,053 | 0.94 | On this CPU it is slower than main in 12 of 14 cases (BC1 detile -34%) and even in the other two. #2736 was 1.06 to 2.18x on the same runs. If you have a case where the swizzle-block runs win, a benchmark for it would help compare. AI-assisted (Claude).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3706:upstream-pr/3706'
git switch 'upstream-pr/3706'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3706'
git switch 'upstream-pr/3706'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3706'
git switch 'upstream-pr/3706'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3706'
git switch 'main'
git merge --squash 'upstream-pr/3706'
git switch 'main'
git merge --ff-only 'upstream-pr/3706'
git switch 'main'
git merge 'upstream-pr/3706'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3706
No description provided.