Shaders: stop startup shader preparation promptly when cancelled #2830
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!2830
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2830"
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?
@Flamingo572 on GitHub · 2026-11-26 16:19 UTC · original
Flamingo572:shaders/cancel-preparation→main· +204 −13 · 1 files · 1 commits · draftFollow-up to #2555. Closing the startup shader preparation window sets
LaunchPreparation::cancel, whichprecompile()previously checked only at the outer record loop. While a split compute shader, a multi-variant record, or a driver slot wait insidePipelines::make_onewas running, cancellation had to wait until those inner loops or driver slot waits finished.What is in it
crates/xcl/src/shaders.rs:is_cancelled(Option<&AtomicBool>)andPipelines::make_with_cache_path_cancel(preservingPipelines::makeandPipelines::make_with_cache_pathunder#[cfg(test)]), checking cancellation before and during split compute piece builds.Option<&AtomicBool>intoPipelines::make_one, using a bounded 50 msCondvar::wait_timeoutwhile driver build slots are busy and exiting early before uncachedCreateComputePipelineStatebuilds.startup.map(|p| &p.cancel)inprecompile()across compute builds, the whole-form split fallback, completion counters, and innerfssm/programs/jobsloops.pipeline_cap_tests(cancelled_split_compute_build_skips_pieces_and_writes_no_blobsandcancelled_pipeline_waiter_exits_while_driver_slots_are_busy), usingrecomp::runner::skip_testwhen DXC/D3D12 is unavailable.Tested
d6cf64c19c6b38e31e3f2df31631481fcf6e56b0(amended from069292cadbe4fa31e19b2b282b25325ae6eaf0d8to add#[cfg(test)]onmakeandmake_with_cache_path, clearing thedead_codewarning).32.0.16.1742), AMD Ryzen AI 7 350 w/ Radeon 860M (AMD Radeon 860M driver32.0.22042.8003), Windows NT 10.0.26300.0,rustc 1.100.0 (0ef1bc386 2026-11-09)(stable-x86_64-pc-windows-msvc), Windows SDK DXC1.9.2602.17(10.0.26100.0), debug.cargo build --workspace: exited 0 (0 warnings incrates/xcl/src/shaders.rs).cargo test -p xcl --lib pipeline_cap_tests -- --nocapture: 5 passed, 0 failed, 0 ignored (0 skipped; both newcancelled_*tests ran on NVIDIA GeForce RTX 5060 Laptop GPU).cargo test -p xcl --lib -- --skip fuzz_validate_and_gpu --test-threads=4: 1316 passed, 0 failed, 27 ignored (SKIPPEDGPU tests: 21no wave64, 3 refused per-lanef16/f32forms, 1shaders::tests::pso_measurement_compiles_an_exact_synthetic_recordcannot disable the driver cache (Windows Developer Mode is required)).cargo test --workspace --test '*' --no-fail-fast -- --test-threads=4: 128 passed, 0 failed, 20 ignored (SKIPPED: 2 debug-layer e2e testsno d3d12SDKLayers.dll, 1heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows, 1uploads_start_from_each_subresources_state: no D3D12 debug layer)..\scripts\test.ps1on069292castopped inxcl --libbecausegpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0,1,2,3}hit pre-existing RTX 5060CreateComputePipelineStateE_OUTOFMEMORY(0x8007000E) on seeds 70, 545, 1019, and 1507 (#1905), including serially (--test-threads=1).Regression run
Pending Windows 11 run of
scripts/smoke.ps1onmain(8b957bec) and PR headd6cf64c19c6b(no retail GDK title available locally).Not tested
scripts/smoke.ps1regression run on a real GDK title (no retail title available locally).gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}on headd6cf64c19c6b(skipped due to pre-existing RTX 5060E_OUTOFMEMORY, #1905).XCL_SAMPLE_*game-data tests (unset), wave64-only / AMD RDNA GPUs locally (@SzczepanGrelapreviously tested069292caon RX 9070 / Wine), D3D12 debug layer tests (d3d12SDKLayers.dllnot installed).acquire_running()/OfflineGate) noted by@upipibi; whichever merges second will need to wirecancelinto those waits.AI use
crates/xcl/src/shaders.rs, and opened the initial draft PR.#[cfg(test)]to clear thedead_codewarning, re-verified tests, and updated this PR description.@SzczepanGrela on GitHub · 2026-11-26 16:36 UTC · original
RX 9070 / Wine release check of the cancellation primitives, paired with main.
Tested
069292cadbe4fa31e19b2b282b25325ae6eaf0d8against main8b957bec6f82495aec940944c6bf47faa02db590.8293130ebe370b1+(local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, releasex86_64-pc-windows-gnu.XCL_NETWORK=0, one DXC worker, two pipeline slots, private enabled caches; inheritedXCL_*flags cleared first.cfg(test)atomic observer immediately before the real condition-variable wait. Test-only wrappers call the cancel-aware primitive on head and the existing primitive on main. Removing the additions reconstructs the pinned source hashes.Original module
shaders::pipeline_cap_tests::, once with one test thread and once with four:Both new cancellation tests ran without capability skips. The existing stale-cap regression also dispatched its synthetic control and verified
gpu_word0=42on each source/thread setting.Observed wait and native controls
Three fresh serial processes per source, alternating source order. The local probe compiles three owned HLSL inputs: two split pieces and a distinct whole fallback. It calls the inner pipeline helpers directly; it does not launch a preparation window or guest.
For the wait case, both slots are marked busy. The test waits for the observer, sets the cancel flag and watches for return without releasing a slot or externally notifying the CV. Only after return or a two-second observation timeout does it release the slots, notify and join the thread. In every head run it observed return first; in every main run return followed cleanup. Slots were still 2/2 before cleanup and returned to zero afterwards.
The uncancelled positive control succeeds on both versions, with identical DXIL and positive-cache filenames/blob bytes across all six processes. No pipeline was refused. The local probe constructs 30 PSOs in total and verifies every 112-byte driver blob. It does not dispatch these three probe shaders; GPU execution above belongs to the separate existing
gpu_word0=42control.Head probe: 1/0/0 in each process. Main probe: expected 0/1/0, at the final pre-cancelled-build assertion after both controls and blocked-waiter cleanup. All ten completed harness summaries, counters, cache files, source reconstruction and executable hashes were independently checked; no runtime skips or ignored tests.
One additional Wine launch failed before libtest with
recvmsg: Connection reset by peer. The identical invocation was retried once and passed; the failed log is retained separately from the ten completed runs.Build:
cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run. Under GE-Proton Wine, run the libtest executable withshaders::pipeline_cap_tests:: --nocapture --test-threads=1/4; local probeshaders::workflow_cancelled_pipeline_checks_native_controls --exact --nocapture --test-threads=1.Not tested
Cancellation during an in-flight DXC or native driver call, restored-cache cancellation races, the actual preparation UI/guest launch, all multi-record startup loops, other GPUs, native Windows, full suite, retail inputs,
scripts/smoke.ps1, performance or FPS. This report covers the inner cancellation primitives and their native positive controls, not a hard scheduling-latency guarantee.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, added the local probe/observer, ran the original module and paired native checks, independently verified the evidence and drafted this report. Publication authorized by the account owner.
@CryingLaughing on GitHub · 2026-11-26 16:41 UTC · original
Independent Windows verification on exact head
069292cadbe4fa31e19b2b282b25325ae6eaf0d8and parent8b957bec6f82495aec940944c6bf47faa02db590. RTX 4080 driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11, debug.cargo test -p xcl --lib --locked -j 2 --no-runbuilt successfully. The exact libtest binary ran bothshaders::pipeline_cap_tests::cancelled_cases serially and reported 2 passed, 0 failed, 0 ignored, with no capability skips. The cases covered leaving no driver blobs after an already-cancelled split build and returning from driver-slot admission while all slots were occupied. The separatehle::d3d12x::present::preparation::tests::selection passed 3/3, including closing before READY preventing handoff.The launcher preparation window and these checks share the cancellation flag. This covered the pipeline and preparation-screen state below the window. The busy-slot fixture uses its timed entry delay. A live window-close run and cancellation during an active native compiler or driver call remain outside this check.
@upipibi on GitHub · 2026-11-26 17:12 UTC · original
Overlap with #2179 (open), from reading both diffs, no run. #2179 replaces this driver-slot wait in
make_onewithacquire_running(), a plain condvar wait, and adds anOfflineGatewait (a 50 mswait_timeoutloop). Neither checks a cancel flag.Whichever of the two merges second needs to pass
cancelinto both waits. Otherwise a cancel while all slots, or the commit gate, are busy waits again for a driver compile to finish.cancelled_pipeline_waiter_exits_while_driver_slots_are_busyis the test that would catch it.AI-assisted (Claude Code, Claude Opus 5.5).
069292cadbtod6cf64c19c@Flamingo572 on GitHub · 2026-11-26 18:50 UTC · original
Thank you @SzczepanGrela and @CryingLaughing for testing
069292ca, and thank you @upipibi for flagging the overlap with #2179 (acquire_running()andOfflineGate).I force-pushed an amended head
d6cf64c19c6b38e31e3f2df31631481fcf6e56b0(no runtime changes from069292ca; only added#[cfg(test)]toPipelines::makeandPipelines::make_with_cache_pathincrates/xcl/src/shaders.rsto clear thedead_codewarning) and updated the PR description with Windows 11 + RTX 5060 Laptop GPU test results.If anyone with a retail GDK title can run a paired
scripts/smoke.ps1regression check againstmain(8b957bec) andd6cf64c19c6b(I don't have a title locally to generate thexcl-smokeblocks), I'd really appreciate it so we can getPR descriptiongreen and take this out of draft.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.