Repository navigation
D3D12.X: a draw waits at most 4 s for a pipeline still building (#232) - #267
heretic1321 wants to merge 1 commit into
Conversation
e31d30f to
b5c9057
Compare
|
Review of b5c9057 against main 9ab7d76. The limit does what the description says in a synthetic frame (numbers below). Five things I would change or settle before it goes in. 1. The 4 s default is not tied to a known threshold.
2.
3. Merged with #214 (f007d4a) the tests do not compile.
4. The limit is one budget per present interval for the whole process, not per draw or per thread.
5. A draw past the limit is lost, not delayed.
Tested Synthetic frame, the same test on both trees (
Not tested
🤖 Claude Fable 5.2 |
|
Tested on an NVIDIA RTX 3080 Ti (Windows 11 10.0.26300, driver 32.0.16.2124, DXC 1.9.2602.17, package 1.0.2.1 verified by hash). Built this branch on top of Result: the run still dies at the early assert before any frame — this PR does not change it here.
Two data points that may matter for the hypothesis:
Happy to run any revision of this PR on the 3080 Ti and return reports/traces. AI-assisted (Claude Code CLI via a model proxy). |
Part of ivall#232. The null write at title+0x2215c35 is the retail game's watchdog (`*(int *)0 = 0` after a stale watched timestamp, decoded in ivall#232; one 23 s call set it off in ivall#156), not a bad pointer from the layer: it fires when a watched thread of the title stops posting. With lazy pipelines a graphics pipeline is sent to the workers at its first SetPipelineState (`resolve_for_bind` -> `resolve`), and then `bind::graphics_bound` / `execute_indirect` call `resolve_wait`: that waits for the build without any limit, and runs it in the title's own thread when no worker has taken it yet. An NVIDIA driver takes 10-17 s for one big translated pixel shader (ivall#156 measurements), so a frame that binds a few new ones holds the title's thread for that long. Now each draw sends the build to the workers and waits at most 4 s (`XCL_PSO_WAIT_MS`, 0 = no limit as before; per draw, so no draw gets only what another left). Past it the draw goes with the stand-in and is lost: counted in report.json (`d3d12.standin_draws`) and logged. An indirect draw with a stand-in gets the title's graphics root signature first, as direct draws do. Compute pipelines are still waited for. Any pipeline wait of 2 s or more is logged with the thread. 4 s is a safety margin, not a measured watchdog threshold. Assisted-by: Antigravity (Claude Opus 5.5)
b5c9057 to
043d1f7
Compare
Part of #232. This is a hypothesis with instrumentation. I have not run the title, and I have no NVIDIA card. Rebased on
4017f8f. Updated for Kalmarv's review; the per-point answers are under Review.Root cause (hypothesis)
title+0x2215c35is the title's watchdog (MKS2508's decode in Retail GTA VI: null write at +0x2215c35 (#159) still hits on NVIDIA RTX 4070 Ti, with and without XCL_NETWORK=0 #232). It wakes once a second, compares the watched timestamps against a constant300.0behind a random gate, then writes*(int *)0 = 0. In NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156 one 23 s call set it off. The layer does not hand the title a null pointer. In First-run report: retail GTA 6 package (game_scarlett_master.exe, Series 1.0.2.1) — boots, 1,042 translated pipelines, 2 presents, deterministic null-write crash #159 and Retail GTA VI: null write at +0x2215c35 (#159) still hits on NVIDIA RTX 4070 Ti, with and without XCL_NETWORK=0 #232 the crash came only in runs where frames stalled.xcl-psoworkers at its firstSetPipelineState(cl_set_pipeline_state→resolve_for_bind→resolve). The draw that follows then waits for it with no limit:bind::graphics_boundandexecute_indirectcallresolve_wait. That runs the build in the title's own thread when no worker has taken it yet, and otherwise blocks until the worker's build is done.af20b4b(the reporter's base) has the same path. NVIDIA takes 10–17 s for one big translated PS (NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156), so a draw can hold a title thread far longer than the watchdog allows.xcl-pso-Nworker in the same wait" does not tell idle workers from workers waiting on the DXC pool. vladbondarenko97's 3080 Ti run dies at an earlier assert (+0x2237178) before any frame, so it says nothing either way about this path.main,bind_abicallsresolve_waitbeforepso_user_sgprs, which is the right order. A wrong merge there only gives compute shaders wrong arguments on the GPU. It cannot make the CPU write to 0.Change (
pso_async.rs,bind.rs,real.rs)pso_async::resolve_for_draw, used bygraphics_boundandexecute_indirect. A graphics pipeline that is still building goes to the workers, never into the title's thread. Each draw waits for it at mostXCL_PSO_WAIT_MS(default 4000;0= no limit, the old behaviour). Past that the draw goes with the stand-in.execute_indirectwith a pipeline that is not translated (a PC pipeline, a stand-in past the limit, a failed build) binds the title's graphics root signature first, asgraphics_bounddoes.report.json → d3d12.standin_drawsand logged.Review (Kalmarv, on
b5c9057)ExecuteIndirectwithout the title's root signature: fixed. The not-translated branch now bindsrs_gfxbeforepc(…). It does this for every pipeline in that branch, not only stand-ins, the same asgraphics_bound. Binding the graphics root signature changes no compute state, so an indirect dispatch with a PC compute pipeline is unaffected. Test:bind::tests::execute_indirect_with_a_stand_in_binds_the_titles_root_signature_firstrecords the call order on a fake list and checks thatSetGraphicsRootSignature(rs)comes beforeExecuteIndirect. It fails without the fix (onlyExecuteIndirectis recorded).XCL_PSO_WAIT_MS, with no shared state and no tie toPresentX. Why per draw rather than per thread:PresentX.XCL_PSO_WAIT_MS=1makes the total about N ms.300.0is milliseconds (the decoder's reading, and consistent with NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156's 23 s trigger), then a 4 s wait is far over and only a limit near zero helps.> 2.0check on a 1000 ms sleep, which would then discard every sample. If the unit is seconds,300.0is 5 minutes, and no wait inside a process 73–93 s old could trip it, so this hypothesis would be wrong.XCL_PSO_WAIT_MS=1) and the breakpoint in step 5 settle the question.mod draw_wait_tests. If D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214 lands first,resolve_withinshould callenqueue(p.clone())instead of its ownsentswap +send, so that a pipeline first sent by a draw is counted inQUEUED(the third number ofbackground_pipelines). My earlier account of D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214 described an older head:f007d4adoes not changeresolve_wait.DRAWS_PCdraw, indistinguishable inreport.jsonfrom a draw with a PC pipeline. It is now counted on its own inreport.json → d3d12.standin_draws. Also as you noted: the build is no longer taken by the thread that needs it, so it waits its turn behind everything queued atSetPipelineState. With a deep queue, or D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214's two driver slots on NVIDIA, the limit buys less progress on the pipeline being drawn.Overlaps
precompile --pipelineson its own threads): only touchescrates/xcl/src/shaders.rs, the offline tool. Composes, no conflict, not redundant. A pre-filled driver cache makes long draw waits rarer.f007d4a, bound driver compile concurrency, plus D3D12.X: build console pipelines at their first use (GTA VI: 45+ GB → 17 GB) #162 / Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187 / D3D12.X: map Scarlett GDK mesh shader subobject slot 24 to PC slot 25 and add console stubs #206): caps driver compiles on the workers. It does not bound how long the title's thread waits, so neither PR makes the other redundant. With both applied, a draw's build queues behind the capped workers and the limit runs out sooner: more lost draws, no stall. Merged with this head, it auto-merges; the merged-tree check result is under Tested. Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187 merged cleanly with the previous head (Kalmarv).What the reporter must verify on the 4070 Ti
On plain
main+ this branch, with no local #203 / #211 / #215 merges, release build, the same package:XCL_NETWORK=0 XCL_ACTIVITY=1 xcl run <game>. Check whether+0x2215c35still happens, and note the presents andd3d12.standin_drawsinreport.json.waited .* for (graphics|compute) pipelineandnot built after. A long compute wait right before the crash points at the compute side, which this PR does not change.XCL_PSO_WAIT_MS=1: draws don't wait for pipeline builds at all. If the crash still comes with this, draw waits are not what the watchdog sees.XCL_PSO_WAIT_MS=0(the old unbounded wait). If the crash comes back only here, this is the cause.0x142215C35and dump 4 KiB at0x146844A20(the decode's timer table: 57 slots × 72 B). The slot with the oldest non-zero timestamp names the stalled subsystem, and the difference tonowgives the threshold's unit. Or attachXCL_THREAD_DUMP_AT=40,65dumps.Tested
043d1f7on4017f8f:AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspace --target x86_64-pc-windows-msvcexit 0, no warnings, and the same with--testsexit 0.pso_async.rsunchanged in a throwaway Linux crate, with stubs only for the log macros,compile_threads,present::activityand the COM release:draw_wait_tests2 passed, 0 failed. Sabotage check (previous head, same wait logic): with the oldresolve_waitpath put back, the draw runs the blocked build itself and the test hangs (killed bytimeout 30).bind::tests::execute_indirect_with_a_stand_in_binds_the_titles_root_signature_firstcompiles; I did not run it (Windows only).f007d4a(merge without conflicts):AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release -p xcl --lib --tests --target x86_64-pc-windows-msvcexit 0 (the E0428 from the twomod testsis gone). Not run.b5c9057) on an RTX 5070 Ti; see the review. Those numbers are not for this head.Not tested
cargo test --workspaceon Windows, the GPU suite,scripts/smoke.ps1on any title.AI use