d3d12x: bound PSO bind waits, guard pending draws, and auto-init uninitialized targets #1642
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1652"
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?
Imported from ivall/xcl. Originally posted by rdj415 on 2026-11-24T18:43:09Z.
Stacked on #1274. Prevent title watchdog freezes and
DXGI_ERROR_DEVICE_HUNG(0x887A0006) during cold shader compilation by bounding PSO bind waits per frame, skipping draws/dispatches with pending or unready pipelines, auto-initializing uninitialized placed/reserved RT/DS targets before the first draw, keepingD3D12_HEAP_FLAG_CREATE_NOT_ZEROEDfor non-RT/DS streaming textures, and blocking Backtrace telemetry uploads.What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs,crates/xcl/src/gpu/recomp/dxc.rs,crates/xcl/src/hle/d3d12x/present.rs: bound runtime PSO bind waits (wait_budget: 250 ms per PSO, 2,000 ms cumulative perPresentXframe viapresent::frame_generation;resolve_wait_criticalgrace capCRITICAL_FRAME_WAIT_CAP_MS= 2,000 ms;XCL_PSO_WAIT_MS=0for unbounded waits), replace FIFO queues inpso_asyncanddxcwith priority-aware scheduling so wanted/warm builds preempt unwanted cold builds, and drop expired background worker threads toBELOW_NORMAL.crates/xcl/src/hle/d3d12x/bind.rs: close theresolve_wait/is_pendingTOCTOU window viaresolve_wait_checked, skip draws andExecuteIndirectdispatches when a translated pipeline is still pending or failed (graphics_bound_with,note_compute_signature/is_compute_signature), and avoid passing unready stand-in PSOs to the PC driver.crates/xcl/src/hle/d3d12x/list_x.rs,crates/xcl/src/hle/d3d12x/real.rs,crates/xcl/src/hle/d3d12x/device_x.rs,crates/xcl/src/hle/d3d12x/vram.rs: track placed/reserved/committed RT/DS targets and RTV/DSV handles (note_uninit_target_if_rt_ds,ensure_bound_targets_initialized,cl_discard_resource), stripD3D12_HEAP_FLAG_CREATE_NOT_ZEROEDonly for RT/DS targets and indirect buffers (should_strip_not_zeroed_resource) while preservingCREATE_NOT_ZEROEDfor ordinary textures/streaming buffers, coalesce duplicate in-flight compute PSO compiles (ComputeFlight), and persist slow (>= 250 ms)<16 KiBcompute driver blobs todriver_cache.crates/xcl/src/hle/netoff.rs,crates/xcl/src/host.rs: hookwinhttp.dll!WinHttpConnect(install_telemetry_block) to reject*.backtrace.iouploads withERROR_WINHTTP_NAME_NOT_RESOLVEDwhile forwarding all other hosts untouched.Tested
rustc 1.98.0-nightly (096694416 2026-06-29), release build and debug unit tests on Windows.cargo test -p xcl --lib -- --nocapture(commitfb07ff8): 747 passed, 0 failed, 21 ignored (SKIPPED GPU tests on 32-lane hardware:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64).scripts/smoke.ps1 -Seconds 60on clean9e3831e(upstream/main) and cleanfb07ff8(pso-compile-watchdog-unblock).Regression run
main:
PR:
Not tested
cargo test --workspace -- --test-threads=4,cargo test -p xcl --test gpu_compute_e2e,cargo test -p xcl --test shaders_e2e, and Python helper tests on commitfb07ff8.<game folder>.AI use
d3d12x-console-vtable-slots(15fab80), resolving thereal.rsconflict, runningcargo test -p xcl --lib, and running thescripts/smoke.ps1verification.Imported from ivall/xcl. Originally posted by throny on 2026-11-24T20:01:11Z.
World-loading test of
fb07ff8merged ontomainc160d86, againstc160d86itself, on the retail title (counts only).Result: in 3 of 6 runs of this PR, the process's commit climbed from about 16 GB to over 30 GB within 6 – 8 s while the title was still on its menu (22 – 44 s into the run, at about 2.5 – 3 GB/s), and our memory guard stopped the run. None of the 4
mainruns did this; they stay between 15 and 17.5 GB over the same stretch. So I couldn't check whether the PR gets past the stall:mainends at the title's watchdog at 110 – 113 s in all 4 runs, and the other 3 PR runs were stopped by the guard at 85 – 92 s with about 30 GB of commit, before that point.mainThe log shows no shader or PSO activity during the climbs, only the menu's normal presents (60 per 2 s). In the runs that reached world loading, the PR skipped 322 – 1 024 draws and 1 024 – 2 708 dispatches.
Tested
main: 2 runs with the default DXC threads, 2 withXCL_DXC_THREADS=4. PR: 2 with the default, 4 withXCL_DXC_THREADS=4(all three jumps were in those).Not tested: the suite on this head, AMD, a machine with more free commit (whether the PR gets to the end of the stall), and what allocates during the climbs.
This PR is about 2 800 added lines and bundles several changes (PSO wait budget, DXC queue scheduling, skipped draws, target initialisation,
NOT_ZEROEDhandling, driver-blob persistence, a telemetry block). Split into separate PRs, a memory jump like this one could be traced to one of them.AI use: Claude Code (Claude Opus 5.5): ran the tests and wrote this.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T21:16:38Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
upstream-sync referenced this pull request2026-11-24 23:06:49 +00:00
Imported from ivall/xcl. Originally posted by milesah3ad on 2026-11-24T22:27:22Z.
@rdj415 a question before I write anything, so we don't end up with two PRs for the same thing again. Would you split the per-frame cap on bind waits out of this PR into a small one of its own? That's
wait_budgetagainst a cumulative limit perPresentXframe (present::frame_generation), with binds past it going on with the stand-in. If you'd rather not, I'm happy to write it as a standalone PR that credits this one.Why that piece on its own:
XCL_PSO_WAIT_MSonmainis per pipeline. @MaurycyBartczak's watchdog runs on #156 built 41 compute pipelines during the stall, so a per-pipeline limit of 2 s still allows about 80 s, far past the title's 30 s countdown. A total per frame is what keepsPresentXcoming. VIctory takes the same approach for the same watchdog: 0.5 s of pipeline waits per title frame, after which a draw or dispatch whose pipeline isn't ready is dropped (victory-gpu/src/pipeline/make.rs; ideas only, it's GPL-3.0).Wait64BitValueX) on values whose producer dispatch was skipped. A smoke pair would need to show whether a capped frame trades the watchdog for that.AI use: Claude Code (Claude Opus 5.5) drafted this.
Imported from ivall/xcl. Originally posted by rdj415 on 2026-11-25T05:05:46Z.
@throny @milesah3ad Thanks for testing and the clear breakdown!
I split out just the per-frame PSO bind wait cap (
present::frame_generation+FrameBudget/XCL_PSO_FRAME_WAIT_MS, with deterministic unit tests and a paired 60 s smoke run on currentmain) into #2114 so it can be reviewed and tested independently from the commit-growth regression and the rest of the changes here.For the open question on #1452: on a longer Windows RTX 5060 Ti run of #2114 alone (
8044bed), the per-frame cap kicked in during world load (at694.8 s) and kept the title past its watchdog with 0 device removals, reaching the opening cutscene dialogue (72,927Opus packets decoded, 0 errors) and opening credits.Wait64BitValueXdid time out 40 times at 2,000 ms while cold compute pipelines were still compiling (46,227dispatches skipped), without triggering a device removal.Converting this PR to draft while breaking out the remaining pieces cleanly.
Imported from ivall/xcl. Originally posted by throny on 2026-11-26T00:48:18Z.
Two contributors checked independently and found that #1931 #2114 solves the same problem (for #505) in a different way: #1607, group D95. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:58:17Z.
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:24:14Z.
Triage (#1607) – head
5829b34This draft (+2892/-289) is stacked on #1274 and contains all of its code. On top of that it bundles several separate changes: the per-frame PSO bind wait budget, priority queues in
pso_async/dxc, skipping draws with pending pipelines, auto-init of uninitialized RT/DS targets, the NOT_ZEROED handling, and a WinHttpConnect hook that blocks*.backtrace.io.The per-frame budget is now in #2114 (same author, focused, default 250 ms per pipeline / 2 s per frame), and #1931 is an opt-in variant (
XCL_PSO_FRAME_WAIT_MS). The other parts have no open counterpart.It is far over the size limit; splitting the remaining parts into their own PRs, with #2114 carrying the budget, would make it reviewable.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.