Repository navigation
D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) - #214
heretic1321 wants to merge 1 commit into
Conversation
01d686b to
bf2a27e
Compare
Tested on Windows + NVIDIA (RTX 4090)The PR says it was never built or run on Windows, so here is a Windows / NVIDIA run. No retail game here, so the measurement plan above (thread dumps, Setup: Windows 11, i7-13700KF, RTX 4090 (driver 32.0.16.2101, wave32 only), Rust 1.100 MSVC, Agility SDK 1.620.2, Windows SDK DXC 1.8.2502 (and DXC 1.9.2609 for E2).
E2 (
On this NVIDIA card the DXC step dominates, not the driver: the heap windows cut DXC ~12× and the driver's one cold compile ~6× against the One thing from reading the code (not measured – no game)Title-thread compiles now wait on the background slots. Before this PR only Minor: AI-assisted (GitHub Copilot); runs and numbers are from my machine. |
|
Tested on an RTX 5070 Ti, merged onto What it fixes, shown on
Notes:
E2 (from #187) at 700 blocks / 19,601 instructions. Each cell is DXIL bytes, median DXC seconds, and the range of three driver times in seconds:
Tested
Not tested
🤖 GPT-6.2 Astra, Claude Opus 5.5 |
Part of ivall#232. The null write at title+0x2215c35 is the retail game's hang watchdog (`mov dword [0], 0`, identified in ivall#156), not a bad pointer from the layer: it fires when one of the title's threads stays silent for long (~30 s per ivall#214). 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 past its watchdog. Now a draw sends the build to the workers and waits at most what is left of 4 s between two presents (`XCL_PSO_WAIT_MS`, 0 = no limit as before). Past it the draw uses the stand-in (draws nothing), logged per pipeline. Compute pipelines are still waited for as before. Every pipeline wait of 2 s or more is logged with the thread, so a run shows what held it. Assisted-by: Antigravity (Claude Opus 5.5)
bf2a27e to
f007d4a
Compare
f007d4a to
960162e
Compare
Draft mitigation + stage instrumentation for #156, rebased cleanly onto
upstream/main(4017f8f, tip960162e; untested on Windows/GPU by me — thank you to @yous0serious and @Kalmarv for the RTX 4090 / RTX 5070 Ti runs and reviews).Review responses (@yous0serious, @Kalmarv)
xcl-pso-urgentthreads waiting behind backgroundxcl-pso-Nslots (both reviewers):DriverCompileGuard::enternow gates only backgroundxcl-pso-Nworkers (is_background_pso_worker_name:starts_with("xcl-pso-") && != "xcl-pso-urgent") onBIG_COMPILES,wait_for_commit(), anddriver_compiles(). Title threads (dev_create_*_pso,resolve_wait) andxcl-pso-urgentbypass both semaphores andwait_for_commit()completely so a blocking bind never queues behind unrelated background compiles or a 30 s commit wait, while still updatingDRIVER_COMPILINGand timing logs (lane=urgentvslane=bg).urgent_and_title_threads_are_exempt_from_background_slotssaturating bothBIG_COMPILESanddriver_compiles()and verifying both the caller thread and anxcl-pso-urgentthread enter immediately.DriverCompileGuardnow recordswait_startedbefore semaphore / commit-wait admission, logs both compile duration and admission wait ({elapsed:.2}s (wait {waited:.2}s, hr=..., concurrent=..., {lane})), and triggers the slow-compile log when eitherelapsed >= 2 sorwaited >= 2 s(orXCL_TRACE_PSO_TIME=1).QUEUEDassertion indormant_lazy_pipelines_are_not_counted_as_queued(@yous0serious):mark_enqueued(p, queued)andfinish_pending(p, real, queued)inpso_async.rsand updated the test to assert against a localAtomicUsize::new(0)instead of reading globalQUEUED, eliminating parallel-test flakiness.XCL_BIG_PSO_KBalready exposes the threshold at runtime (e.g.XCL_BIG_PSO_KB=128with DXC 1.9) without recompiling.upstream/main(4017f8f) —#187/#162/#206are no longer stacked here,main'sretry_without_rect_gsstays insideDriverCompileGuard,standin_graphicsusesmain'spc_topology_type, andpso_async.rsis onmain'ssubmit_as/resolve_wait.real.rs+present.rs: background driver concurrency limits (DriverCompileGuard), 30 swait_for_commitcap, admission + compile timing, and window-title driver progress;pso_async.rs: lock-freeQUEUEDaccounting + isolated unit test;real.rs:fallback_streamsubobjects14/15/16+translated_gs_psoRTV/DSV format conversion.What is in it
crates/xcl/src/hle/d3d12x/real.rs:DriverCompileGuardbounding background (xcl-pso-N) driverCreate*PipelineStateconcurrency across all translated paths (CS,VS+PSwrappingretry_without_rect_gs,MS-mesh/MS-cs,GS-mesh/GS-cs):BIG_COMPILES(1) →wait_for_commit()(30 s cap + warning) →driver_compiles()(XCL_DRIVER_COMPILE_THREADS, default2on 32-lane-only / NVIDIA,4on 64-lane). Title andxcl-pso-urgentthreads are exempt from both semaphores andwait_for_commit().driver_compile_counts(), admission + compile timing (>= 2 sorXCL_TRACE_PSO_TIME=1), and unit tests (big_compile_serialization_leaves_fast_lane_for_small_compiles,urgent_and_title_threads_are_exempt_from_background_slots).fallback_stream(subobjects14/15/16) and RTV/DSV format translation intranslated_gs_pso.crates/xcl/src/hle/d3d12x/pso_async.rs:counts()via atomicQUEUED+mark_enqueued/finish_pending/enqueuehelpers excluding dormant lazy stand-ins, plus isolated unit testdormant_lazy_pipelines_are_not_counted_as_queued.crates/xcl/src/hle/d3d12x/present.rs:compiling shaders: N dxc, M done, D driver (C done), Q pipelines queued).Overlaps
ed5322f,shaders.rs— precompile--pipelineson its own threads): zero file overlap; composes cleanly (offline precompile vs runtimexcl run).e31d30f,pso_async.rs+bind.rs— draws wait at most 4 s a frame, never build graphics on the game thread): minor conflict inpso_async.rs(resolve_withinshould callenqueue(p.clone())if both merge); strongly complementary because D3D12.X: a draw waits at most 4 s for a pipeline still building (#232) #267 routes more graphics builds toxcl-pso-Nworkers where ourDriverCompileGuardbounds driver concurrency.Validation & what was NOT tested
960162e:AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspace --target x86_64-pc-windows-msvc— exit 0 (6.31s, 0 errors, 0 warnings).AR_x86_64_pc_windows_msvc=llvm-ar cargo check --tests --workspace --target x86_64-pc-windows-msvc— exit 0 (2.77s, 0 errors, 0 warnings).cargo testexecution on this revision (960162e).AI use
Gemini 4 Neon (Antigravity CLI), human-reviewed. Single commit on
upstream/main4017f8f, 3 files (+360/-38 lines). Compile-checked forx86_64-pc-windows-msvcon Linux; no Windows, GPU or title run.