Shaders: make static-sampler root signatures first, in one order #2326
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2326
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2326"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@CowboyBingus on GitHub · 2026-11-25 14:35 UTC · original
CowboyBingus:driver-cache-sampler-order→main· +194 −7 · 4 files · 1 commits · draftxcl shaders --precompile --pipelinesnow writes the static-sampler sets of the compute programs it translates (and those of an earlier file), sorted, tosampler-sets.txtin 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 main689f2dbplus 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, andsampler_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_signatureswrites the file (this pass's sets plus those of an earlier file) and makes those root signatures first;make_allthen makes the pipelines onXCL_PIPELINE_THREADSthreads. GPU test: the pass writes the file and makes the root signatures in the same order assampler_set_signatures, the function the runtime calls.crates/xcl/src/hle/d3d12x/real.rs:make_sampler_set_signaturesat device creation puts them inABI_RS_SAMPLERS;abi_rs_forusessampler_key.README.md: the file and what it does.Tested
d65ae60on main06c9f55.cargo build --workspace(debug) andcargo build --release -p xclbuild.cargo test -p xcl --lib sampler_set -- --nocapture: 2 passed, 0 failed, 0 ignored; noSKIPPEDline in the output (runner::skip_testprints one when there is no D3D12 device).cargo test -p xcl --lib -- shaders:: recomp::pso::: 31 passed, 0 failed, 1 ignored.cargo test -p xcl --lib -- pipeline_cap_tests finish_two_pass: 3 passed, 0 failed, 0 ignored.cargo test --workspace --no-fail-fast -- --test-threads=4: 23test resultlines, 1,262 passed, 5 failed, 46 ignored.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0to_3(CreateComputePipelineState: Not enough memory resources are available to complete this operation. (0x8007000E), seeds 70, 545, 1019, 1507) andhle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory(assertion atkernelx.rs:2328, left 0, right 1).06c9f55:cargo test -p xcl --lib -- fuzz_validate_and_gpu xmem_virtual_query_marks_cpu_readable_memory: 0 passed, 5 failed.SKIPPEDlines: 21no wave64; 3 inlower_dxil::testsper-lane forms,refused (unsupported V_MUL_F16 …),(unsupported V_PK_MUL_F16 …)and(unsupported V_CVT_F16_F32 …); 1no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form).exe\xcl.exe(sha256 3be124…), which the session log records as built after commite723784(this change on main1a0bbe3). Frome723784(parent1a0bbe3) to the head (parent06c9f55),git range-diffshows: the commit message, the README bullet, one doc comment inpso.rs, one context line inpso.rsthat main changed, and the GPU test setting thedispatch_chainfield that #2080 added toCompiled.exe\xcl.exe, sha256 3be124…) at one exe path, built after commite723784per the session log, withXCL_PSO_DISK_CACHE=0(XCL's blob files off),XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1and a newXCL_DXIL_CACHEfolder in all three:xcl shaders <pack> --precompile --only cs --pipelineswithXCL_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.sampler-sets.txthad the same SHA-256 after both passes.85 static-sampler root signatures made firstlogged 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 graphicsdriver compile finishline, 2,566 ms. The last 2-s activity window with presents is logged at 62.0 s.mainfor comparison: release build (sha256 ca17a157…), built from1a0bbe3per the session log, at its own exe path,XCL_PSO_DISK_CACHE=0,XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1, its own newXCL_DXIL_CACHEfolder holding a copy of theused-pipelines.txtwritten 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-onlywithXCL_PIPELINE_THREADS=8: compiled 445; 2,244 compute programs passed over; pipelines made 445, refused 0; wall 610.2 s.driver compile finishlines 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.XCL_PSO_DISK_CACHEat its default (on): the sameexe\xcl.exeand DXIL cache folder as the PR's runs above, other settings as there.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.driver compile startlines: 207 withdriver blob supplied, 2 withdriver blob absent. 14 graphicsdriver compile finishlines, 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:this PR's head
d65ae60:Both smoke runs used the default DXIL cache (no
XCL_DXIL_CACHE); neither log has astatic-sampler root signaturesline.Not tested
mainwithXCL_PSO_DISK_CACHEat its default (on); its full-pack prebuild ended with exit code -1 after 1,692.4 s.mainafter a full-pack prebuild with blobs off (it was compared after a--used-onlyprebuild).d65ae60(only the smoke run above).AI use
🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-25 14:39 UTC · original
Independent Radeon and RTX 5090 sampler-order check of
d65ae604ba81ee66132028b96c4e4a8dffd3565f.Tested
cargo test --locked -p xcl --lib sampler_set -- --nocapture --test-threads=1withXCL_ADAPTER=AMD RadeonandXCL_ADAPTER=NVIDIA GeForce RTX 5090in separate processes. Both gave 2 passed, 0 failed, 0 ignored and no skips.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 on GitHub · 2026-11-25 14:40 UTC · original
@nnonno91 thanks for running the tests on both cards.
AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@SlopTart on GitHub · 2026-11-25 14:44 UTC · original
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 targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (--release --locked,--test-threads=2): 142 passed / 3 failed / 1 ignored, identical to plainorigin/mainon this rig (rig's known baseline: fuzz seed 1003 of #2115,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed). No delta with the root-signature ordering change in place.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 on GitHub · 2026-11-25 14:45 UTC · original
@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_orderandprebuild_and_runtime_make_the_sampler_set_root_signatures_in_one_order. Neither name starts withgpu_, so that filter skips them;cargo test -p xcl --lib sampler_setruns both.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@Gevroska on GitHub · 2026-11-25 17:04 UTC · original
I found a COM reference leak on
d65ae604ifsampler-sets.txtcontains the same valid sampler set twice. The normal writer deduplicates its output, but the reader accepts both lines.On the second entry,
or_insert(rs.into_raw() as usize)evaluatesinto_raw()even though the key is already occupied. The map keeps the first root signature, and nothing owns the second raw reference. Usingor_insert_with(|| rs.into_raw() as usize)would transfer ownership only on insertion and let the duplicatersdrop normally.I traced this in the source. My CPU fixtures covered other registry cases, and I didn’t measure native COM reference counts. I used Codex GPT-6.2 Sol for the investigation and a separate GPT-6.2 Sol agent for independent source review.
I reviewed and approved this comment before posting.
@DavidM1911 on GitHub · 2026-11-25 18:04 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
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.Merge
Merge the changes and update on Forgejo.