D3D12.X: title textures are detiled on the GPU #1513

Open
github-bot wants to merge 2 commits from github-bot/gh-1513 into main AGit
Owner

@⁠oishigeso on GitHub · 2026-11-24 17:10 UTC · original
oishigeso:detile-2-gpu → main · +553 −26 · 5 files · 2 commits · draft

Part 2 of 2 for #1511, stacked on #1512 (only the top commit belongs here). The tiled bytes and the layout's tables (only the entries the texture reaches) go to the upload buffer as they are. A compute shader (detile_gpu, DXC cs_6_0, root constants + root SRV / UAV) writes each subresource's rows into the uploader's scratch UAV buffer at its GetCopyableFootprints place, and the copies into the texture read from there. Same formula as Layout::offset_z; reads out of range give 0.

The CPU path stays for XCL_GPU_DETILE=0, without DXC or the pipeline, for a texture the plan cannot take, and while tracing frames (that looks at the detiled bytes).

What is in it

  • crates/xcl/src/gpu/detile_gpu.rs (new): the plan, the shader and its pipeline
  • crates/xcl/src/gpu/texture.rs: upload_batch_with dispatches it before the copies
  • crates/xcl/src/hle/d3d12x/title_textures.rs: plan_gpu per texture, the rest on the CPU as before
  • crates/xcl/src/gpu/tiling.rs: Layout::tables, the offset tables for the shader; crates/xcl/src/gpu/mod.rs: the module
  • Test gpu_detile_matches_the_cpu: 78 textures (every 2D mode × element size, mips, 2 slices, tiled bytes cut short, 3D) read back byte-identical against the CPU detile

494 changed lines, over the ~400 target: about half is the new module and its test, and the shader, its plan and the upload change don't work apart.

Tested

  • AMD Radeon RX 6700 XT (driver 32.0.21030.2001), Ryzen 5 3600, Windows 10 Pro 19045, rustc 1.100.0, release
  • cargo test -p xcl --lib detile -- --test-threads=1: 7 passed, 0 failed (detile_level_runs_match_elements, detile_level_matches_element_by_element, linear_levels_detile_by_rows_as_by_elements, tile_then_detile_round_trips_with_partial_blocks, gpu_detile_matches_the_cpu, a_batch_detiled_on_several_threads_matches_one_thread, retail_ttpf_textures_detile_with_their_mip_chains). Run before the rebase onto 930e8b4, which had no conflicts
  • On in about 15 test runs of a retail title on this PC since it was written, the longest 20 min; an A/B with XCL_GPU_DETILE=0 showed no difference in memory

Regression run

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 6700 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 373 (PresentX 374)
presents per 2 s (last 3): 0 28 60
device removals: 0
crashes: 0
peak commit: 19259 MB

