D3D12.X: build console pipelines at their first use (retail title: 45+ GB → 17 GB) #162
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!162
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/162/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?
@Sr-0w on GitHub · 2026-11-23 18:01 UTC · original
Sr-0w:lazy-pso→main· +184 −24 · 3 files · 4 commits · closed without mergingProblem
The retail title (GDK) creates ~51 000 distinct pipelines in its first 30 s (measured: a translation-keyed cache found only 33 duplicates). Built at creation, each stays in AMD's driver heap (
amdxc64.dll, ~400 KB per pipeline, measured with anNtAllocateVirtualMemorytrace): private commit climbed past 45 GB and the system ran out of commit.While the shader queue was long, title threads without a stand-in waited in their own
Create*PipelineStatecall behind thousands of background DXC jobs (most held bywait_for_memory). The game's watchdog (+0x2215a60) kills the process when a thread stays silent ~30 s.Change
pso_async::submit_lazy: pipelines with console shaders (graphics without HS/DS/GS, compute) get their stand-in at creation and are sent to the workers on their firstresolve.resolve_wait(compute) builds a not-yet-sent pipeline on the spot.XCL_LAZY_PSO=0restores build-at-creation.dxc::urgent: compiles requested from a title thread that waits for them (the sync fallbacks with no stand-in) run immediately on their ownxcl-dxc-urgentthread, not behind the pool queue / memory gate (still counted inWORKING).pc_topology_type(console rect list19/0were refused with0x80070057, so the title waited for the full translation instead).Result (retail title 1.0.2.1, AMD GPU, 64 GB)
No more watchdog kill from starved pipeline creation. (The game then stops on Xbox depth-format issues: separate PR.)
Test plan
cargo test --release -p xcl --lib: 534 passed; the 1 failure (gpu_wave64_ps_whole_wave_reductions) also fails onmainpipelines are built at their first use (n created so far)XCL_LAZY_PSO=0to compare)🤖 Generated with Claude Code
@Krigsexe on GitHub · 2026-11-23 18:07 UTC · original · edited 2026-11-23 18:08 UTC
Heads-up: this repo isn't about any specific retail title. Naming a build version and binary offset in a public PR is a quick way to get the whole repo DMCA'd. Better to keep it generic to D3D12.X pipeline creation. @Sr-0w & @claude
@ryosen0 on GitHub · 2026-11-23 18:12 UTC · original
Tested
pull/162/head(lazy-pso, commit73c8e74) on this title, Windows 11 host, RTX 3060 Ti (wave32),XCL_NETWORK=0:The null-write crash is unchanged —
game_scarlett_master.exe+0x2215c35 (write at address 0x0), identical registers to the non-lazy run:Differences with lazy-pso:
translated_pipelines: 3(most now deferred to first use),failed_pipelines: 641,presents: 2, unique shaders 4,536 — same ballpark;PSO stream rejected (0x80070057), the fallback version too.Two conclusions this rules in/out:
+0x2215a60—+0x2215c35is a different site (+0x1d5 away), and lazy building changed the timing without moving the crash. So it's a genuine null-deref, not a thread-silence kill.rax=0x140004380) regardless of when that pipeline was built. The0x80070057rejections —topology type 3, 2 render targets, DSV format 118, HS false, GS false— look like the upstream cause; this matches the AS/MS subobject suspicion in HANDOFF. PR #163 (D16S8 depth formats) is likely relevant since DSV format 118 (D16S8) is in that rejected stream.Happy to re-run any candidate fix (AS/MS numbering, or #163) on this title and report register-level diffs — fast turnaround on our side.
@gefydev on GitHub · 2026-11-23 18:11 UTC · original · edited 2026-11-23 19:05 UTC
Update 18:16 UTC:
mainmoved to956a476while I measured. Itsresolve_waitnow also builds a pipeline no worker has started, so on the same benchmainis at 0.58 / 0.60 / 0.62 s for the last one and 7.35 / 7.39 / 7.36 s for all 200. Themainrow below is the olderdb5dc26. The queue wait is no longer a difference between this PR andmain; the lazy build is, and points 1 and 2 are about that. This PR conflicts withmainnow.I had a smaller change for the same wait ready (a waited-for pipeline moves ahead of the queue) and found this PR in my last duplicate check, so I did not open mine. I tested this one instead.
Machine: Ryzen 5 1600 (6C/12T), 16 GB RAM, ~13.5 GB commit free, GTX 1650 4 GB (driver 32.0.16.2124, 32-lane waves), Windows 11 26300, DXC from SDK 10.0.26100. No retail title was run here. PR head
73c8e74ondb5dc26, debug build.Tests:
cargo test --workspace: 535 lib tests pass, 0 fail, 2 SKIPPED (no wave64). The other suites pass. e2e passes aftercargo build --workspace; my first run failed only because I had not built the test title.Synthetic bench: 200 pipelines, each one DXC compile of a different CS, no cache, no driver PSO, 11 DXC threads. 3 runs each.
maindb5dc26,submitsubmitsubmit_lazy, 1 title thread, all usedsubmit_lazy, 4 title threads, all usedThe
mainruns and this PR's were not interleaved with each other (minutes apart on the same machine). The wait behind the queue is gone. Two things I noticed:counts()still counts every unfinishedPending, so lazy pipelines that were never used count as building (measured: 200 of 200 before any use).present::show_compilingtreatsqueued > 0as active, so from reading the code the window title would say "compiling shaders: … N pipelines queued" for the whole run, andreport.jsonbackground_pipelineswould include them. Counting only those that were sent (queued) or whosejobis already taken would fix it.When pipelines are used right after they are bound, they are built one at a time per title thread.
resolveat bind sends the pipeline, but the draw / dispatch that follows takes the job back inresolve_waitif no worker got it first, so the worker pool seems to stay mostly idle (45 s against 7.4 s above). It is the worst case (every pipeline used, bind then use at once, no other work between them) and it does not count what you save by never building the rest, so it may well be the right trade for a title that creates ~51 000. It is the first-use hitch your last test-plan item asks about. Each waiting thread also skipswait_for_memory, so the gate's limit does not hold for them.My version's tests (queue order, waiting twice, a blocked worker) are yours if useful; I can send them as a patch.
@Sr-0w on GitHub · 2026-11-23 19:19 UTC · original
Found the cause of the device removal I attributed to deferring compute pipelines: invalid UAV descriptors on depth buffers whose UAV flag #163 drops, used by a dispatch. #163 now writes a null view for them. With that, deferring compute pipelines too works (
XCL_LAZY_COMPUTE=1locally): private memory stays around 20 GB at 35 s, vs 60+ GB and rising without it. The game then gets further (it creates those shadow-map UAVs) and stops at ~35 s on amemsetto a null pointer in title code (+0x5ebea33, a 256 KB R32_FLOAT buffer whose allocation returned null). I am investigating that before proposing compute deferral again.🤖 Generated with Claude Code
@gw1337x on GitHub · 2026-11-23 20:19 UTC · original
Setup: AMD Radeon RX 7800 XT (RDNA3, 16 GB), driver 32.0.32015.7029, 32 GB RAM, Windows 11 Pro 26200, GTA VI retail,
XCL_NETWORK=0, release build.Test branch:
main956a476+ #170 (incl. #163 @634c423) + #162 @641f551+ #168 @070a737+xg.rsof #169 + #176 + #164.Data point for compute deferral, with the view-format fixes I posted on #163 and #168 in place: deferring compute pipelines works on this machine and it is what makes the difference with 32 GB of RAM.
XCL_TRACE_ALLOC(#164): without compute deferral,amdxc64.dllgrows 4.7 → 23 → 48 GB (15 / 30 / 45 s), all undertranslated_compute_pso→CreateComputePipelineState. Private commit of the game process reaches 76–90 GB, the working set drops to ~0 (paging), and the game's watchdog (+0x2215c35) fires at 50–54 s. A warm translation cache made no difference.XCL_DXC_THREADS=4made no difference either.amdxc64.dll(tracer, cumulative)(I restored the compute branch of
73c8e74behindXCL_LAZY_COMPUTE=1.)Related:
dxc::wait_for_memorychecksullAvailPageFile, which on a system-managed page file keeps growing (the commit limit went 84.8 → 113 GB during a run), so the gate never held anything back while physical memory was exhausted.Next stop with deferral on:
DEVICE_HUNG(0x887a0006) at ~26 s. In a debug-layer run of the same build, the last error before it stopped wasIASetIndexBuffer: pDesc->BufferLocation 0x...2480 does not belong to any existing Resource or Heap(title memory outside the GPU windows, I think).🤖 Generated with Claude Code
@Kalmarv on GitHub · 2026-11-23 20:33 UTC · original
I tested disposal, concurrent first use and build failure at the scheduler boundary on PR head
641f55143864349fa3a5dd02557512af8fe0e43dand main956a476bf738a098f39df4f4c8acef682e43030f(Windows x64 MSVC, Rust 1.99.0). These were synthetic closures. The surrounding D3D12.X tests ran on the RTX 5070 Ti workstation.Repeated binding after failure continued to return the stand-in. The first draw can still block while a build is in flight:
crates/xcl/src/hle/d3d12x/bind.rs:291callsresolve_waitbefore drawing. A nonblocking graphics bind alone therefore gives no bound on first-draw latency.The PR adds no tests. The affected module plus two reviewer tests gave 56 pass / 0 fail on the PR head and 55 pass / 1 fail on main; the eager-disposal negative control accounts for the difference. The fixtures cover two concurrent waiters and an ordinary failed build. Driver compilation time, frame-time distribution, process memory and retail execution were outside this test. AI-assisted review.
@Sr-0w on GitHub · 2026-11-23 20:42 UTC · original
Compute pipelines are deferred again, now by default (
XCL_LAZY_COMPUTE=0turns it off). The device removal this deferral caused earlier came from invalid depth-buffer UAVs, which #163 now fixes. Without the deferral, GTA VI makes no dispatch in 80 s and reaches 96 GB of commit. With it, it stays around 20–40 GB and gets to its title screen and menus. Screenshots are in #203. Marked ready for review.🤖 Generated with Claude Code
@ivall on GitHub · 2026-11-23 20:52 UTC · original
Main now creates console pipelines at their first use by default (
956a476+38b05b7:pso_async::lazy,XCL_LAZY_PSO=0turns it off). A graphics pipeline is translated and sent to the workers at its first resolve, and a compute pipeline is built at its first bind. With that, and the page-based placement of GPU-owned textures in38b05b7, the retail game reaches its first menu at ~19 GB of commit. This branch now conflicts with main. Could you check against current main whether anything here is still needed, for example the disposal and concurrent-first-use behaviour Kalmarv tested?@Sr-0w on GitHub · 2026-11-23 22:08 UTC · original
Checked against current main (
7a033c8): main already builds console pipelines at first use, graphics at first resolve and compute at first bind. With it, the retail game gets past its title screen and into its world without this branch. The only thing left here is dropping a deferred build whose stand-in is released before its first bind (the disposal case Kalmarv tested). It saves some wasted compiles but isn't needed for correctness, and I haven't measured a difference from it. Closing. I can reopen a small PR for that part alone if you want it.🤖 Generated with Claude Code
@Sr-0w on GitHub · 2026-11-23 19:03 UTC · original · edited 2026-11-25 13:07 UTC
Update after
956a476("Retail game reaches 30 fps"):maininto this branch.pso_asyncnow keeps yourjob/completestructure and only adds the first-use part (queued,submit_lazy,send).956a476, building GTA VI's compute pipelines at their first dispatch got the device removed ~20 s in (0x887a0001, nothing from the debug layer before it). I bisected my 4 PRs on top ofmainand only this deferral did it. With graphics deferral only, it runs at 30 fps likemain.main. Private commit during the first minute:main13 → 18 → 30 → 38 → 39 GB, this branch 15 → 19 → 27 → 38 → 44 GB. Both then hit the same spike (up to 162 GB onmainhere, 64 GB RAM): withXCL_TRACE_ALLOC(#164) it isamdxc64.dllcompiling pipelines plus XCL's translation of big compute shaders (translate/emit, called fromdev_create_compute_psoon a title thread). That matches the 1 MB ray-tracing programs in HANDOFF.Converting to draft: as it stands, this does not earn its complexity on current
main. Thedxc::urgentpart (compiles for a title thread that waits, run ahead of the queue) may still be worth taking on its own. Tell me if you want it split out.🤖 Generated with Claude Code
@Kalmarv on GitHub · 2026-11-25 14:19 UTC · original
@Sr-0w no need to split out
dxc::urgentfor my sake. You measured that it doesn't earn its complexity on currentmain, and I agree with keeping it out. Thanks for checking.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Pull request closed