D3D12.X: process 2D texture tiling in contiguous block runs #2820

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

@⁠KOLESNiii on GitHub · 2026-11-26 14:29 UTC · original
KOLESNiii:d3d12x-tiling-block-runs → main · +321 −62 · 1 files · 1 commits · open

Part of #1833. This is T1 from the extraction plan in #2787. It takes b81ac2eb from #2778 (bmjask), unchanged. That commit adapts raylitebull's 032c661a block-slab algorithm.

CPU texture tiling and detiling in gpu/tiling.rs went through swizzled 2D textures one element at a time and worked out each element's block position again. For each GFX10 layout, this caches the longest horizontal run that is provably contiguous, works on one 4 KiB / 64 KiB block at a time, and copies whole runs in one go. It keeps the element-by-element bounds checks for a truncated source. Low base-swizzle bits make the runs shorter. Thick 3D single-slice helpers keep their existing path. The persistent detile workers (6dd9d53f) are not included.

What is in it

  • D3D12.X: process 2D texture tiling in contiguous block runs (crates/xcl/src/gpu/tiling.rs), cherry-picked with -x from b81ac2eb. Its two new tests compare tiled and detiled output with the element-by-element path, including base XOR.

Tested

  • NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, rustc 1.100.0, debug tests and a release smoke run
  • cargo test --workspace -- --test-threads=4 on 065f31bb: 1437 passed, 0 failed, 47 ignored
  • 25 SKIPPED on this adapter: 24 recompiler GPU tests with no wave64 (or the wave32 per-lane form refused), and heap_window_out_of_memory_falls_back_to_the_switch_form with no heap windows
  • Byte parity and timing: retrope13 measured this commit on main b49be183 (RTX 4060 Laptop, i5-14500HX, release) in #2787. Output checksums were identical in all 8 cases. 1920×1080 R8 mode 5 detile went from 18.75 to 0.59 ms. 2048×2048 RGBA8 mode 10 detile went from 40.14 to 5.48 ms. 2048×2048 BC7 detile went from 2.84 to 1.11 ms. I did not repeat that benchmark.

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1480 (PresentX 1480)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17754 MB

This PR:

xcl-smoke v1
commit: 065f31bbcd08b891af2b144d045feecd4a04fcd7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1414 (PresentX 1414)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17752 MB

Not tested

  • How much this changes world-load time on the retail title. The 60 s smoke run is a regression check only, and I did not measure the time spent detiling during it.
  • AMD and Intel GPUs. The 47 ignored tests.

AI use

  • Claude Code (Claude Opus 5.5) chose this item from #2787, cherry-picked it, ran the tests and smoke runs, and wrote this description. The source commit's own message names the tools that wrote it (Codex, Antigravity).

🤖 Generated with Claude Code

**@⁠KOLESNiii** on GitHub · 2026-11-26 14:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2820) `KOLESNiii:d3d12x-tiling-block-runs` → `main` · +321 −62 · 1 files · 1 commits · open Part of #1833. This is T1 from the extraction plan in #2787. It takes `b81ac2eb` from #2778 (bmjask), unchanged. That commit adapts raylitebull's `032c661a` block-slab algorithm. CPU texture tiling and detiling in `gpu/tiling.rs` went through swizzled 2D textures one element at a time and worked out each element's block position again. For each GFX10 layout, this caches the longest horizontal run that is provably contiguous, works on one 4 KiB / 64 KiB block at a time, and copies whole runs in one go. It keeps the element-by-element bounds checks for a truncated source. Low base-swizzle bits make the runs shorter. Thick 3D single-slice helpers keep their existing path. The persistent detile workers (`6dd9d53f`) are not included. **What is in it** - `D3D12.X: process 2D texture tiling in contiguous block runs` (`crates/xcl/src/gpu/tiling.rs`), cherry-picked with `-x` from `b81ac2eb`. Its two new tests compare tiled and detiled output with the element-by-element path, including base XOR. **Tested** - NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, rustc 1.100.0, debug tests and a release smoke run - `cargo test --workspace -- --test-threads=4` on `065f31bb`: 1437 passed, 0 failed, 47 ignored - 25 `SKIPPED` on this adapter: 24 recompiler GPU tests with `no wave64` (or the wave32 per-lane form refused), and `heap_window_out_of_memory_falls_back_to_the_switch_form` with `no heap windows` - Byte parity and timing: retrope13 measured this commit on `main` `b49be183` (RTX 4060 Laptop, i5-14500HX, release) [in #2787](https://git.gtahub.st/github/xcl-dev--xcl/issues/2787). Output checksums were identical in all 8 cases. 1920×1080 R8 mode 5 detile went from 18.75 to 0.59 ms. 2048×2048 RGBA8 mode 10 detile went from 40.14 to 5.48 ms. 2048×2048 BC7 detile went from 2.84 to 1.11 ms. I did not repeat that benchmark. **Regression run** `main`: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1480 (PresentX 1480) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17754 MB ``` This PR: ``` xcl-smoke v1 commit: 065f31bbcd08b891af2b144d045feecd4a04fcd7 gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1414 (PresentX 1414) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17752 MB ``` **Not tested** - How much this changes world-load time on the retail title. The 60 s smoke run is a regression check only, and I did not measure the time spent detiling during it. - AMD and Intel GPUs. The 47 ignored tests. **AI use** - Claude Code (Claude Opus 5.5) chose this item from #2787, cherry-picked it, ran the tests and smoke runs, and wrote this description. The source commit's own message names the tools that wrote it (Codex, Antigravity). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The existing row-factorized detiler still visited swizzled textures one element at a time and recalculated block placement for every element. Large CPU-written textures therefore consumed milliseconds on the submit path even after persistent detile workers.

Adapt raylitebull's 032c661a block-slab algorithm: cache the largest provably contiguous horizontal run for each immutable GFX10 layout, keep one 4 KiB/64 KiB block hot at a time, bulk-copy complete runs, and retain element-wise bounds checks for a truncated source. Low-bit base swizzles shorten runs safely; thick 3D single-slice helpers retain their former path.

On this AMD EPYC 7R13 Linux host, an isolated release benchmark against 032c661a's parent reduced 1920x1080 R8 mode-5 detile from 8.8-10.3 ms to 0.76-0.87 ms and tile from 28-31 ms to 0.64-0.78 ms. A 2048x2048 RGBA8 mode-10 detile fell from 28-31 ms to 9.7-11.8 ms and tile from 59-67 ms to 5.8-6.9 ms.

All 17 isolated pure tiling tests passed. The Windows GNU library/test cross-check passed with the existing warnings; Windows MSVC, GPU, and smoke tests were unavailable.

Source algorithm: 032c661a by raylitebull, assisted by Antigravity (Gemini 4 Neon High).

Assisted-by: Codex (GPT-5.6-sol)
(cherry picked from commit b81ac2ebfb)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:31:05 +00:00
This pull request can be merged automatically.
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/2820/head:github-bot/gh-2820'
git switch 'github-bot/gh-2820'

Merge

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