PR (this PR's head commit; the title is run through a folder named RetailTitle):

xcl-smoke v1
commit: 82bd5bc89e9388b2d5540f9c1354f73d8bc656a2
gpu: AMD Radeon RX 6700 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 577 (PresentX 577)
presents per 2 s (last 3): 0 30 60
device removals: 0
crashes: 0
peak commit: 19147 MB

Not tested

  • NVIDIA, Intel; Linux / Wine (vkd3d-proton)

AI use

  • Claude Code (Claude Opus 5.5) wrote the change, its test and this description, and ran the tests and runs above on my PC at my direction.

🤖 Generated with Claude Code

**@⁠oishigeso** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1513) `oishigeso:detile-2-gpu` → `main` · +553 −26 · 5 files · 2 commits · draft Part 2 of 2 for #1511, stacked on #1512 (only the top commit belongs here). The tiled bytes and the layout's tables (only the entries the texture reaches) go to the upload buffer as they are. A compute shader (`detile_gpu`, DXC `cs_6_0`, root constants + root SRV / UAV) writes each subresource's rows into the uploader's scratch UAV buffer at its `GetCopyableFootprints` place, and the copies into the texture read from there. Same formula as `Layout::offset_z`; reads out of range give 0. The CPU path stays for `XCL_GPU_DETILE=0`, without DXC or the pipeline, for a texture the plan cannot take, and while tracing frames (that looks at the detiled bytes). **What is in it** - `crates/xcl/src/gpu/detile_gpu.rs` (new): the plan, the shader and its pipeline - `crates/xcl/src/gpu/texture.rs`: `upload_batch_with` dispatches it before the copies - `crates/xcl/src/hle/d3d12x/title_textures.rs`: `plan_gpu` per texture, the rest on the CPU as before - `crates/xcl/src/gpu/tiling.rs`: `Layout::tables`, the offset tables for the shader; `crates/xcl/src/gpu/mod.rs`: the module - Test `gpu_detile_matches_the_cpu`: 78 textures (every 2D mode × element size, mips, 2 slices, tiled bytes cut short, 3D) read back byte-identical against the CPU detile 494 changed lines, over the ~400 target: about half is the new module and its test, and the shader, its plan and the upload change don't work apart. **Tested** - AMD Radeon RX 6700 XT (driver 32.0.21030.2001), Ryzen 5 3600, Windows 10 Pro 19045, rustc 1.100.0, release - `cargo test -p xcl --lib detile -- --test-threads=1`: 7 passed, 0 failed (`detile_level_runs_match_elements`, `detile_level_matches_element_by_element`, `linear_levels_detile_by_rows_as_by_elements`, `tile_then_detile_round_trips_with_partial_blocks`, `gpu_detile_matches_the_cpu`, `a_batch_detiled_on_several_threads_matches_one_thread`, `retail_ttpf_textures_detile_with_their_mip_chains`). Run before the rebase onto 930e8b4, which had no conflicts - On in about 15 test runs of a retail title on this PC since it was written, the longest 20 min; an A/B with `XCL_GPU_DETILE=0` showed no difference in memory **Regression run** main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: AMD Radeon RX 6700 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 373 (PresentX 374) presents per 2 s (last 3): 0 28 60 device removals: 0 crashes: 0 peak commit: 19259 MB ``` PR (this PR's head commit; the title is run through a folder named RetailTitle): ``` xcl-smoke v1 commit: 82bd5bc89e9388b2d5540f9c1354f73d8bc656a2 gpu: AMD Radeon RX 6700 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 577 (PresentX 577) presents per 2 s (last 3): 0 30 60 device removals: 0 crashes: 0 peak commit: 19147 MB ``` **Not tested** - NVIDIA, Intel; Linux / Wine (vkd3d-proton) **AI use** - Claude Code (Claude Opus 5.5) wrote the change, its test and this description, and ran the tests and runs above on my PC at my direction. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
RGBA8 2048x2048 on the console pipe config: 22 ms -> 10 ms; BC 8/16 B ~10%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tiled bytes and the layout's tables (only the entries the texture reaches) go to the
upload buffer as they are; a compute shader (detile_gpu, DXC cs_6_0, root constants + root
SRV/UAV) writes each subresource's rows into the uploader's scratch UAV buffer at its
GetCopyableFootprints place, and the copies into the texture read from there. Same formula
as Layout::offset_z, out-of-range reads as 0. CPU path kept: XCL_GPU_DETILE=0, no DXC or
pipeline, a texture the plan cannot take, and frame tracing.

Test: gpu_detile_matches_the_cpu - 78 textures (every 2D mode x element size, mips, 2 slices,
tiled bytes cut short, 3D) read back identical to the CPU detile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:02 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 18:53 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 18:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/1513#issuecomment-7141304428) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠ZekkJJ on GitHub · 2026-11-25 00:22 UTC · original

I’m profiling host-side texture upload memory on a 16 GiB Windows system with an RTX 4060 Laptop GPU. On main 80f4819, one retail upload needed 132.3 MiB of copy footprints. The synchronous uploader grew its mapped buffer from 128 MiB to 256 MiB while the previous buffer remained live. The two staging buffers and the 131.5 MiB of detiled output overlapped at 515.5 MiB. The 256 MiB buffer then stayed cached through loading artwork. These are ownership-counter measurements at the allocation sites.

@⁠oishigeso @⁠Cattn I’m considering a separate change in the synchronous Uploader::staging path. Keep the existing small size classes, round larger requests in 16 MiB steps, and release the previous buffer after its existing fence has completed and before allocating the replacement. Keep the upload batch and waits as they are. The intended scope is independent of GPU detiling and the in-flight allocator and staging lifetime in #455.

Does this overlap work you have underway, or is there a compatibility constraint in #1513 or #455 that I should account for? I’m validating an isolated experiment with readback and matched retail runs first.

AI use: Codex (GPT-6) instrumented and analyzed the local run.

