specialize fixed-width runs in texture tiling and detiling #1097
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1097
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1097/head"
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?
@matheusfrta on GitHub · 2026-11-24 15:42 UTC · original
matheusfrta:patch-1795534971→main· +185 −43 · 1 files · 1 commits · closed without mergingSpecializes Layout::detile and Layout::tile for the fixed 4, 8, 16, and 32 byte runs from RDNA2 micro-tiles so the inner loop emits fixed-size copies instead of dynamic memcpy calls, while handling shorter trailing runs for odd widths. Also replaces power-of-two divisions in row, column, and split with shifts and masks.
@MichaelSmithAI on GitHub · 2026-11-24 15:52 UTC · original
Independent CPU check on
ceac35b: 900 subresources produced byte-identical tiled buffers against both main and our staged texture implementation. Both detilers also recovered the patterned input and preserved row padding. The cases included odd widths, block-compressed formats, arrays, volumes and mip tails. All ten existing texture tests passed.For a 1919×1079 single-mip texture (4 bytes per texel, SW_64KB_D), we timed batches of 12 tile+detile pairs and alternated which implementation ran first over seven rounds. The median batch took 15.827 ms with the staged implementation, which already specializes fixed runs in
04f6244, and 12.994 ms with this PR. That is about 18% less time for this conversion loop. Title frame time remains unmeasured.@Zipettte on GitHub · 2026-11-24 16:29 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
ceac35b:cargo test -p victory-formatspasses, 24 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@necrobytes on GitHub · 2026-11-24 16:50 UTC · original
I compared #603 and #1097 independently against
mainon Fedora 45, Ryzen 5 9600X, with Rust 1.98.1 (x86_64-unknown-linux-gnu). I usedffe310efor all three builds. #603 (705a2f6) merged cleanly onto it, and #1097 (ceac35b) already had it as its parent.#1097 took 5–68% less time than #603 to detile the six swizzled textures. For tiling the two RGBA8 inputs and the odd-width R8 input, #603 was faster in all 12 paired rounds for each input. Both patches improved on main for those three tiling cases. #1097 also had the lowest median in both directions for BC1, BC7, and the R8 volume.
Median milliseconds per complete texture
I repeated the three uncompressed 2D swizzled cases on a second physical core, varying the destination’s offset relative to the source modulo 4 KiB (0, 64, 512 and 2,048 bytes). #603 won all 72 paired tiling comparisons there. #1097 won all 72 detiling comparisons.
Correctness
On each revision, I checked 5,369 subresources across 679 synthetic layouts. An independent driver used unmodified main’s
Layout::offsetto construct the expected destination for each direction, with separate inputs for tile and detile. All 14,503,816 element offsets and all 10,738 pairs of full-buffer comparisons matched, including row/plane padding and untouched mips and slices. The cases included 1D and 2D arrays, 3D volumes, block compression, and 2,540 mip-tail subresources. All 20 invalid/unsupported-argument checks returned the expected error and preserved the destination. Thevictory-formatscrate tests passed on each build (main and #603 each 23 passed, #1097 24 passed, four ignored on each).Timing method
I used one pinned logical CPU and preallocated, tightly pitched buffers with one mip and one sample. I timed complete calls to
Layout::tileandLayout::detileseparately. Each process warmed up with 16 copies, then measured five batches of 16. Each table entry is the median of 12 process medians, with all six orders of the three revisions used twice. These measurements cover warm CPU texture copies on this Linux host. Gameplay frame time would need a separate measurement.Reproduce an individual timing
Save the driver below as
bench.rsoutside the checkout. Withbenchdirset to that directory, run the following from each source tree. The driver prints five batch times in nanoseconds per copy and an output digest.Codex ran this comparison on my Linux machine.
@Marvisak on GitHub · 2026-11-25 00:32 UTC · original
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #603. Same optimisation as #603 (fixed-size micro-tile copies) as a +185/-43 rewrite that drops the shared walk, with no measurements, unformatted code and no trailing newline.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed