Formats: speed up GFX10 tiled texture copies up to 2.4x #2736

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

@⁠brainbudt on GitHub · 2026-11-25 19:22 UTC · original
brainbudt:perf/texture-detile → main · +291 −64 · 1 files · 1 commits · open

Layout::detile and Layout::tile previously inspected every column to build a run list and visited each row and depth slice independently, revisiting tiled blocks on adjacent rows and volume slices.

What changed

  • Derive the contiguous run width once from the shared swizzle pattern.
  • Pair short runs from adjacent rows and traverse depth slices while their tiled blocks stay in cache.
  • Add an ignored detile_throughput benchmark and extend copy tests against per-element Layout::offset across all addressable swizzles, element sizes, padding, odd dimensions, mip tails, array slices, 3D slabs, and error precedence.
  • Pure safe Rust, no new dependencies, public API and supported swizzle modes unchanged.

Benchmark (detile_throughput, median of 5 release runs on Apple M4, MB/s)

Layout Detile before Detile after Tile before Tile after
BC7 4096×4096 · 64KB_D 20,185.0 21,311.9 16,698.5 20,075.9
BC7 4096×4096 · 64KB_S 13,307.1 14,262.4 13,782.8 17,277.7
BC1 4096×4096 · 64KB_D 22,636.1 22,628.6 19,768.0 34,399.2
RGBA8 1920×1080 · 64KB_D 20,145.7 22,918.6 13,655.7 29,101.6
RGBA8 1920×1080 · 4KB_S 19,658.5 22,230.7 10,883.3 25,879.7
BC7 mip 5, 128×128 · 64KB_D 28,899.8 50,543.7 28,752.9 54,087.3
RGBA8 128×128×64 · 4KB_S 11,344.2 27,357.3 10,442.9 24,228.3

Verification

  • cargo test --release -p victory-formats texture (17 tests) and cargo clippy -p victory-formats --all-targets -- -D warnings passed.
  • Reproduce benchmark with cargo test --release -p victory-formats detile_throughput -- --ignored --nocapture.

Created with gpt-6.2-astra in Codex (orchestrated with Gemini 4 Neon in T3 Code).

**@⁠brainbudt** on GitHub · 2026-11-25 19:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736) `brainbudt:perf/texture-detile` → `main` · +291 −64 · 1 files · 1 commits · open `Layout::detile` and `Layout::tile` previously inspected every column to build a run list and visited each row and depth slice independently, revisiting tiled blocks on adjacent rows and volume slices. ### What changed - Derive the contiguous run width once from the shared swizzle pattern. - Pair short runs from adjacent rows and traverse depth slices while their tiled blocks stay in cache. - Add an ignored `detile_throughput` benchmark and extend copy tests against per-element `Layout::offset` across all addressable swizzles, element sizes, padding, odd dimensions, mip tails, array slices, 3D slabs, and error precedence. - Pure safe Rust, no new dependencies, public API and supported swizzle modes unchanged. ### Benchmark (`detile_throughput`, median of 5 release runs on Apple M4, MB/s) | Layout | Detile before | Detile after | Tile before | Tile after | |---|---:|---:|---:|---:| | BC7 4096×4096 · `64KB_D` | 20,185.0 | 21,311.9 | 16,698.5 | 20,075.9 | | BC7 4096×4096 · `64KB_S` | 13,307.1 | 14,262.4 | 13,782.8 | 17,277.7 | | BC1 4096×4096 · `64KB_D` | 22,636.1 | 22,628.6 | 19,768.0 | 34,399.2 | | RGBA8 1920×1080 · `64KB_D` | 20,145.7 | 22,918.6 | 13,655.7 | 29,101.6 | | RGBA8 1920×1080 · `4KB_S` | 19,658.5 | 22,230.7 | 10,883.3 | 25,879.7 | | BC7 mip 5, 128×128 · `64KB_D` | 28,899.8 | 50,543.7 | 28,752.9 | 54,087.3 | | RGBA8 128×128×64 · `4KB_S` | 11,344.2 | 27,357.3 | 10,442.9 | 24,228.3 | ### Verification - `cargo test --release -p victory-formats texture` (17 tests) and `cargo clippy -p victory-formats --all-targets -- -D warnings` passed. - Reproduce benchmark with `cargo test --release -p victory-formats detile_throughput -- --ignored --nocapture`. Created with gpt-6.2-astra in Codex (orchestrated with Gemini 4 Neon in T3 Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:04 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 20:10 UTC · original

Reviewed and benchmarked d3310473 on Windows 11 against main (13f91ca).

Code review

  • Zero unsafe, and all bounds/overflow checks (mip/slice/3D slice == 0, addressable(), checked_mul/checked_add, row_pitch/depth_pitch, tiled_len/linear_len) run in walk before writing any output bytes (covered by copy_errors_precede_writes_in_both_directions).
  • Checked the walk_runs::<N> specializations against all 15 MICRO entries (Thin S / Thin D / Thick 3D × 1/2/4/8/16B): contiguous x-run widths always fall in {4, 8, 16, 32} bytes, every BLOCK_256_2D / BLOCK_256_3D entry has even micro[1] so tail.y is always even for the rows = 2 paired path (N < 32), and columns + trailing last / copy.span handle empty columns, single-row mips, odd widths, and unaligned pitches without out-of-bounds slicing.

Verification & same-machine --release benchmark (rustc 1.98.1 MSVC)

  • cargo test -p victory-formats --locked: 39 passed, 0 failed, 6 ignored (byte-exact round-trip vs Layout::offset across LINEAR/256B/4KB/64KB S/D, 1..16B bpp, odd 259x19, 8-mip tail chain, arrays, and 3D).
  • victory-gpu WARP (--features diagnostics): texture::tests 2/2, draw::tests --test-threads=1 11/11.
  • cargo clippy -p victory-formats --all-targets --locked -- -D warnings: 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree against 13f91ca and #2735.
  • detile_throughput (--release, same machine vs 13f91ca):
    • BC7 64KB_D: detile 9,317 -> 13,471 MB/s (1.45x) | tile 12,646 -> 15,430 MB/s (1.22x)
    • BC7 64KB_S: detile 9,354 -> 12,430 MB/s (1.33x) | tile 10,307 -> 14,856 MB/s (1.44x)
    • BC1 64KB_D: detile 19,254 -> 33,089 MB/s (1.72x) | tile 25,347 -> 44,560 MB/s (1.76x)
    • RGBA8 64KB_D: detile 15,925 -> 32,770 MB/s (2.06x) | tile 12,847 -> 40,079 MB/s (3.12x)
    • RGBA8 4KB_S: detile 15,445 -> 32,479 MB/s (2.10x) | tile 13,660 -> 35,579 MB/s (2.60x)
    • BC7 64KB_D tail: detile 29,747 -> 48,344 MB/s (1.63x) | tile 28,035 -> 49,428 MB/s (1.76x)
    • RGBA8 3D 4KB_S: detile 12,117 -> 29,495 MB/s (2.43x) | tile 6,690 -> 17,379 MB/s (2.60x)
**@⁠fuzeofficlal** on GitHub · 2026-11-25 20:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#issuecomment-7173279442) Reviewed and benchmarked `d3310473` on Windows 11 against `main` (`13f91ca`). ### Code review - Zero `unsafe`, and all bounds/overflow checks (`mip`/`slice`/3D `slice == 0`, `addressable()`, `checked_mul`/`checked_add`, `row_pitch`/`depth_pitch`, `tiled_len`/`linear_len`) run in `walk` before writing any output bytes (covered by `copy_errors_precede_writes_in_both_directions`). - Checked the `walk_runs::<N>` specializations against all 15 `MICRO` entries (`Thin S` / `Thin D` / `Thick 3D` × 1/2/4/8/16B): contiguous x-run widths always fall in `{4, 8, 16, 32}` bytes, every `BLOCK_256_2D` / `BLOCK_256_3D` entry has even `micro[1]` so `tail.y` is always even for the `rows = 2` paired path (`N < 32`), and `columns` + trailing `last` / `copy.span` handle empty columns, single-row mips, odd widths, and unaligned pitches without out-of-bounds slicing. ### Verification & same-machine `--release` benchmark (`rustc 1.98.1` MSVC) - `cargo test -p victory-formats --locked`: **39 passed, 0 failed, 6 ignored** (byte-exact round-trip vs `Layout::offset` across `LINEAR`/`256B`/`4KB`/`64KB` `S`/`D`, 1..16B bpp, odd `259x19`, 8-mip tail chain, arrays, and 3D). - `victory-gpu` WARP (`--features diagnostics`): `texture::tests` **2/2**, `draw::tests --test-threads=1` **11/11**. - `cargo clippy -p victory-formats --all-targets --locked -- -D warnings`: **0 warnings**; `cargo xtask policy`: **184 files ok**; clean `git merge-tree` against `13f91ca` and `#2735`. - `detile_throughput` (`--release`, same machine vs `13f91ca`): - `BC7 64KB_D`: detile `9,317` -> **`13,471 MB/s` (1.45x)** | tile `12,646` -> **`15,430 MB/s` (1.22x)** - `BC7 64KB_S`: detile `9,354` -> **`12,430 MB/s` (1.33x)** | tile `10,307` -> **`14,856 MB/s` (1.44x)** - `BC1 64KB_D`: detile `19,254` -> **`33,089 MB/s` (1.72x)** | tile `25,347` -> **`44,560 MB/s` (1.76x)** - `RGBA8 64KB_D`: detile `15,925` -> **`32,770 MB/s` (2.06x)** | tile `12,847` -> **`40,079 MB/s` (3.12x)** - `RGBA8 4KB_S`: detile `15,445` -> **`32,479 MB/s` (2.10x)** | tile `13,660` -> **`35,579 MB/s` (2.60x)** - `BC7 64KB_D tail`: detile `29,747` -> **`48,344 MB/s` (1.63x)** | tile `28,035` -> **`49,428 MB/s` (1.76x)** - `RGBA8 3D 4KB_S`: detile `12,117` -> **`29,495 MB/s` (2.43x)** | tile `6,690` -> **`17,379 MB/s` (2.60x)**
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:36 UTC · original

Solid rewrite: the contiguous-prefix detection (take_while on the x pattern) yields the compile-time run width N, columns are precomputed once in N-byte units, and the row-pair trick for narrow runs keeps writes to nearby tiled addresses together. The unreachable! on run width is safe per the GFX10 pattern shape. One coverage question: do the texture tests (or a fixture elsewhere) round-trip tile/detile across the swizzle modes and mip tails? The tail-run + second-row edge cases in walk_runs are exactly the spots where a copy could silently misalign.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#issuecomment-7173916566) Solid rewrite: the contiguous-prefix detection (take_while on the x pattern) yields the compile-time run width N, columns are precomputed once in N-byte units, and the row-pair trick for narrow runs keeps writes to nearby tiled addresses together. The unreachable! on run width is safe per the GFX10 pattern shape. One coverage question: do the texture tests (or a fixture elsewhere) round-trip tile/detile across the swizzle modes and mip tails? The tail-run + second-row edge cases in walk_runs are exactly the spots where a copy could silently misalign.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 20:58 UTC · original

Independent WARP/CPU verification of d3310473 (#2736).

Review: Only victory-formats/src/texture.rs changes. walk now validates everything before any write (it was already doing that, and copy_errors_precede_writes_in_both_directions now pins it), and tiled copies go through a Buffers enum with monomorphised run widths (4/8/16/32). Linear layouts take a plain row copy. I found no unsafe, and slicing stays bounds-checked. Odd widths (a short last run) and odd heights (an unpaired row) are handled through last and second. I found no correctness problems.

Results (CPU):

  • origin/main: cargo test -p victory-formats --lib: 38 passed, 5 ignored.
  • PR: 39 passed, 0 failed, 6 ignored (the ignored extra is the detile_throughput benchmark; I did not re-measure the 2.4x claim).
  • cargo clippy --locked -p victory-formats --all-targets [--all-features] -- -D warnings: clean. cargo test -p xtask (policy): 6 passed.

Negative control (mutating the PR head):

  • Dropping the short tail run (last = None): addresses_are_a_bijection_and_copies_round_trip fails.
  • Dropping the row pairing (second = None): addresses_are_a_bijection_and_copies_round_trip and depth_pitch_accepts_exact_and_padded_slices fail.

So the new odd-size and cross-block cases catch breakage in the new fast path.

Method: no physical GPU. VICTORY_WARP=1, VICTORY_D3D12_WARP=1, Windows SDK 10.0.26100 dxil.dll on PATH, Windows 11, rustc 1.98.1 MSVC, --locked. Compared origin/main (13f91ca) with the PR head. The PR merges cleanly onto that main. No game files, dumps, shader names or retail hashes were used or are needed.

AI disclosure: this verification was done by Claude Code / Claude Sonnet 5.5.

**@⁠oni-swr** on GitHub · 2026-11-25 20:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#issuecomment-7174432527) Independent WARP/CPU verification of `d3310473` (#2736). **Review:** Only `victory-formats/src/texture.rs` changes. `walk` now validates everything before any write (it was already doing that, and `copy_errors_precede_writes_in_both_directions` now pins it), and tiled copies go through a `Buffers` enum with monomorphised run widths (4/8/16/32). Linear layouts take a plain row copy. I found no `unsafe`, and slicing stays bounds-checked. Odd widths (a short last run) and odd heights (an unpaired row) are handled through `last` and `second`. I found no correctness problems. **Results (CPU):** - `origin/main`: `cargo test -p victory-formats --lib`: 38 passed, 5 ignored. - PR: 39 passed, 0 failed, 6 ignored (the ignored extra is the `detile_throughput` benchmark; I did not re-measure the 2.4x claim). - `cargo clippy --locked -p victory-formats --all-targets [--all-features] -- -D warnings`: clean. `cargo test -p xtask` (policy): 6 passed. **Negative control (mutating the PR head):** - Dropping the short tail run (`last = None`): `addresses_are_a_bijection_and_copies_round_trip` fails. - Dropping the row pairing (`second = None`): `addresses_are_a_bijection_and_copies_round_trip` and `depth_pitch_accepts_exact_and_padded_slices` fail. So the new odd-size and cross-block cases catch breakage in the new fast path. Method: no physical GPU. `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, Windows SDK 10.0.26100 `dxil.dll` on `PATH`, Windows 11, rustc 1.98.1 MSVC, `--locked`. Compared `origin/main` (`13f91ca`) with the PR head. The PR merges cleanly onto that main. No game files, dumps, shader names or retail hashes were used or are needed. AI disclosure: this verification was done by Claude Code / Claude Sonnet 5.5.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:22 UTC · original

Automated triage for the maintainers.

This reworks Layout::walk in crates/victory-formats/src/texture.rs for tile/detile: the contiguous run width is derived once from pattern[0], copies are monomorphised per width (walk_runs::<N>), narrow runs pair adjacent rows using pattern[1][1], and thick 3D slabs walk their depth slices together. By reading I checked the assumptions against MICRO: every addressable kind/element size gives a run of 4, 8, 16 or 32 bytes (so the unreachable! holds), y bits always sit above the run bits (so the paired-row offset is a whole number of chunks), micro tiles are at least 2 rows tall (tail origins stay on even y), and all validation still precedes the first write. The round-trip test now compares the whole tiled buffer against per-element Layout::offset over all addressable swizzles, element sizes, odd sizes, arrays and volumes. CI (check) passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#issuecomment-7177470921) <!-- victory-triage v1 head=d33104738a4724e8c616be780089e58d8f96a5fe verdict=merge-candidate at=2026-11-25T23:22:14Z --> Automated triage for the maintainers. This reworks `Layout::walk` in `crates/victory-formats/src/texture.rs` for `tile`/`detile`: the contiguous run width is derived once from `pattern[0]`, copies are monomorphised per width (`walk_runs::<N>`), narrow runs pair adjacent rows using `pattern[1][1]`, and thick 3D slabs walk their depth slices together. By reading I checked the assumptions against `MICRO`: every addressable kind/element size gives a run of 4, 8, 16 or 32 bytes (so the `unreachable!` holds), y bits always sit above the run bits (so the paired-row offset is a whole number of chunks), micro tiles are at least 2 rows tall (tail origins stay on even y), and all validation still precedes the first write. The round-trip test now compares the whole tiled buffer against per-element `Layout::offset` over all addressable swizzles, element sizes, odd sizes, arrays and volumes. CI (`check`) passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-26 00:49 UTC · original · approved these changes

Verified against origin/main (63bcca4):

  • GFX10 tiled texture copy speedup passes all 47 victory-formats unit tests (including addresses_are_a_bijection_and_copies_round_trip, layouts_match_addrlib, and layouts_share_identical_swizzle_tables).
  • cargo clippy -p victory-formats --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-26 00:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#pullrequestreview-6067059370) · **approved these changes** Verified against `origin/main` (`63bcca4`): - GFX10 tiled texture copy speedup passes all 47 `victory-formats` unit tests (including `addresses_are_a_bijection_and_copies_round_trip`, `layouts_match_addrlib`, and `layouts_share_identical_swizzle_tables`). - `cargo clippy -p victory-formats --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 12:42 UTC · original

NVIDIA full-suite run, to go with the reports above by fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head d331047 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: copy_errors_precede_writes_in_both_directions.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 12:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#issuecomment-7192364343) NVIDIA full-suite run, to go with the reports above by fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head `d331047` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `copy_errors_precede_writes_in_both_directions`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 14:42 UTC · original · approved these changes

The contiguous run widths (4, 8, 16, and 32 bytes in crates/victory-formats/src/texture.rs:705-761) cover all currently addressable MICRO patterns and element sizes (1..=16 B), every full-run column() offset and pattern[1][1] second-row delta is an exact multiple of N, row pairs stay within a block height (both y and tail.y are even), 3D slab alignment holds since slice == 0 for Tex3d, narrow/odd tails fall back cleanly to span(), and all validation checks precede writes in both directions. Verified address equivalence across 60 layouts / 717 subresources / 999,986 element addresses (including 231 tail and 88 bytes < N subresources) with zero mismatches.

Local verification at d3310473 (and merged onto origin/main at 8a82b503): xtask policy (184 files ok), cargo clippy -p victory-formats --all-targets (default and --all-features, 0 warnings), and cargo test -p victory-formats (debug and --release: 39 passed, 0 failed, 6 ignored; merged onto origin/main: 47 passed, 0 failed, 6 ignored) all passed. Release detile_throughput on a Ryzen 9 9950X vs origin/main (63bcca43) improved across all 14 cases by 1.43x–4.35x (e.g., BC7 64KB_D detile 8,278.7 -> 16,452.3 MB/s, BC7 64KB_S tile 12,000.7 -> 21,391.2 MB/s, RGBA8 64KB_D detile 9,937.6 -> 43,266.9 MB/s, RGBA8 4KB_S tile 13,255.4 -> 52,662.9 MB/s, RGBA8 3D 4KB_S tile 7,311.3 -> 18,624.0 MB/s). Approving.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#pullrequestreview-6076046893) · **approved these changes** The contiguous run widths (`4`, `8`, `16`, and `32` bytes in `crates/victory-formats/src/texture.rs:705-761`) cover all currently addressable `MICRO` patterns and element sizes (`1..=16` B), every full-run `column()` offset and `pattern[1][1]` second-row delta is an exact multiple of `N`, row pairs stay within a block height (both `y` and `tail.y` are even), 3D `slab` alignment holds since `slice == 0` for `Tex3d`, narrow/odd tails fall back cleanly to `span()`, and all validation checks precede writes in both directions. Verified address equivalence across 60 layouts / 717 subresources / 999,986 element addresses (including 231 tail and 88 `bytes < N` subresources) with zero mismatches. Local verification at `d3310473` (and merged onto `origin/main` at `8a82b503`): `xtask policy` (`184 files ok`), `cargo clippy -p victory-formats --all-targets` (`default` and `--all-features`, 0 warnings), and `cargo test -p victory-formats` (debug and `--release`: `39 passed, 0 failed, 6 ignored`; merged onto `origin/main`: `47 passed, 0 failed, 6 ignored`) all passed. Release `detile_throughput` on a Ryzen 9 9950X vs `origin/main` (`63bcca43`) improved across all 14 cases by **1.43x–4.35x** (e.g., `BC7 64KB_D detile` `8,278.7 -> 16,452.3 MB/s`, `BC7 64KB_S tile` `12,000.7 -> 21,391.2 MB/s`, `RGBA8 64KB_D detile` `9,937.6 -> 43,266.9 MB/s`, `RGBA8 4KB_S tile` `13,255.4 -> 52,662.9 MB/s`, `RGBA8 3D 4KB_S tile` `7,311.3 -> 18,624.0 MB/s`). Approving.
Author
Owner

@⁠rezioliver-collab on GitHub · 2026-11-26 18:02 UTC · original

I measured the odd-pitch case separately on Apple M1. Adding 37 bytes to each linear row and 19 bytes between depth slices still gave a speedup in both directions, including on a 3D volume with an odd depth.

Synthetic surface, +37-byte row padding Tile speedup Detile speedup
RGBA8, 257 × 129, array slice 1 1.89× 1.79×
BC7, 513 × 257, array slice 1 1.50× 1.95×
RGBA8, 65 × 33 × 9, 3D 2.06× 2.08×

I compared 13f91cae with d3310473 using coordinate-dependent bytes. Tight rows and rows rounded up to 256 bytes were additional controls. The PR had a faster median in all 18 combinations of surface, pitch and copy direction. I built a tiled reference one element at a time with Layout::offset, then compared whole buffers in both directions, including row padding, guard bytes and the untouched array slice. Every comparison matched.

The table uses median base/PR ratios from 12 alternating release pairs on macOS 14.7, Rust 1.98.1.

**@⁠rezioliver-collab** on GitHub · 2026-11-26 18:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#issuecomment-7199981960) I measured the odd-pitch case separately on Apple M1. Adding 37 bytes to each linear row and 19 bytes between depth slices still gave a speedup in both directions, including on a 3D volume with an odd depth. | Synthetic surface, +37-byte row padding | Tile speedup | Detile speedup | |---|---:|---:| | RGBA8, 257 × 129, array slice 1 | 1.89× | 1.79× | | BC7, 513 × 257, array slice 1 | 1.50× | 1.95× | | RGBA8, 65 × 33 × 9, 3D | 2.06× | 2.08× | I compared `13f91cae` with `d3310473` using coordinate-dependent bytes. Tight rows and rows rounded up to 256 bytes were additional controls. The PR had a faster median in all 18 combinations of surface, pitch and copy direction. I built a tiled reference one element at a time with `Layout::offset`, then compared whole buffers in both directions, including row padding, guard bytes and the untouched array slice. Every comparison matched. The table uses median base/PR ratios from 12 alternating release pairs on macOS 14.7, Rust 1.98.1.
Author
Owner

@⁠Desamodeth on GitHub · 2026-11-26 18:41 UTC · original · reviewed

I compared #2026 (1ec3877) and this PR (d331047) against main (63bcca4) on the same Ryzen 7 9800X3D. I would prioritize #2736 for its performance in both copy directions. One exception worth preserving in future benchmarks is detiling a rotating set of 1080p surfaces: #2026 was faster there in both processes.

Median µs per complete subresource copy on Windows x64. Columns are main / #2026 / #2736, first process:

Synthetic layout Detile Tile
1920×1080 RGBA8, 64KB_D 328 / 273 / 186 402 / 712 / 184
Same, rotating 8 input/output pairs 675 / 442 / 460 572 / 723 / 369
4096² BC7, 64KB_D 436 / 372 / 344 413 / 366 / 347
Same, rotating 4 pairs 1131 / 770 / 752 769 / 696 / 709
128×128×64 RGBA8 volume, 4KB_S 341 / 233 / 143 669 / 741 / 248

The second process reversed the version order. The 1080p tile slowdown on #2026 repeated (380 / 741 / 188 µs), as did its advantage over #2736 for rotating 1080p detile (696 / 448 / 484 µs). The rotating BC7 detile ranking between the two PRs flipped; that case does not give a dependable winner. The linear 1080p control was within 2% across versions in each process.

Each version's actual texture.rs was compiled as a separate optimized Rust 1.98.1 MSVC library. The module on #2736's older base is byte-identical to current main. Same buffers for all three versions, all six orders, two warm-up batches and twelve measured batches. Before timing I compared each direction independently against buffers built with main's per-element Layout::offset, including padding, an untouched array slice and a small mip. The module's active tests passed on all three. CPU copies only; no game frame or GPU measurement. Coordination. AI-assisted with Codex.

**@⁠Desamodeth** on GitHub · 2026-11-26 18:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2736#pullrequestreview-6079097963) · **reviewed** I compared #2026 (`1ec3877`) and this PR (`d331047`) against main (`63bcca4`) on the same Ryzen 7 9800X3D. I would prioritize **#2736** for its performance in both copy directions. One exception worth preserving in future benchmarks is detiling a rotating set of 1080p surfaces: #2026 was faster there in both processes. Median µs per complete subresource copy on Windows x64. Columns are **main / #2026 / #2736**, first process: | Synthetic layout | Detile | Tile | |---|---:|---:| | 1920×1080 RGBA8, 64KB_D | 328 / 273 / **186** | 402 / 712 / **184** | | Same, rotating 8 input/output pairs | 675 / **442** / 460 | 572 / 723 / **369** | | 4096² BC7, 64KB_D | 436 / 372 / **344** | 413 / 366 / **347** | | Same, rotating 4 pairs | 1131 / 770 / 752 | 769 / 696 / 709 | | 128×128×64 RGBA8 volume, 4KB_S | 341 / 233 / **143** | 669 / 741 / **248** | The second process reversed the version order. The 1080p tile slowdown on #2026 repeated (380 / 741 / 188 µs), as did its advantage over #2736 for rotating 1080p detile (696 / 448 / 484 µs). The rotating BC7 detile ranking between the two PRs flipped; that case does not give a dependable winner. The linear 1080p control was within 2% across versions in each process. Each version's actual `texture.rs` was compiled as a separate optimized Rust 1.98.1 MSVC library. The module on #2736's older base is byte-identical to current main. Same buffers for all three versions, all six orders, two warm-up batches and twelve measured batches. Before timing I compared each direction independently against buffers built with main's per-element `Layout::offset`, including padding, an untouched array slice and a small mip. The module's active tests passed on all three. CPU copies only; no game frame or GPU measurement. [Coordination](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). AI-assisted with Codex.
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/2736/head:github-bot/gh-2736'
git switch 'github-bot/gh-2736'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2736'
git switch 'github-bot/gh-2736'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2736'
git switch 'github-bot/gh-2736'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2736'
git switch 'main'
git merge --squash 'github-bot/gh-2736'
git switch 'main'
git merge --ff-only 'github-bot/gh-2736'
git switch 'main'
git merge 'github-bot/gh-2736'
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/Marvisak--VIctory!2736
No description provided.