**@⁠ZekkJJ** on GitHub · 2026-11-25 00:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1513#issuecomment-7148450201) I’m profiling host-side texture upload memory on a 16 GiB Windows system with an RTX 4060 Laptop GPU. On main `80f4819`, one retail upload needed 132.3 MiB of copy footprints. The synchronous uploader grew its mapped buffer from 128 MiB to 256 MiB while the previous buffer remained live. The two staging buffers and the 131.5 MiB of detiled output overlapped at 515.5 MiB. The 256 MiB buffer then stayed cached through loading artwork. These are ownership-counter measurements at the allocation sites. @⁠oishigeso @⁠Cattn I’m considering a separate change in the synchronous `Uploader::staging` path. Keep the existing small size classes, round larger requests in 16 MiB steps, and release the previous buffer after its existing fence has completed and before allocating the replacement. Keep the upload batch and waits as they are. The intended scope is independent of GPU detiling and the in-flight allocator and staging lifetime in #455. Does this overlap work you have underway, or is there a compatibility constraint in #1513 or #455 that I should account for? I’m validating an isolated experiment with readback and matched retail runs first. AI use: Codex (GPT-6) instrumented and analyzed the local run.
Author
Owner

@⁠LANgmas on GitHub · 2026-11-25 05:48 UTC · original

Independent dual-adapter validation — PR head 82bd5bc: PASS

NVIDIA RTX 3050 Laptop GPU

  • Focused gpu_detile_matches_the_cpu executed the actual GPU detile, dispatch and readback path.
  • Confirmed: GPU detile matched the CPU in 78 textures.
  • Full workspace via the repository test wrapper: 752 passed, 0 failed, 0 ignored.
  • SKIPPED: 2 expected wave64-only tests.
  • EXCLUDED: test_title_runs_and_game_folder_is_untouched (no retail title available).
  • Wrapper exit code: 0.

Intel Iris Xe

  • The same focused test executed on the real Intel D3D12 adapter.
  • Confirmed: GPU detile matched the CPU in 78 textures.

Test-selection note
The test helper's device() uses D3D12CreateDevice(NULL, ...) and does not honor XCL_ADAPTER. I initially observed the default Intel adapter even when setting XCL_ADAPTER=nvidia. For the NVIDIA run, I used temporary per-application Windows GPU preference steering; an independent adapter probe confirmed RTX 3050 selection. The temporary preference was removed after testing.

Limitations

  • No retail-title smoke test was performed.
  • The tests were run against the exact PR head, whose base (9e3831e) is behind current upstream main (6020a33). This is not a rebase or integration test against current main.
  • No performance improvement is claimed.

This adds independent RTX 3050 full-suite evidence and Intel Iris Xe GPU-detiling validation beyond the existing AMD and RTX 3060 Ti reports.

**@⁠LANgmas** on GitHub · 2026-11-25 05:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/1513#issuecomment-7154151203) Independent dual-adapter validation — PR head `82bd5bc`: PASS NVIDIA RTX 3050 Laptop GPU - Focused `gpu_detile_matches_the_cpu` executed the actual GPU detile, dispatch and readback path. - Confirmed: `GPU detile matched the CPU in 78 textures`. - Full workspace via the repository test wrapper: 752 passed, 0 failed, 0 ignored. - SKIPPED: 2 expected wave64-only tests. - EXCLUDED: `test_title_runs_and_game_folder_is_untouched` (no retail title available). - Wrapper exit code: 0. Intel Iris Xe - The same focused test executed on the real Intel D3D12 adapter. - Confirmed: `GPU detile matched the CPU in 78 textures`. Test-selection note The test helper's `device()` uses `D3D12CreateDevice(NULL, ...)` and does not honor `XCL_ADAPTER`. I initially observed the default Intel adapter even when setting `XCL_ADAPTER=nvidia`. For the NVIDIA run, I used temporary per-application Windows GPU preference steering; an independent adapter probe confirmed RTX 3050 selection. The temporary preference was removed after testing. Limitations - No retail-title smoke test was performed. - The tests were run against the exact PR head, whose base (`9e3831e`) is behind current upstream `main` (`6020a33`). This is not a rebase or integration test against current main. - No performance improvement is claimed. This adds independent RTX 3050 full-suite evidence and Intel Iris Xe GPU-detiling validation beyond the existing AMD and RTX 3060 Ti reports.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/title_textures.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1513/head:github-bot/gh-1513'
git switch 'github-bot/gh-1513'

Merge

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