Skip to content

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

Draft
oishigeso wants to merge 2 commits into
xcl-dev:mainfrom
oishigeso:detile-2-gpu
Draft

oishigeso wants to merge 2 commits into
xcl-dev:mainfrom
oishigeso:detile-2-gpu

Conversation

@oishigeso

@oishigeso oishigeso commented Nov 24, 2026 •

Copy link
Copy Markdown

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

suppai-ringo and others added 2 commits November 24, 2026 06:44
…in one go

RGBA8 2048x2048 on the console pipe config: 22 ms -> 10 ms; BC 8/16 B ~10%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>

@gut0to gut0to left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focused detile tests are useful. CONTRIBUTING.md also requires the full workspace suite to run on a GPU, with pass/fail/ignored counts and skipped-test names. This description reports only the detile tests. Please add the full-suite result before merge. AI-assisted review; I checked the Tested section against the guide.

@DavidM1911

Copy link
Copy Markdown
Contributor

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!

@ZekkJJ

ZekkJJ commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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.

@LANgmas

LANgmas commented Nov 25, 2026

Copy link
Copy Markdown

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.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants