D3D12.X: clamp PcCalls across frame boundaries and drop orphaned PSO jobs immediately #2296
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!2296
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2296/head"
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?
@Decodere on GitHub · 2026-11-25 12:58 UTC · original
Decodere:fix-1782-2178-pso-async-frame-orphan→main· +197 −23 · 1 files · 1 commits · merged 2026-11-25 18:16 UTCWhat is in it
Follow-up to #1782 and #2178 fixing two lifetime/timing bugs in
crates/xcl/src/hle/d3d12x/pso_async.rs:PcCallsacross monotonic frame boundaries:PcCallsnow tracksframe: Option<u64>andframe_since: Option<Instant>, recordingframe_since = Some(now)on monotonic frame advances (frame > previnbegin(),end(), andholds(), withpc_call()readingpresent::presents()underPC_CALLS.lock()likeheld_by_pc_call()andPcCall::drop()) and clamping call start times viasince.max(frame_since). A long PC call that began on frameNand finishes after frameN+1is presented no longer charges its pre-frame-N+1duration into frameN+1'sPC_CALL_HOLDS_AFTER(250 ms) budget, stale lower frame numbers never rewindframeor clearspent, and a call genuinely stuck>= 250 msafter a frame still holds the title.Jobclosures: Addeddrop_unstarted_job(&Pending)and call it fromreleased()(after releasingPENDINGandp.donelocks) as well as thepreload()andenqueue()workerp.orphanchecks. Whenreleased()claimsp.jobbefore a worker takes it, the unstartedJobclosure (with its captured COM objects and shader bytecode buffers) is cancelled and dropped immediately outside all locks rather than staying pinned until background workers drain deep queues, and*p.done = true+p.cv.notify_all()wakes any concurrent waiter (a worker that already passed thep.orphancheck and claimsp.jobfirst still runs and discards its result once incomplete()).(Rebased onto
origin/main06c9f550to adapt cleanly to #2080'sWorkqueue /enqueue()extraction inpso_async.rs, callingdrop_unstarted_job(&p)inenqueue()'s orphan branch.)Tested
cargo test --release -p xcl --lib hle::d3d12x::pso_async::used_tests:: -- --test-threads=1 --nocapture):10 passed, 2 failed— both new tests failed (pre-frame duration leaked into frame 8's budgetandnormal queued job was not dropped immediately on released()).cargo test --release -p xcl --lib hle::d3d12x::pso_async::used_tests:: -- --test-threads=4 --nocapture:12 passed, 0 failed, 0 ignored(0.61 s), including:pc_call_crossing_frame_boundary_does_not_charge_prior_frame_time: verifies pre-frame duration does not leak on eitherholds()orend()after a frame advance, calls genuinely stuck>= PC_CALL_HOLDS_AFTERafter the frame advance still hold the title, and stale lower frame numbers never rewindframeor wipe the newer frame'sspentbudget.released_queued_pipeline_drops_job_immediately_before_workers_drain: saturates both the normal worker pool and thepreloadworker pool behind gates, callsreleased()on queued pipelines carrying aDropFlag, and asserts both jobs drop immediately while workers are still blocked and never execute.used_testswith a test-onlyWORKER_SATURATION_LOCKsoa_released_queued_pipeline_is_not_built_by_normal_workersand the new saturation test never race under--test-threads=4.cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocaptureon NVIDIA GeForce RTX 4060):23test binaries,1267 passed, 0 failed, 46 ignored(28pre-existing hardware/debug-layerSKIPPED:21no wave64on 32-lane GPU,3wave32 per-lanerefused,2missing D3D12 debug layer,1driver cache toggle,1no heap windows;0skipped inpso_async).Regression run
Paired 60 s
scripts/smoke.ps1runs on the same RTX 4060 host againstorigin/main(06c9f5505f63f10c5ec49ef932d75b2c28177324) and PR head (5b97e22b2e77b2ba3e65d8a3396c0f7a9eaf04af):Baseline (
origin/main):PR head:
Not tested
d3d12SDKLayers.dllis not installed on this host).AI use
Implemented and verified with Google Antigravity (Gemini 4 Neon).
@Decodere on GitHub · 2026-11-25 14:20 UTC · original
Thanks
@fromthemoonx(for the RTX 3060 + D3D12 debug-layer verification) and@Gevroska(for the cancellation-boundary testing and wording precision)!Rebased onto
origin/main06c9f550->5b97e22b:Workqueue /enqueue()extraction incrates/xcl/src/hle/d3d12x/pso_async.rs(wiringdrop_unstarted_job(&p)intoenqueue()'sp.orphancheck).@Gevroskato clarify thatreleased()cancels/drops immediately when it claimsp.jobbefore a worker takes it, whereas a worker that already passed thep.orphancheck and claimsp.jobfirst still runs and discards its result once incomplete().pso_async::used_tests(12/0), full release workspace (1,267 passed, 0 failed, 46 ignored), and paired 60 s RTX 4060 smoke (1566 -> 1559frames,0removals/crashes,14462 -> 14420 MB).AI use: rebased, tested, and drafted with Google Antigravity (Gemini 4 Neon).
@nnonno91 on GitHub · 2026-11-25 14:25 UTC · original
Independent parallel test rerun on rebased head
5b97e22b2e77b2ba3e65d8a3396c0f7a9eaf04af.Tested
cargo test --locked -p xcl --lib hle::d3d12x::pso_async::used_tests:: -- --nocapture --test-threads=4three times in separate processes. All three runs gave 12 passed, 0 failed, 0 ignored and no skips.Not tested
The parent, a retail title, GPU behavior and the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the checks, verified the logs and wrote this report.
@fromthemoonx on GitHub · 2026-11-25 14:06 UTC · original · edited 2026-11-25 14:26 UTC
Rerun on the new head
5b97e22(rebased ontomain06c9f55): passes on NVIDIA with the D3D12 debug layer, and the debug layer reports the same messages as onmain. The conflict with #2080 noted below is resolved.cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDlines (no wave64and the refused per-lane cases);test_title_draws_with_a_root_signature_under_the_debug_layerran and passedcargo test -p xcl --lib hle::d3d12x::pso_async::used_tests:: -- --test-threads=4, 30 runsxcl.log, PR vs06c9f55First run, on
99bb282: Passed on NVIDIA with the D3D12 debug layer installed, but conflicted withmain. #2080 (9a257e1) had changed the worker loop inqueue()(Box<dyn FnOnce()>work items, the orphan check moved intoenqueue()), so I tested the head on its base1a0bbe3: 1252 passed, 0 failed, 46 ignored;used_tests30 of 30; debug-layer messages identical to1a0bbe3.The e2e title runs with
XCL_ASYNC_PSOunset (async on). It does not release a pipeline that is still queued, and it does not keep a PC call open across a present. So the debug-layer run checks that nothing changed for that title, not the two new paths themselves. The new unit tests cover those.Tested: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.
Not tested: a release build, a title, AMD / Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@Gevroska on GitHub · 2026-11-25 14:01 UTC · original · edited 2026-11-25 15:23 UTC
I tested the cancellation boundary at
99bb2826with a standalone Rust CPU fixture. I paused the worker after it readorphan == false, then letreleased()mark the entry orphaned. When I resumed the worker beforereleased()took the job mutex, the worker claimed and ran the job. On completion, it discarded the result exactly once. Whenreleased()took the job first, the waiter woke and the job never ran.I’d qualify “any unstarted
Jobclosure is dropped immediately” in the description. Release cancels a queued job if it takes the job slot first. A worker that already passed the orphan check can still win that race.All four fixture cases passed. I used inert job results and did not run a driver compile. I used Codex GPT-6.2 Sol for the fixture and a separate GPT-6.2 Sol agent at high reasoning to verify the source and results.
I reviewed and approved this comment before posting.
@DavidM1911 on GitHub · 2026-11-25 17:29 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!
@emirduran707 on GitHub · 2026-11-25 17:37 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
5b97e22b2e77b2ba3e65d8a3396c0f7a9eaf04af(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1265 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record).hle::d3d12x::pso_async::used_tests::pc_call_crossing_frame_boundary_does_not_charge_prior_frame_timeandreleased_queued_pipeline_drops_job_immediately_before_workers_drain.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use