Textures: detile and tile levels a block at a time, in runs of x neighbours #901

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

@⁠mastrr9 on GitHub · 2026-11-24 08:00 UTC · original
mastrr9:perf/tiling-block-runs → main · +538 −41 · 2 files · 1 commits · open

Speeds up CPU-side console texture detiling and tiling (detile_level, tile_level, detile_volume, tile_volume in crates/xcl/src/gpu/tiling.rs):

  • Replaces per-element bounds-checked runtime-length memcpy and row-wide walks with a single block-by-block walk that splits x/y/z offsets, uses fixed-size element copies, and copies aligned runs of up to 16 B of x-neighbours at once (falling back element-by-element where swizzle bits overlap).
  • Produces byte-identical output across all tiling modes and adds comprehensive equivalence tests plus a manual #[ignore] benchmark harness (crates/xcl/tests/tiling_perf.rs).

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: 8b521d5d5a9a88cf299e26d0c81520a948eef4f3 (HEAD 2e88e656a3e1f9096d9c06e2d8314657510c716e has an identical tree; only commit author metadata was updated after GitHub account rename)
  • cargo build --workspace: clean (no new warnings; only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 718 passed, 0 failed, 42 ignored (extra ignored item is the manual benchmark in tests/tiling_perf.rs)
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Regression run
Smoke run by @⁠Toons29 in comment below: #901
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.

main:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB

PR:

xcl-smoke v1
commit: 2e88e656a3e1f9096d9c06e2d8314657510c716e
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1621 (PresentX 1621)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14807 MB

Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; the tester checked the blocks before posting.

Not tested

  • No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
  • Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.
**@⁠mastrr9** on GitHub · 2026-11-24 08:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/901) `mastrr9:perf/tiling-block-runs` → `main` · +538 −41 · 2 files · 1 commits · open Speeds up CPU-side console texture detiling and tiling (`detile_level`, `tile_level`, `detile_volume`, `tile_volume` in `crates/xcl/src/gpu/tiling.rs`): - Replaces per-element bounds-checked runtime-length `memcpy` and row-wide walks with a single block-by-block walk that splits x/y/z offsets, uses fixed-size element copies, and copies aligned runs of up to 16 B of x-neighbours at once (falling back element-by-element where swizzle bits overlap). - Produces byte-identical output across all tiling modes and adds comprehensive equivalence tests plus a manual `#[ignore]` benchmark harness (`crates/xcl/tests/tiling_perf.rs`). **Tested** - Hardware/OS: NVIDIA RTX 5080 (driver `617.42` / `32.0.16.1742`), Windows 11 Pro 25H2 (`26200.9974`), `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC debug, DXC Windows SDK `10.0.26100.0`, `d3d12SDKLayers.dll` installed - Commit tested: `8b521d5d5a9a88cf299e26d0c81520a948eef4f3` (HEAD `2e88e656a3e1f9096d9c06e2d8314657510c716e` has an identical tree; only commit author metadata was updated after GitHub account rename) - `cargo build --workspace`: clean (no new warnings; only pre-existing `fetch_update` deprecation warning) - `cargo test --workspace -- --test-threads=4`: **718 passed, 0 failed, 42 ignored** (extra ignored item is the manual benchmark in `tests/tiling_perf.rs`) - `SKIPPED` GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64` **Regression run** Smoke run by @⁠Toons29 in comment below: https://git.gtahub.st/github/xcl-dev--xcl/pulls/901 Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted. main: ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` PR: ``` xcl-smoke v1 commit: 2e88e656a3e1f9096d9c06e2d8314657510c716e gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1621 (PresentX 1621) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14807 MB ``` Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; the tester checked the blocks before posting. **Not tested** - No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known. **AI use** - Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5). - Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.
Detiling still cost a bounds-checked, runtime-length copy (a memcpy call)
per element, and tile_level, detile_volume and tile_volume recomputed the
whole element_at_z (two divisions, six table lookups) for every element.
Rows were walked across the whole level, so on a 3840-wide surface the
rows of blocks 64 KB (or 4 KB) apart fall in the same cache sets and evict
each other before the next rows use the rest of their lines.

All four now share one walk: the x part of the offset once per level, the
y part once per row, z once per depth slice. Copies are specialised by
element size (1 to 16 B), and in every mode the lowest address bits are x
bits, so an aligned group of 2 to 16 x neighbours lies in consecutive
bytes: it is one fixed-size copy of up to 16 B, in every row whose y / z /
base swizzle bits leave those bits alone (otherwise element by element).
The level is walked block by block. Output is byte-identical: bytes past
the end of the source still read as 0 per element, and tiling into a
slice too short (or from a linear one too short) falls back to the old
row-major order so it panics having written the same elements.

Tests: the old element-by-element functions kept as reference models,
compared on every mode (linear too), element size and 10 pipe configs,
sizes around the block, mips with tails, base swizzles (unaligned and past
the block), array slices, 3D thick / thin / linear, truncated sources,
odd origins and pitches, and short destinations and linear buffers.

Measured (Linux harness, release, median of 6 alternating runs each,
4 shared cores):
  RGBA8 3840x2160 64KB_D    detile_level 34.3 -> 11.2 ms (3.1x)
                            tile_level  126.2 -> 10.4 ms (12.1x)
  RGBA8 3840x2160 4KB_S     detile_level 34.3 -> 11.1 ms (3.1x)
  RGBA8 3840x2160 R_X (SX)  detile_level 35.5 -> 10.9 ms (3.2x)
  BC7 3840x2160 64KB_D      detile_level  2.18 -> 1.38 ms (1.6x)
                            tile_level   11.2 ->  1.06 ms (10.6x)
  BC7 4096x4096, 13 mips    detile_level  7.33 -> 3.99 ms (1.8x)
  RGBA8 256x256x64 4KB_S    detile_volume 72.1 -> 10.4 ms (7.0x)
    thick                   tile_volume   59.0 ->  6.5 ms (9.0x)
A memcpy of the same bytes into a new Vec takes 4.1 ms (RGBA8) and
0.69 ms (BC7) on the same machine.

Assisted-by: Claude Code (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:36:19 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 09:34 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 2e88e65 onto main 09940bb, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 712 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. detile/tile run tests green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-24 09:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/901#issuecomment-7127600416) Linux / AMD RDNA3 datapoint. **Merged state:** head `2e88e65` onto main `09940bb`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **712 passed, 7 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows. detile/tile run tests green. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:07 UTC · original

Regression run of 2e88e656 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 2e88e656a3e1f9096d9c06e2d8314657510c716e
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1621 (PresentX 1621)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14807 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/901#issuecomment-7151613298) Regression run of `2e88e656` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 2e88e656a3e1f9096d9c06e2d8314657510c716e gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1621 (PresentX 1621) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14807 MB ``` Against the limits in CONTRIBUTING.md: 100 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:50 UTC · original

Empirical test report (2e88e656)

Hardware / environment

  • Commit 2e88e656a3e1f9096d9c06e2d8314657510c716e in a clean detached worktree on Windows x64, build 26200. AMD64 Family 23 Model 113 Stepping 0 with 12 logical processors.
  • rustc 1.100.0 (0ef1bc386 2026-11-09) and DXC 1.9.2609.5 (01b62ad47). Both focused runs used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. They ran outside Invoke-ArcTest.ps1 with zero Arc GPU mutex hold.

Commands and results

  • cargo test --workspace --no-run exited 0 and compiled the workspace test executables.
  • cargo test -p xcl --lib gpu::tiling::tests:: -- --nocapture exited 0 with 17 passed, 0 failed, 0 ignored, 0 skipped, and 681 filtered out. The harness finished in 27.78 s.
  • cargo test --release -p xcl --test tiling_perf -- --ignored --nocapture exited 0 with 1 opt-in benchmark passed, 0 failed, 0 ignored, and 0 skipped.

Observed behavior

  • The new 2D and 3D tests matched the element-by-element reference byte for byte on the cases exercised, including mip tails, array slices, swizzles, and truncated sources.
  • The short-slice test matched the reference's panic behavior and the bytes written before a panic. The expected caught panics appear in the uncaptured output.
  • The release benchmark completed all eight cases. Head-only median samples in ms were 23.90 detile / 11.72 tile for RGBA8 3840x2160 64KB_D and 14.36 detile / 11.83 tile for RGBA8 256x256x64 4KB_S thick.

Not tested

The full GPU workspace suite, game smoke runs, and a performance comparison against main were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr901-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/901#issuecomment-7154191749) ### Empirical test report (2e88e656) **Hardware / environment** - Commit `2e88e656a3e1f9096d9c06e2d8314657510c716e` in a clean detached worktree on Windows x64, build 26200. AMD64 Family 23 Model 113 Stepping 0 with 12 logical processors. - `rustc 1.100.0 (0ef1bc386 2026-11-09)` and DXC `1.9.2609.5 (01b62ad47)`. Both focused runs used `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`. They ran outside `Invoke-ArcTest.ps1` with zero Arc GPU mutex hold. **Commands and results** - `cargo test --workspace --no-run` exited 0 and compiled the workspace test executables. - `cargo test -p xcl --lib gpu::tiling::tests:: -- --nocapture` exited 0 with 17 passed, 0 failed, 0 ignored, 0 skipped, and 681 filtered out. The harness finished in 27.78 s. - `cargo test --release -p xcl --test tiling_perf -- --ignored --nocapture` exited 0 with 1 opt-in benchmark passed, 0 failed, 0 ignored, and 0 skipped. **Observed behavior** - The new 2D and 3D tests matched the element-by-element reference byte for byte on the cases exercised, including mip tails, array slices, swizzles, and truncated sources. - The short-slice test matched the reference's panic behavior and the bytes written before a panic. The expected caught panics appear in the uncaptured output. - The release benchmark completed all eight cases. Head-only median samples in ms were 23.90 detile / 11.72 tile for RGBA8 3840x2160 64KB_D and 14.36 detile / 11.83 tile for RGBA8 256x256x64 4KB_S thick. **Not tested** The full GPU workspace suite, game smoke runs, and a performance comparison against `main` were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr901-focused.log` and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 09:41 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 09:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/901#issuecomment-7158679814) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
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/901/head:github-bot/gh-901'
git switch 'github-bot/gh-901'

Merge

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