Skip to content

Shaders: precompile the compute passes of console mesh shaders - #2246

Open
MacieGx wants to merge 1 commit into
xcl-dev:mainfrom
MacieGx:shaders/precompile-mesh-compute
Open

MacieGx wants to merge 1 commit into
xcl-dev:mainfrom
MacieGx:shaders/precompile-mesh-compute

Conversation

@MacieGx

@MacieGx MacieGx commented Nov 25, 2026

Copy link
Copy Markdown

xcl shaders --precompile --pipelines built driver blobs for console compute shaders only. The compute pass of a console mesh shader (the two-pass path, real::finish_two_pass) was always compiled by the driver in the game. In the newer retail title (#505), whose world is drawn by thousands of console mesh pipelines, that was 3–9 s per pass on an RTX 5080, one at a time, while its draws were skipped. With this, --precompile makes those passes too and keeps their blobs where the runtime looks for them. Part of #505.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs: console_mesh_in(blob, ps, split, windows), the body of console_mesh with the memory windows passed in; console_mesh calls it with mem_windows(), so the runtime is unchanged.
  • crates/xcl/src/shaders.rs:
    • --precompile treats an MS the runtime builds in two passes like a CS. It translates it through console_mesh_in with no pixel shader (the compute pass does not depend on it, so its DXIL is the runtime's).
    • With --pipelines it builds the pass with XCL's ABI root signature and the pass's static samplers, through the existing make_with_cache_path (so XCL_PIPELINE_THREADS and XCL_PIPELINE_MAX_KB apply), and keeps the blob at real::two_pass_compute_blob_path.
    • --only ms builds those alone. --sample N stops after the first N programs --only lets through.
    • --used-only passes MSs over: a mesh pipeline's used key includes its PS, so the MS alone does not identify it.
  • crates/xcl/src/hle/d3d12x/real.rs: two_pass_compute_blob_path is the file finish_two_pass reads. The pass's blob is now looked up before the huge-pipeline gate, and a pass with a blob no longer counts towards the gate's size (it is made in milliseconds).
  • README.md: the --only ms line.
  • Test shaders::tests::an_ms_compute_pass_is_precompiled_under_the_runtimes_key. For no split / 4 windows, split / 4 windows and split / heap windows: the precompiled DXIL and static samplers equal what the runtime builds with a PS, and the blob path equals two_pass_compute_blob_path. console_mesh with mem_windows() gives the same pass as console_mesh_in, and a CS and a PS are not taken for mesh shaders.
  • 149 lines added and 28 removed.

Tested

  • NVIDIA GeForce RTX 5080 (driver 621.24 = 32.0.16.2124), AMD Ryzen 7 5800X3D, 32 GB, Windows 11 Pro 10.0.26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, release. On 8d49cf1 (this PR on main c9a5d58 before the README line was added; the head 696a222 differs only in README.md).
  • cargo test --release -p xcl --lib shaders::: 10 passed, 0 failed, 0 ignored (the new test passed; pso_measurement_compiles_an_exact_synthetic_record SKIPPED: the driver cache cannot be disabled without Developer Mode).
  • cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1224 passed, 6 failed, 46 ignored.
    • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState: out of memory (0x8007000E)) fail on main as well.
    • gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator and hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa fail the same way, run alone, on a clean c9a5d58 without this change.
  • SKIPPED (the same as on main): 18 "no wave64" (recomp::lower::tests ×4, recomp::lower_dxil::tests ×12, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), 3 "refused by the per-lane form", heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record.
  • xcl shaders <the title's shaders.rpf> --precompile --only ms --pipelines --sample 50: 50 compiled, 0 errors, 50 pipelines made, 0 refused, 8.1 s.
  • On a local branch that adds other open PRs and local work to main (where the title reaches its world), the same change made 9282 compute passes in 25 min (--only ms --pipelines). There, blobs that game runs had kept were found by the precompile under the same files (11 of the first 50), which shows that the two keys agree.

Regression run

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1383 (PresentX 1383)
presents per 2 s (last 3): 35 52 56
device removals: 0
crashes: 0
peak commit: 19703 MB

this PR:

xcl-smoke v1
commit: 696a222a597cfe1f3e86db9d0c2b732f8177156f
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1460 (PresentX 1461)
presents per 2 s (last 3): 54 37 7
device removals: 0
crashes: 0
peak commit: 20183 MB

Not tested

  • AMD and Intel GPUs; a debug build; a full --only ms run on main itself.
  • The smoke runs cover the title's first 60 s, before its world, where few mesh pipelines are built; they check that nothing regresses, not the gain.
  • The pass-through mesh pipeline (the title's PS and state) is still built in the game; it cannot be precompiled from the pack.
  • GS two-pass pipelines are not precompiled.

AI use

  • Claude Code. Claude Opus 5.5 coordinated, ran the regression runs, reviewed the change and wrote this description. A Claude Opus 5.5 subagent wrote the change and its test on a lab branch, and another ported it to main and ran the whole suite and the sample precompile.

🤖 Generated with Claude Code

A retail title's world has thousands of console mesh pipelines. The
runtime builds each as two passes (`real::finish_two_pass`): a compute
pass translated from the console MS and a pass-through mesh pipeline.
`xcl shaders --precompile --pipelines` made only the CS pipelines, so
every compute pass was compiled by the driver in-game, 3-9 s each.

`--precompile` now treats an MS the runtime builds in two passes like a
CS: it translates it through `pso::console_mesh_in` (the runtime's
`console_mesh` with the memory windows given) with no pixel shader -
the compute pass does not depend on it - so the DXIL is the one the
runtime makes. With `--pipelines` the pass is built with XCL's ABI root
signature and the pass's static samplers, under `XCL_PIPELINE_THREADS`
and the `XCL_PIPELINE_MAX_KB` cap, and its driver blob is kept under
`real::two_pass_compute_blob_path` (DXIL alone, no flags), the file
`finish_two_pass` now reads through the same helper. `--only ms` builds
those alone; `--sample N` stops after the first N programs `--only`
lets through. `--used-only` passes the MSs over: a mesh pipeline's key
includes its PS, so the MS alone does not identify it.

In `finish_two_pass` the compute pass's blob is looked up before the
huge-pipeline gate, and a pass with a blob no longer counts towards the
gate's size: with a blob it is made in milliseconds.

Not covered: the pass-through mesh pipeline depends on the title's PS
and its blend / raster / depth state and target formats, so it cannot
be precompiled and is still built by the runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@itsSio

itsSio commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Tested

Independent debug check on clean 696a222a597cfe1f3e86db9d0c2b732f8177156f. Windows 11 Pro 26200 on both PCs, x64 MSVC, unoptimized dev/test profiles with debug info off. cargo build --workspace --locked passed on both. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture exited 101 on both:

GPU / driver CPU, RAM, toolchain Passed / failed / ignored Runtime SKIPPED
RTX 5080 / 32.0.16.1088 Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC/DXIL 1.9.2609.5 1228 / 2 / 46 25
RTX 2080 SUPER / 32.0.16.1088 Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC/DXIL 1.8.2502.11 1228 / 2 / 46 27

Both logged 20 native-wave64 skips, three per-lane f16/f32 refusals, unavailable driver-cache control and unavailable heap windows. The RTX 2080 SUPER also logged two tests skipped for the missing D3D12 debug layer.

cargo test -p xcl --lib --locked shaders::tests:: -- --test-threads=1 --nocapture gave 8 passed / 0 failed / 0 ignored on each RTX card and on the Radeon RDNA2 iGPU (driver 32.0.21043.5001, Ryzen 7 system). This included an_ms_compute_pass_is_precompiled_under_the_runtimes_key. On each adapter, the driver-cache measurement logged one runtime SKIPPED, and the optional pack test did no work because XCL_SAMPLE_RPF was unset.

The two workspace failures were rerouted_disk_entries_follow_the_direct_translator (68 instead of 1) and pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa (format 85, got 28). Both match the previously independently reproduced assertions on 5478c4a7 (evidence); that was not an exact-parent comparison for this PR. The workspace results above remain failing.

Not tested

Retail smoke, a full --only ms pack run, full AMD workspace, Intel, or performance.

AI use

Ran via Samaritan:

  • OpenCode with OpenAI GPT-6.2 Sol (openai/gpt-6.2-sol): ran the independent checks, verified logs on both PCs and wrote this report. No subagents contributed to this check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants