Skip to content

Shaders: make static-sampler root signatures first, in one order - #2326

Draft
CowboyBingus wants to merge 1 commit into
xcl-dev:mainfrom
CowboyBingus:driver-cache-sampler-order
Draft

CowboyBingus wants to merge 1 commit into
xcl-dev:mainfrom
CowboyBingus:driver-cache-sampler-order

Conversation

@CowboyBingus

@CowboyBingus CowboyBingus commented Nov 25, 2026 •

Copy link
Copy Markdown

xcl shaders --precompile --pipelines now writes the static-sampler sets of the compute programs it translates (and those of an earlier file), sorted, to sampler-sets.txt in the DXIL cache, and makes their root signatures before any pipeline, in the file's order. At device creation the runtime makes the same root signatures, in the same order, from that file and uses them for every pipeline with one of these sets. Part of #2088 (plan in this comment).

Why: measured on an RTX 5070 Ti with XCL's blob files off (XCL_PSO_DISK_CACHE=0), with an earlier local version of this change (XCL_SAMPLER_REGISTRY=<file>, on main 689f2db plus three other PRs and local changes, largest-first pipeline order). After a full prebuild and two title runs that all made these root signatures in one order, two prebuilds were each stopped early. With that order, six compute pipelines with three static samplers took 14.9 to 33.9 ms each; with the reverse order, the same six took 27.9 to 73.2 s each (the only 6 creates that run logged before its 150 s limit).

Related: #1420 (XCL's blob file name by sampler state, a different problem). #2290 turns more S# words into static samplers: the sets in the file are taken from the programs each prebuild translates, and a set that is not in the file is still made when a pipeline first needs it, as before.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs: SAMPLER_SETS_FILE, sampler_key, sampler_sets_text (sorted, each set once), parse_sampler_sets, and sampler_set_signatures, which makes the file's root signatures in file order. Unit test of the writer and the reader.
  • crates/xcl/src/shaders.rs: with --pipelines, the pipelines are made after all programs are translated. Pipelines::first_signatures writes the file (this pass's sets plus those of an earlier file) and makes those root signatures first; make_all then makes the pipelines on XCL_PIPELINE_THREADS threads. GPU test: the pass writes the file and makes the root signatures in the same order as sampler_set_signatures, the function the runtime calls.
  • crates/xcl/src/hle/d3d12x/real.rs: make_sampler_set_signatures at device creation puts them in ABI_RS_SAMPLERS; abi_rs_for uses sampler_key.
  • README.md: the file and what it does.

Tested

  • NVIDIA GeForce RTX 5070 Ti, driver 621.24; AMD Ryzen 7 9800X3D; Windows 10.0.26300.9974; rustc 1.91.1. Head d65ae60 on main 06c9f55.
  • On the head: cargo build --workspace (debug) and cargo build --release -p xcl build.
  • On the head: cargo test -p xcl --lib sampler_set -- --nocapture: 2 passed, 0 failed, 0 ignored; no SKIPPED line in the output (runner::skip_test prints one when there is no D3D12 device).
  • On the head: cargo test -p xcl --lib -- shaders:: recomp::pso::: 31 passed, 0 failed, 1 ignored.
  • On the head: cargo test -p xcl --lib -- pipeline_cap_tests finish_two_pass: 3 passed, 0 failed, 0 ignored.
  • On the head, clean tree: cargo test --workspace --no-fail-fast -- --test-threads=4: 23 test result lines, 1,262 passed, 5 failed, 46 ignored.
    • Failed: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 to _3 (CreateComputePipelineState: Not enough memory resources are available to complete this operation. (0x8007000E), seeds 70, 545, 1019, 1507) and hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory (assertion at kernelx.rs:2328, left 0, right 1).
    • The same 5 tests fail with the same messages on main 06c9f55: cargo test -p xcl --lib -- fuzz_validate_and_gpu xmem_virtual_query_marks_cpu_readable_memory: 0 passed, 5 failed.
    • 25 SKIPPED lines: 21 no wave64; 3 in lower_dxil::tests per-lane forms, refused (unsupported V_MUL_F16 …), (unsupported V_PK_MUL_F16 …) and (unsupported V_CVT_F16_F32 …); 1 no heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form).
  • The measurements below were made with exe\xcl.exe (sha256 3be124…), which the session log records as built after commit e723784 (this change on main 1a0bbe3). From e723784 (parent 1a0bbe3) to the head (parent 06c9f55), git range-diff shows: the commit message, the README bullet, one doc comment in pso.rs, one context line in pso.rs that main changed, and the GPU test setting the dispatch_chain field that Recompiler: split large direct compute pipelines at CFG edges #2080 added to Compiled.
  • The retail title's shader pack and the title, release build (exe\xcl.exe, sha256 3be124…) at one exe path, built after commit e723784 per the session log, with XCL_PSO_DISK_CACHE=0 (XCL's blob files off), XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1 and a new XCL_DXIL_CACHE folder in all three:
    • xcl shaders <pack> --precompile --only cs --pipelines with XCL_PIPELINE_THREADS=8: compiled 2,689, errors 0; pipelines made 2,689, refused 0; 85 static-sampler root signatures made first; wall 2,945.8 s.
    • The same command again: pipelines made 2,689, refused 0; 85 made first; wall 6.4 s. sampler-sets.txt had the same SHA-256 after both passes.
    • Then a 240 s title run with scripted A presses at 14 to 140 s: 85 static-sampler root signatures made first logged at 0.470 s. 474 compute pipeline creates logged; 2 took 1 s or more (5,278 ms and 4,791 ms, started at 64.9 s and 70.8 s). The translation-cache files of both programs were written during the title run, not during the prebuilds (31 compute translation files were written during the run). 1 graphics driver compile finish line, 2,566 ms. The last 2-s activity window with presents is logged at 62.0 s.
  • main for comparison: release build (sha256 ca17a157…), built from 1a0bbe3 per the session log, at its own exe path, XCL_PSO_DISK_CACHE=0, XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, its own new XCL_DXIL_CACHE folder holding a copy of the used-pipelines.txt written by the PR's title run above. Earlier, a full-pack prebuild with XCL's blob files on, at the same exe path and into another DXIL cache folder, ended with exit code -1 after 1,692.4 s without a summary line (last progress line: 1,575 pipelines made, 0 refused).
    • xcl shaders <pack> --precompile --only cs --pipelines --used-only with XCL_PIPELINE_THREADS=8: compiled 445; 2,244 compute programs passed over; pipelines made 445, refused 0; wall 610.2 s.
    • Then a 240 s title run with the same settings and presses as the PR's run above: 395 compute pipeline creates logged, 82 of them 1 s or more (max 22,164 ms). Of the 47 compute driver compile finish lines of 1 s or more, 42 are programs whose translation-cache files the prebuild wrote. The last 2-s activity window with presents is logged at 70.1 s.
  • This PR with XCL_PSO_DISK_CACHE at its default (on): the same exe\xcl.exe and DXIL cache folder as the PR's runs above, other settings as there.
    • The prebuild command again: pipelines made 2,689, refused 0; pipelines loaded from the driver cache 88 (XCL's blob files; the folder that holds them was created during this pass); 85 static-sampler root signatures made first; wall 10.0 s.
    • Then a 240 s title run with the same presses: 679 compute pipeline creates logged, 0 of them 1 s or more (max 60 ms). 209 compute driver compile start lines: 207 with driver blob supplied, 2 with driver blob absent. 14 graphics driver compile finish lines, 11 of them 1 s or more (max 10,179 ms). The last 2-s activity window with presents is logged at 72.1 s.

Regression run

main 1a0bbe3:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: NVIDIA GeForce RTX 5070 Ti
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17507 MB

this PR's head d65ae60:

xcl-smoke v1
commit: d65ae604ba81ee66132028b96c4e4a8dffd3565f
gpu: NVIDIA GeForce RTX 5070 Ti
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1522 (PresentX 1522)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17516 MB

Both smoke runs used the default DXIL cache (no XCL_DXIL_CACHE); neither log has a static-sampler root signatures line.

Not tested

  • A title run of main with XCL_PSO_DISK_CACHE at its default (on); its full-pack prebuild ended with exit code -1 after 1,692.4 s.
  • main after a full-pack prebuild with blobs off (it was compared after a --used-only prebuild).
  • No prebuild or title run on the head d65ae60 (only the smoke run above).
  • AMD GPUs, other NVIDIA cards and drivers.
  • Graphics pipelines: their static-sampler sets (a pixel shader's after its vertex shader's) are not in the file.
  • Why the order of root signature creation matters to the cache below XCL.

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests and this description, and ran the builds, tests and measurements.

🤖 Generated with Claude Code

`xcl shaders --precompile --pipelines` now translates the compute
programs first, writes the distinct static-sampler sets of the programs
it translated (and those of an earlier file), sorted, to
`sampler-sets.txt` in the DXIL cache, and makes those root signatures
before any pipeline, in the file's order. At device creation the runtime
reads the same file from its DXIL cache, makes the same root signatures
in the same order, and keeps them in `ABI_RS_SAMPLERS`, so pipelines
with one of these sets use them. A set that is not in the file is still
made when a pipeline first needs it.

Measured on an RTX 5070 Ti with XCL's blob files off
(XCL_PSO_DISK_CACHE=0), with an earlier local version of this change
(XCL_SAMPLER_REGISTRY=<file>, on main 689f2db plus three other PRs and
local changes, largest-first pipeline order): after a full prebuild and
two title runs that all made these root signatures in one order, two
prebuilds were each stopped early. With that order, six compute
pipelines with three static samplers took 14.9-33.9 ms each; with the
reverse order, the same six took 27.9-73.2 s each.

Part of xcl-dev#2088.

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

Copy link
Copy Markdown

Independent Radeon and RTX 5090 sampler-order check of d65ae604ba81ee66132028b96c4e4a8dffd3565f.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62 and RTX 5090 driver 32.0.16.1742.
  • cargo test --locked -p xcl --lib sampler_set -- --nocapture --test-threads=1 with XCL_ADAPTER=AMD Radeon and XCL_ADAPTER=NVIDIA GeForce RTX 5090 in separate processes. Both gave 2 passed, 0 failed, 0 ignored and no skips.
  • The tests checked duplicate elimination, preservation of earlier sets when a later prebuild sees fewer programs, and matching prebuild/runtime root-signature order for the same three sampler sets.

Not tested

Cold driver-cache timings, retail shader packs, retail smoke and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.

@CowboyBingus

Copy link
Copy Markdown
Author

@nnonno91 thanks for running the tests on both cards.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

No new tests in the PR; the suite result is the whole data point: nothing regresses on the Wine lane with the static-sampler sets made first.

Not tested: retail titles (no title data on this lane, counts only).

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

@CowboyBingus

Copy link
Copy Markdown
Author

@SlopTart thanks for the Wine/RADV run. One correction: the PR does add two tests, sampler_sets_are_written_sorted_once_and_read_back_in_file_order and prebuild_and_runtime_make_the_sampler_set_root_signatures_in_one_order. Neither name starts with gpu_, so that filter skips them; cargo test -p xcl --lib sampler_set runs both.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

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.

3 participants