xcl run: shader preparation in worker processes, only what earlier runs used; upstream main; sampler fix #2624
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!2624
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2624"
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?
@theaustinayers on GitHub · 2026-11-26 02:56 UTC · original
xcl-dev:shader-prep→nvidia-dev· +12724 −690 · 83 files · 178 commits · merged 2026-11-26 06:10 UTCBrings
nvidia-devup to upstream main (through #2371) and adds the faster shader preparation before a title starts.What is in it
b49be183, includes #2338, #174, #2371), with the fork's fixes kept.crates/xcl/src/shaders.rs): the stages are translated in the host; a pack's compute pipelines are built by worker processes, each on its own slice of the records. The driver builds about two pipelines at a time for one process, so one process stood for minutes on each stretch of large compute programs. Workers: logical processors less four, 3 GB of free commit each (XCL_PREPARE_WORKERS;1= one process as before). A worker that fails is logged and the title starts; a worker ends when the host does.shaders.rs,hle/d3d12x/pso_async.rs): a run keeps the shaders of the pipelines it uses inused-shaders.txtbeside the DXIL cache. With that list the preparation translates only those records, and the pipeline pass builds only the compute pipelines an earlier run used.XCL_PREPARE_ALL=1prepares every record.XCL_PREPARE=0skips preparation: the title builds what it uses as it goes.hle/d3d12x/present/preparation.rs): each pass has its own heading and count, a worker reports every record, the host logs progress every 5 s.gpu/recomp/mod.rs): an S# set before a branch or a loop is recognised as a static sampler after it. Before, those samples went through sampler-heap entry 0 (point, wrap, mip 0): banded gradients, stepped glows.XCL_ZERO_SAMPLER_LINEAR=1is a diagnostic for that entry.XCL_WAVE64_SPIN=1restores the counters).Tested
cargo test --release -p xcl --lib -- --test-threads=4atfbfac4d0: 1538 passed, 0 failed, 25 ignored; 59 tests that open the hardware GPU not run. The four tests added after it (the_shaders_of_a_used_set_are_kept_for_the_next_run,the_key_of_one_shader_is_the_key_of_a_set_of_it,preparation_workers_leave_two_processors_and_follow_the_commit_left,static_sampler_set_before_a_branch_is_a_constant_after_it) pass at the head.Not tested
AI use
🤖 Generated with Claude Code
a_new_list_takes_no_copy_scratch_of_an_earlier_one asserted while it held COPY_SCRATCH. When an assert failed, the lock was poisoned; the test's command list was then dropped during unwinding, its Release hook (real::cl_release -> on_release -> release_copy_scratch) panicked on the poisoned lock, and a panic there is non-unwinding, so the whole lib test binary aborted ("thread caused non-unwinding panic. aborting.", exit status 9). Every test result of that process was lost. Measured under Wine 11.22 + vkd3d-proton v3.1 on an RTX 5060 Ti, where gpu_more_atomics_sub_dword_scratch_valu hangs the GPU and the device is removed for later tests (the fence then reads as complete, so this test's "stays until the fence" check fails): main aborted in 2 of 2 runs; with this change the binary runs to the end and reports the failures. The checks are now read under the lock and asserted after it is released. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <[email protected]>In crates/xcl/src/gpu/dxil/lower.rs, Lw::salu unconditionally called read64 on _b64 saveexec/wrexec forms even in wave32 (!self.wave64) and unconditionally read sreg(127) (EXEC_HI) before branching on (!self.wave64 || name.ends_with("_b32")). On 32-bit-only source encodings such as m0 (SSRC0 = 124), wave32 S_AND_SAVEEXEC_B64 failed translation with Err("...: op"), and on SGPR sources it spuriously touched s[n+1] and EXEC_HI (s127). Move source reads and EXEC_HI handling inside the wave32/_b32 vs wave64 _b64 branches to mirror HLSL (#191), and add unit/disassembly and wave32 RTX 4060 GPU regression tests in lower.rs. Part of #1269 Assisted-by: Google Antigravity (Gemini 4 Neon)In HLSL 2021 pixel shaders (#define XCL_PIXEL 1), PRELUDE::rla() indexed uint4 xcl_lv with a runtime index xcl_lv[min(h >> 5, 3u)] and used scalar ternary/if chains. DXC lowered every rla() call site into a [4 x i32] alloca local array plus conditional branches; across the retail pixel shader corpus (12,056 unique PS), 7,634 shaders call rla() (up to 212 calls / 212 local arrays in a single pixel shader). Replace xcl_lv[min(h >> 5, 3u)] with inline branchless select() over xcl_lv.{x,y,z,w} (self-contained inside PRELUDE without depending on PRELUDE_MEM::pick4) and replace the scalar ?: and if chains in rla() with select() and and(). Part of #2088 Part of #1269 Assisted-by: Google Antigravity (Gemini 4 Neon)Persist deterministic negative cache markers (.err) alongside positive shader cache entries so repeated boots do not re-lower refused programs or re-invoke DXC on deterministically failing HLSL: - dxc.rs: cache deterministic DXC compiler rejections (raw error starting with 'dxc: ') in {key:016x}.err (keyed by crate version, DXC toolchain identity, profile, entry, and HLSL source). Subsequent runs return the identical error text with zero DXC invocations. Transient/missing-DLL errors and cached_only deferrals are never cached. - pso.rs: cache translator refusals and compile errors in translated/v2/{ident:016x}/...err (keyed by XCL_TRANSLATOR_SOURCE_ID, DXC toolchain identity, blob hashes/length, stage, sampler_base, windows, and split_wave64). Updating translator sources, DXC DLLs, or wave mode automatically invalidates prior markers; debug/capability env overrides bypass the cache via cache_allowed. Fixes #1412. Assisted-by: Antigravity (Gemini 4 Neon)Recompiler: translate v_qsad_pk_u16_u8 and v_mqsad_{pk_u16,u32}_u8 in both backends (takes over #909)e1d84b7d) into world-main f8d79eca12b49be183: #174, #2371) into world-main 6aa80e3c80@GodlyBDS on GitHub · 2026-11-26 03:29 UTC · original · edited 2026-11-26 03:43 UTC
RTX 3090 Ti / 621.40 / Windows 10 / 32 GiB follow-up on
e877812e. I used two local startup compatibility changes already tested on the older NVIDIA branch (Agility host-path scope and the XG extra argument), and the same per-executable 1 GiB shader heap reserve. The release build and six focused startup tests passed. This arm uses on-demand compilation (XCL_PREPARE=0, background PSO preload off) and starts from 8,426 prior native entries. The translated cache is regenerated so that the refreshed shader paths use their current outputs.The independent timing of PSO worker gate waits is in #2628. AI use: OpenAI Codex (GPT-6) ran the comparison and drafted the report.
Long-run update. One recording thread completed 37 large, cache-missing compute PSO builds in sequence between 773.010 and 1,443.620 s. Their logged driver durations total 670.124 s of that 670.610 s interval. The runtime stack samples caught the thread in
nvgpucomp64.dll. There were no Presents in that interval and the run remained active. The verified seed held 8,426 native entries and the live cache had 10,565 files at this sample. The foreground sequence is separate from the worker-gate pressure described on #2628. This supports warming the demanded native PSOs on this GPU. It does not show that precompilation resolves the full world transition.@pickles976 on GitHub · 2026-11-26 04:02 UTC · original
Blocker for 16 GiB / capped Wine hosts (source-verified at exact head
82e4a9bbf3be583418b9df7825dd1430fd8b06d6): the default worker budget has a byte/MB mismatch.crates/xcl/src/host.rs:13-22documents and returnssystem_commit()total/limit in bytes (K32GetPerformanceInfo× PageSize).crates/xcl/src/shaders.rs:1683-1694forwardslimit.saturating_sub(used)unchanged toworkers_for(cores, free_mb), which divides by 3072 assuming its input is MiB. On this laptopnproc=16; for an illustrative 6 GiB free commit, the intended three-GiB-per-worker rule is 2 workers, but the head's expression selects 12 (all 16-4 allowed CPU slots). Under the local 9 GiB Wine cgroup and 16 GiB physical RAM, this can trigger the external 2 GiB MemAvailable guard or an OOM before the title starts.XCL_PREPARE_WORKERS=1avoids this risky default for local trials, not a shipping fix. Please make the argument explicitly bytes and divide by3 * 1024 * 1024 * 1024(or convert bytes to MiB before calling), add a regression with 6 GiB in bytes, and respect a smaller applicable process/cgroup memory limit if the application is launched within one; global commit alone does not enforce a 9 GiB scope cap.I attempted the focused Windows-MSVC Wine test
preparation_workers_leave_two_processors_and_follow_the_commit_left, but the head does not reach the test on this build setup: transitivewindows-future 0.3.2fails compilation againstwindows-core 0.62.2/windows-threading(IMarshal,marshaler,submitmissing), exit 101. Local log.compat-xcl/logs/verify-pr2624-wine-worker-budget.log. The existing syntheticworkers_forcases pass fake numbers labeled MB and would not catch the bytes passed from the real caller. No worker processes or retail title were launched; the source-level unit mismatch is independent of the dependency build failure. Machine: RTX 4060 Laptop 8 GiB, Wine 11.0, 16 GiB host RAM.@LocranKing on GitHub · 2026-11-26 05:13 UTC · original
Independent NVIDIA test report on exact head
82e4a9bbf3be583418b9df7825dd1430fd8b06d6(clean detached checkout, no local changes), compared againstnvidia-dev(c044dc6d).Tested
32.0.16.2140/ 621.40), AMD Ryzen 5 5500 (6c/12t), 32 GB RAM, Windows 11 Home (build 26300), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4(debug):nvidia-dev(c044dc6d): 1560 passed, 6 failed, 47 ignored (xcl --lib: 1490 passed, 2 failed, 27 ignored), 28SKIPPED.#2624(82e4a9bb): 1721 passed, 6 failed, 48 ignored (xcl --lib: 1594 passed, 2 failed, 28 ignored), 28SKIPPED.nvidia-dev(+161 passing tests). All 6 failures matchnvidia-dev:hle::d3d12x::texture_upload::tests::{gpu_parts_of_a_texture_go_up_and_the_rest_stays, pieces_hold_the_texels_of_their_levels}(texture_upload.rs:990:17:attempt to multiply with overflowin debug)d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly(expected AS-slot refusal in translation_errors: ["MS: no NGG hardware variant"])gpu_compute_e2e::async_compute_pso_registers_real_pso_and_not_standingpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(both test runs fail withdisabled:)SKIPPEDGPU tests on this adapter: 21 wave64-only (no wave64), 3 wave32 per-lane f16/f32 semantics, 1no heap windows, 1no heap windows (opt-in: XCL_HEAP_WINDOWS=1), 1 no D3D12 debug layer (0x887A002D), 1 cannot disable driver cache without Developer Mode (0x887A002D).used-shaders.txt= 11 shaders from the priorXCL_PREPARE=0run):0 of 8 workers failed), checked 26,503 records and finished compute pipeline preparation in 6 s (total_elapsed_s=72.5including the 60 s run), presentation window worked cleanly.Regression run
scripts/smoke.ps1 -Seconds 60, release builds ofnvidia-dev(c044dc6d) and#2624(82e4a9bb):nvidia-dev (
c044dc6d):PR (
XCL_PREPARE=0):PR (with worker preparation over
used-shaders.txt, 8 workers, 6 s prep):Not tested
XCL_PREPARE_ALL=1full-pack compute precompile pass; AMD / Intel / Linux GPUs;XCL_SAMPLE_*tests; the 60 s smoke run covers boot/intro/menus and does not enter the 3D world.AI use
smoke.ps1commands on this machine and drafted this report from the captured outputs.@itsSio on GitHub · 2026-11-26 05:29 UTC · original
Dual-PC NVIDIA full-workspace test run (debug) and RTX 5080 retail smoke (release) at exact head
82e4a9bbf3be583418b9df7825dd1430fd8b06d6, covering the full suite, hardware-GPU tests, integration tests, and non-5090 NVIDIA hardware listed under Not tested.Tested
82e4a9bbf3be583418b9df7825dd1430fd8b06d6(basenvidia-dev), clean checkouts on both PCs,XCL_ADAPTER=NVIDIA,cargo build --workspacebefore runningcargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture.32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200.9974,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug build.1594 passed, 2 failed, 28 ignored; raw lines also print 3 single-test child reruns and a duplicategpu_two_pass_cacheprint, excluded from totals).SKIPPED: 27 lines (no-wave64 group, 3 refused wave32 per-lane f16 forms, no heap windows).32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200.8653,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11, debug build.1594 passed, 2 failed, 28 ignored).SKIPPED: 30 lines (18 distinct tests: PC 1 skips pluspso_measurement_compiles_an_exact_synthetic_record,uploads_start_from_each_subresources_state, and 2lower::wave64 tests).#2624tests pass on both PCs:the_shaders_of_a_used_set_are_kept_for_the_next_run,the_key_of_one_shader_is_the_key_of_a_set_of_it,preparation_workers_leave_two_processors_and_follow_the_commit_left,static_sampler_set_before_a_branch_is_a_constant_after_it.nvidia-dev, reproduced on both PCs):texture_upload::tests::pieces_hold_the_texels_of_their_levels&gpu_parts_of_a_texture_go_up_and_the_rest_stays(texture_upload.rs:990:17, debug multiply overflow in test LCG).d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly(:96, expected AS-slot refusal, got["MS: no NGG hardware variant"]).gpu_compute_e2e::async_compute_pso_registers_real_pso_and_not_standin(:535,TRANSLATED_COMPUTEcleanup vslate_release).gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(:649, two-pass state releaseleft 3, right 0vslate_release).e2e::test_title_runs_and_game_folder_is_untouched,e2e.rs:168):NVIDIA Corporation\andNVIDIA Corporation\umdlogs\directories.#2624(82e4a9bb) failed 4/4 runs;nvidia-dev(c044dc6d) passed 3/3 runs (where the VFS redirects those driver writes to the overlay because D3D12 init happens after VFS install, whereaspreparation::before_guestopens D3D12 before VFS install while cwd is the game root). Passing on PC 2 (RTX 2080 SUPER does not createumdlogs).XCL_PREPARE=0,XCL_DXC_DIR= DXC1.9.2609.5):Not tested
XCL_PREPARE=1) andused-shaders.txtreuse on a retail title, visual verification of the static sampler fix in 3D world rendering, AMD / Intel GPUs, and retail smoke on the RTX 2080 SUPER.AI use
Ran via Samaritan:
e2eA/B check againstc044dc6d, and the release build, and traced thebefore_guestcwd vs VFS ordering behind theumdlogsfailure.@luckyteagirl on GitHub · 2026-11-26 04:50 UTC · original · reviewed
With
XCL_PREPARE_WORKERS=2,XCL_ADAPTERunset, and a title config such asd3d12_adapter = "1"on a two-GPU host, the parent capturesprogress.adapterbut this childCommanddoes not pass it on. Each worker enters the CLIshaders --precompilepath withstartup=None, soPipelines::for_adapter("auto")selects the default adapter; the title runtime still selects adapter 1. That means the workers can warm driver PSOs for the wrong device, and matching-DXIL cache entries can later be rejected and rebuilt on the title's adapter. Could the spawn pass the resolved adapter to children (for example viaXCL_ADAPTERonly when no explicit environment override exists) and test the config-only secondary-adapter case? This is source review; I did not run a two-GPU preparation test, and this point concerns the worker pipeline path rather than all translation-only preparation.@KDenKC on GitHub · 2026-11-26 06:20 UTC · original
+1 to @pickles976's byte/MB finding above (7182236787). I didn't see it before posting, sorry for the repeat. One new data point: it is still there at the current
nvidia-devheadaf2cecc4(shaders.rs:1727passessystem_commit()bytes toworkers_for, which divides by 3072). So on a 16-thread CPU the default is still 12 workers, whatever commit is free. We'll setXCL_PREPARE_WORKERSexplicitly when we run the branch.AI use: Claude Code (Claude Opus 5.5) checked the source at
af2cecc4and wrote this.@pr1sm-dev on GitHub · 2026-11-26 06:27 UTC · original
@pickles976 confirmed by reading the current
nvidia-devheadaf2cecc:prepare_workers(crates/xcl/src/shaders.rs:1727-1728) still passeshost::system_commit(), which is in bytes (host.rs:11-12), toworkers_for(cores, free_mb), which divides by 3072 as MiB (shaders.rs:1732-1733). So the commit bound never applies, and the count is always the logical processors less four (capped at 32).I'm taking the fix, as a small PR against
nvidia-dev: convert at the call site, leaveworkers_forand its tests as they are, and add a regression test with byte values (6 GiB free on 16 threads → 2 workers). A process or cgroup memory cap that the commit figures do not show stays out of scope; I'll say so in the PR.AI use: Claude Code (Claude Opus 5.5) read the source and wrote this comment.
@KDenKC on GitHub · 2026-11-26 08:53 UTC · original
nvidia-devaf2cecc4, all cold, RTX 5090. Preparation works and removes the graphics stall on a relaunch. The wall left is about 20 split programs' whole forms, which the worker processes do not build.RTX 5090 (621.24), Ryzen 7 9800X3D (16 threads), Windows 11, release,
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1 XCL_NETWORK=0,XCL_PREPARE_WORKERS=6(set by hand, see the byte/MB note above), 600 s of title time, the retail title. Each arm used a fresh exe name (empty NVIDIA cache) and a freshXCL_DXIL_CACHE. One run per arm:mainb49be18.used-shaders.txt,used-pipelines.txtandused-graphics-pipelines.bin.None of the three reached the world in 600 s. Each one sat on the world loading screen from about +110 s, while large compute pipelines kept compiling.
Where N2's time went. Joining
driver compile start/finishwith the binds:used-pipelines.txt, and Pass 2 had built their pieces.The reason is in
shaders.rs(af2cecc4, around line 2172):p.make_one(&c.dxil, …, true, None)for a program with adispatch_chainruns onlyif startup.is_some(). Pass 2's workers runprecompilewithstartup = None, so they build the pieces but never the whole form. Building it whenXCL_PRECOMPILE_PARENTis set too (or passing a flag to the workers) looks like it would take most of that remaining wait into preparation.Not tested: the default worker count; more than one run per arm; whether the title reaches the world with whole forms prepared; AMD.
nvidia-devis the whole branch, so M vs N differences are not only #2624's.AI use: Claude Code (Claude Opus 5.5) ran the three arms. Gemini (Antigravity) joined the trace lines and found the
startupgate. Claude Code checked the gate in the source and wrote this.