Copy packed linear texture rows one depth slice at a time #1201

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

@⁠BradRoland on GitHub · 2026-11-25 23:49 UTC · original
BradRoland:codex/linear-texture-row-copy → main · +43 −0 · 1 files · 1 commits · open

Layout::tile and detile currently issue a host copy per row, even for a linear mip whose logical row width equals both the title pitch and the caller's pitch. In that case each depth slice can be copied in one operation. Each side keeps its own slice stride, so padding between depth slices and the adjacent mip levels stay intact.

On an i9-12900K I timed the public tile and detile entry points with reused buffers. Both revisions ran in one optimized process pinned to one logical CPU. Each pair used the same buffers, alternating which implementation ran first. These are medians across 24 pairs, 128 MiB copied per batch.

Packed linear texture Tile before → after Detile before → after
64×64, 8 B/texel 635 → 552 ns 623 → 555 ns
128×128, 4 B/texel 1,356 → 1,058 ns 1,280 → 1,076 ns
256×256, 4 B/texel 4,623 → 4,191 ns 4,423 → 4,278 ns
256×256, 8 B/texel 8,421 → 8,097 ns 8,556 → 8,382 ns

Padded-row and 64 KiB tiled controls took the existing path and had mixed timings. The padded 63×64 tile control measured 201 → 218 ns. Results for the largest packed copy were sensitive to buffer placement across separate processes. Gameplay impact is unmeasured.

The new regression checks both directions against per-row offsets in a 3D mip, including untouched bytes around the mip and between slices. The formats suite passed 26 tests with four ignored, and Clippy passed with warnings denied. I also ran the #1152 D3D12 readback fixture with 64×64 linear R32_FLOAT resources on an RTX 4080 and WARP. Both passed its byte comparisons for full and restricted views.

**@⁠BradRoland** on GitHub · 2026-11-25 23:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/1201) `BradRoland:codex/linear-texture-row-copy` → `main` · +43 −0 · 1 files · 1 commits · open `Layout::tile` and `detile` currently issue a host copy per row, even for a linear mip whose logical row width equals both the title pitch and the caller's pitch. In that case each depth slice can be copied in one operation. Each side keeps its own slice stride, so padding between depth slices and the adjacent mip levels stay intact. On an i9-12900K I timed the public `tile` and `detile` entry points with reused buffers. Both revisions ran in one optimized process pinned to one logical CPU. Each pair used the same buffers, alternating which implementation ran first. These are medians across 24 pairs, 128 MiB copied per batch. | Packed linear texture | Tile before → after | Detile before → after | |---|---:|---:| | 64×64, 8 B/texel | 635 → 552 ns | 623 → 555 ns | | 128×128, 4 B/texel | 1,356 → 1,058 ns | 1,280 → 1,076 ns | | 256×256, 4 B/texel | 4,623 → 4,191 ns | 4,423 → 4,278 ns | | 256×256, 8 B/texel | 8,421 → 8,097 ns | 8,556 → 8,382 ns | Padded-row and 64 KiB tiled controls took the existing path and had mixed timings. The padded 63×64 tile control measured 201 → 218 ns. Results for the largest packed copy were sensitive to buffer placement across separate processes. Gameplay impact is unmeasured. The new regression checks both directions against per-row offsets in a 3D mip, including untouched bytes around the mip and between slices. The formats suite passed 26 tests with four ignored, and Clippy passed with warnings denied. I also ran the #1152 D3D12 readback fixture with 64×64 linear `R32_FLOAT` resources on an RTX 4080 and WARP. Both passed its byte comparisons for full and restricted views.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:24 +00:00
Author
Owner

@⁠Yoshi-233 on GitHub · 2026-11-26 03:57 UTC · original

I tested #1201 together with #1055 because both change the same volume-copy path. The #1055 texture patch applied cleanly to 5bb9592.

I used a CPU reference that copies one element at a time using Layout::offset. I checked the entire destination in both directions, including padding and neighboring mips. All 1,920 valid cases matched on the parent, #1201 alone, #1055 alone, and the two together. Of those cases, 180 meet the packed-linear fast-path condition. The rest cover padded rows or the 4 KiB swizzle. The input for detiling was generated separately from the tiling output.

I also tried 960 calls with the depth pitch one byte shorter than the active slice. Both the parent and #1201 alone accepted all 960 and wrote to the destination. #1055 alone and the combination returned TooSmall for all 960 and left every destination unchanged. The exact minimum pitch still worked, including when it omitted the final row's padding.

On the combined tree, cargo test --locked -p victory-formats --lib passed 27 tests with 4 ignored (Linux x86-64). The results support applying the two changes together. This was a byte-correctness check; I didn't measure throughput.

**@⁠Yoshi-233** on GitHub · 2026-11-26 03:57 UTC · [original](https://github.com/fxceless/victory-fork/pull/1201#issuecomment-7182165827) I tested #1201 together with #1055 because both change the same volume-copy path. The #1055 texture patch applied cleanly to `5bb9592`. I used a CPU reference that copies one element at a time using `Layout::offset`. I checked the entire destination in both directions, including padding and neighboring mips. All **1,920 valid cases** matched on the parent, #1201 alone, #1055 alone, and the two together. Of those cases, 180 meet the packed-linear fast-path condition. The rest cover padded rows or the 4 KiB swizzle. The input for detiling was generated separately from the tiling output. I also tried 960 calls with the depth pitch **one byte shorter** than the active slice. Both the parent and #1201 alone accepted all 960 and wrote to the destination. #1055 alone and the combination returned `TooSmall` for all 960 and left every destination unchanged. The exact minimum pitch still worked, including when it omitted the final row's padding. On the combined tree, `cargo test --locked -p victory-formats --lib` passed 27 tests with 4 ignored (Linux x86-64). The results support applying the two changes together. This was a byte-correctness check; I didn't measure throughput.
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/1201/head:github-bot/gh-1201'
git switch 'github-bot/gh-1201'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1201'
git switch 'github-bot/gh-1201'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1201'
git switch 'github-bot/gh-1201'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1201'
git switch 'main'
git merge --squash 'github-bot/gh-1201'
git switch 'main'
git merge --ff-only 'github-bot/gh-1201'
git switch 'main'
git merge 'github-bot/gh-1201'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.