Repository navigation
D3D12.X: add opt-in gameplay graphics PSO frame budget, scale workers, and log slow compile hashes - #2988
D3D12.X: add opt-in gameplay graphics PSO frame budget, scale workers, and log slow compile hashes#2988Saksukella wants to merge 270 commits into
Conversation
In a pixel shader EXEC holds helper lanes (s_wqm), and on a primitive's edge the first lane of EXEC is often one. v_readfirstlane read that lane. An RDNA2 driver (RX 6700 XT, 32.0.21045) gives 0 for everything a helper lane holds once a WaveReadLaneAt ran inside a loop, quad reads included. A loop whose state the console's compiler carries in a vector register (v_mov v, s ... v_readfirstlane s, v) then read 0 back on each pass and ran to the loop budget: a retail title's volumetric light pass took seconds per draw at its world start and Windows reset the GPU (xcl-dev#675). v_readfirstlane now reads the first lane of EXEC that is live (ballot(true), per half in the wave32-in-64 form) when EXEC has one, and the first lane of EXEC as before when it has none. The value is the same: the console's compiler reads the first lane of a value equal in every lane, or of a lane it then removes from EXEC (a waterfall loop). The new GPU test draws that title's list-loop shape on two triangles sharing a diagonal. Without the change, on the RX 6700 XT, 69 of 1024 pixels run the loop 65 536 times (the budget) with wrong results; with it, none, and at most 16 passes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esent in flight)
A retail game unmaps addresses while it streams its world with
XMemMapPhysicalPagesScatter(addresses, n, NULL); it checks the result
and runs into its own int3 when the call fails (+0xb18de7, then its
crash reporter). XCL refused a NULL page array with
ERROR_INVALID_PARAMETER. Page 0 already means "unmap this address" in a
scatter, so no array is taken as page 0 for every address.
Test scatter_without_pages_unmaps: two pages mapped and written, unmapped
with no array (the call succeeds, the addresses are no longer committed),
mapped again they read what was written. It fails without the change
("refused").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title keeps its destination page lists in slots of its own table and writes a slot's pages after EnqueueRequest. At enqueue such a slot can still name the pages of the slot's previous request, and the snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the entries that are 0). Over 16 000 requests a run were written into pages the title had since reused: its objects got garbage pointers and it crashed about 20 s into world loading; when the old pages were freed, the request failed with E_ACCESS_VIOLATION. The console reads the list when it runs the request. execute() now reads it again (through read_own, as the snapshot) and takes it when it differs and every page in it is allocated (kernelx::physical_pages_live). A list that was on the enqueuing thread's stack keeps the snapshot: that memory is reused once the call returns, and a page ID written there since can belong to another live allocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heir pages with their texels A retail title places its streamed textures at full size and has memory behind their levels only as it loads them, the small ones first. vram::place_pages gives a sampled texture a 64 KiB page of video memory for every tile at once: when that title's world is set up about 92 % of those pages have nothing behind them (80 690 pages, 6 809 committed, on one card). With the switch (off by default) a sampled 2D texture of one slice is placed with no tile mapped. Its tiling is kept as groups of tiles, one for each level with tiles of its own and one for the packed levels, and a group gets its pages before the first upload that has texels for it - the same pages by address as before, so textures placed at one address still share them. A texture the GPU writes gets all its pages. Part of xcl-dev#1773. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… done When the GPU-wait watchdog releases a wait (xcl-dev#505), its lines say which queues wait on which, but not what the GPU is running. With XCL_GPU_CULPRIT=1 every dispatch XCL records (title lists, console-recorded lists, ExecuteIndirect of a translated compute pipeline) is wrapped in WriteBufferImmediate markers, in before and out after, one pair of words per PC list in a readback buffer. At a release the lists whose marker in is above their marker out are logged with the dispatches between the two: console CS (fnv64 of the title's bytecode), PC pipeline and groups. On the retail title of xcl-dev#505 (RTX 5080) this named, at each stall, one list with a run of 1-D dispatches of one CS whose first never finished; not the same CS from run to run. DRED breadcrumbs were tried first: they change the driver's pipeline cache keys, so every pipeline was built again and the title never got past its start. Off by default; without the variable nothing is recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…load Fixes, each run in a retail title's world on an AMD RX 9070 (16 GB): - list_x: a wait an earlier signal of the same cell or fence already satisfies is not part of a cycle (nvidia-dev 4cdb71f, f98a1d6). Every pipelined frame (wait N armed, signal N+1 next) counted as one: 16 false cycle breaks a run before, none after. - dispatch_chain: whole_in_cooldown takes CHAINS with try_lock, and a replaced chain is dropped after the lock: title threads blocked there. - bind: prelude job tables live in pooled 1 MiB persistently mapped blocks (64 kept) instead of a committed buffer per use: ~1 250 CreateCommittedResource a second during the world load before. XCL_TWO_PASS_LIST_MB sizes a list's two-pass record buffer (32 MiB, as before). - title_textures: a submit whose lists were all closed before the last write-watch look began, in the same frame, takes no look of its own (XCL_LOOK_SKIP=0: off). A quarter of the world's submits skip it. - sparse, vram: a submit waits on the CPU (XCL_SPARSE_CPU_WAIT_MS, 1 s) for the tile mappings its queue needs, then on the GPU only if they are late; placements no longer signal the sparse queue one by one. - pso_async: workers are throttled by the system's free commit, not its free RAM: the world load dropped free RAM to 1.3 GB with 12 GB of commit free, every worker idled and a bind waited 14 s for a compute pipeline. - real: pipelines waiting to be built (pso_async::lazy) share their copies of console shaders (same address, same bytes): ~80 000 of them in the first minute held 318 MB of copies after this. Diagnostics (XCL_ACTIVITY): - prof: a "profile (2 s)" line, where the title's threads waited in XCL: pipeline waits, submits (write-watch, sparse copies, texture uploads, list segments, driver), placements, frame events, presents. - flight: every queue XCL signals, with a stall warning after 1 s and, at a device removal or crash, the queues (the first stopped first) and the last 400 events; tile mappings and creations a line. After 3 s without GPU progress its thread reports the GPU culprit (XCL_GPU_CULPRIT=1) and after 8 s dumps the threads (XCL_STALL_DUMP=1): in the activity thread they never came, its DXGI query blocked in the hung driver. - memory_report (xcl-dev#2697): "memory by owner" against DXGI's budget, the title's committed resources alive by kind, and every 10 s the address space walked. - eh: thread dumps go 40 frames deep. Not fixed: the device is still removed 60-110 s into the world. The culprit report named an indirect compute dispatch in one run; in the others no dispatch was in flight and every queue waited.
A driver device limit can end workers during startup. Retry their batches once after the other workers finish, and count only batches that still fail. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Port xcl-dev#2865 to keep per-region budgets in compute and kernel shaders. Charge more budget for longer loops so a compute dispatch cannot spend its full iteration budget in a large loop. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Port xcl-dev#2868. Use the pipeline workers' free-commit measure so low free RAM alone does not stall big compiles. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Port xcl-dev#2859. Keep a readable dword beyond the logical blob length for the driver. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Port xcl-dev#2842. Check the fence after each event wake-up and keep a timed-out staging job alive while the GPU can still write to it. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
A shared fence could move backward as separate title queues completed out of order. Signal a separate fence on each source queue. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Port xcl-dev#2630. Smaller pools let more video memory return when a title frees runs of tiles and keeps the tiles between them. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Keep full read-write sparse pages GPU-only until the title touches them on the CPU. Preserve title-facing query and protection behavior for lazy pages. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Record the compute, graphics or mesh pipeline in the driver when compilation stops the process. Skip the recorded pipeline on later launches and retain the available shader diagnostics. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
Track active profiling spans, queue waits and submissions, and report the dispatch associated with a device removal. Assisted-by: Claude (exact model unknown), Codex (GPT-6 family, exact model unknown)
…s, and log slow compile hashes
|
Independent check of #2988 head
One policy point: Not tested: full workspace suite, Intel/AMD hardware, or a paired title smoke run. AI use: Codex (GPT-6.2 Sol) ran the exact-head and exact-parent tests and traced the frame counter; Codex (GPT-6.2 Astra) reviewed the attribution and wait policy. |
…AME_BUDGET_MS opt-in
|
Follow-up to my earlier NVIDIA report: I isolated the two pack-backed failures on the exact On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC, with
The mesh test should give each synthetic PSO its own frame budget or explicitly disable the frame cap while measuring translation. That would distinguish a stand-in from an actual failure to build the two-pass PSO. No title executable was run; no full workspace suite or paired smoke run was done in this follow-up. AI use: Codex (GPT-6.2 Sol) traced the wait path and ran these GPU tests. |
|
Thanks @thehollowedone for the thorough check and great policy catch! You're right that switching from 12 s to 32 ms at Present count 60 triggers during menu/loading screens and can skip cold graphics PSOs on world entry. Pushed an update keeping the default graphics frame budget at \12_000 ms\ (identical to \�md-dev, zero premature draw skips), while making \XCL_GFX_PSO_FRAME_BUDGET_MS\ strictly opt-in (caps graphics-only bind waits from frame 60 onward while leaving producer compute uncapped, with \XCL_PSO_FRAME_BUDGET_MS\ overriding all frames). High-core/high-RAM worker scaling (\6 -> 10\ on >=16T / >=24GiB) and >= 500 ms\ slow-compile shader record hash logging remain enabled by default. Updated \rame_budget_keeps_default_12s_and_honors_opt_in_gfx_and_explicit_overrides\ (\38/38\ passed in \pso_async). |
|
Full suite on NVIDIA (listed under Not tested) on the new head Tested:
From reading: Not tested: a title on NVIDIA with this branch, a 24 GB+ host with 16+ threads (the new worker scaling), a release build, Intel. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
I compared parent
The probe verifies policy output and record selection. It did not start PSO workers or run a driver compile or a title. AI use: OpenAI Codex (GPT-6) prepared and ran the probe and drafted this report. |
|
RDNA3 data at gameplay frames for #2988, taken at the old head Setup: RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003, Ryzen 7 5700X3D (16 logical CPUs), 64 GB, Windows 11 build 26200, DXC 1.8.2502.11, release builds of the unmodified commits
Not tested: AI use: Claude Code (Claude Sonnet 5.5) built the trees, ran the title, read the logs and wrote this comment. Every number comes from those runs. |
bmjask
left a comment
There was a problem hiding this comment.
The opt-in frame-budget transition leaves producer compute uncapped, and I found no concrete defect in that policy implementation. The current PR combines three logical changes, however: gameplay wait policy, worker-count scaling, and slow-compile logging. They have different risks and rollback criteria and should be split under the repository contribution rules.
Please also validate the enabled gameplay-budget path in the smoke run; the supplied default-path smoke does not exercise the principal behavior change. Worker scaling needs a high-commit-pressure run, not only pure unit tests.
Reviewed at 6f5e03c with Codex (GPT-5).
|
Only the top two commits are this PR's own (dd0b65f, 6f5e03c in AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Introduces a dynamic boot-to-gameplay graphics PSO frame wait budget, scales default PSO compile worker threads on high-core / high-RAM hosts, and logs shader record hashes for slow driver compiles (
>= 500 ms).Motivation & summary of changes
On AMD RDNA 4 (RX 9070 XT), world entry hits hundreds of uncached 3D graphics PSOs. Because
DEFAULT_FRAME_BUDGET_MSwas12,000 msacross all frames, a single 3D gameplay frame hitting 10–13 unready graphics PSOs stalled the title thread for 5–6.5 seconds per frame (237.8 s total in a 240 s run) before falling back to stand-ins anyway. Meanwhile,pso_worker_threads()remained capped at 6 even on 16–24 thread / 32+ GiB systems, and slow driver compiles (>= 500 ms) did not log the shader record hash withoutXCL_PSO_TRACE=1.crates/xcl/src/hle/d3d12x/pso_async.rs):FrameBudgetPolicy::{Explicit, Dynamic}withGAMEPLAY_FRAME_BUDGET_MS = 32starting atGAMEPLAY_FRAME_BUDGET_START_FRAME = 60.frame < 60) keep the existing12,000 msbudget; once active rendering is flowing (frame >= 60), graphics PSO bind waits cap at32 ms/framewhile background workers finish compiling them in parallel.XCL_PSO_FRAME_BUDGET_MS(orXCL_GFX_PSO_FRAME_BUDGET_MS) always overrides uniformly across all frames.p.compute == true/wait_for_submit) are completely untouched (fcap = None).crates/xcl/src/hle/d3d12x/pso_async.rs):pso_worker_threads_for(logical_cpus, total_ram_gib): hosts with< 16logical CPUs or< 24 GiBRAM keep the existing2..=6cap; hosts with>= 16CPUs and>= 24 GiBRAM scale to(logical_cpus / 2).clamp(6, 10)(protected by81c04142commit-headroom gating). ExplicitXCL_PSO_THREADS/XCL_DXC_THREADSalways override.crates/xcl/src/hle/d3d12x/real.rs):driver_compile_identifiednow logs any compile>= 500 mswith its 64-bitrecordhash and driver blob status without requiringXCL_PSO_TRACE=1, andfinish_two_passsupplies the two-pass console shader hash on all 3 call sites.Tested
amd-dev(bf7c82ee+dd0b65f1,--test-threads=1, 0 new warnings):cargo test -p xcl --lib pso_async -- --test-threads=1:38 passed; 0 failed, including new pure-CPU unit tests:dynamic_frame_budget_transitions_after_boot_and_honors_explicit_overridepso_worker_threads_scales_with_cpus_and_ramcargo test -p xcl --lib big_compile -- --test-threads=1:15 passed(1 pre-existing unrelated failuregiant_driver_compiles_have_their_own_laneonbf7c82eebase).Not tested
< 16logical CPUs or< 24 GiBRAM (verified viapso_worker_threads_scales_with_cpus_and_ramunit test).Regression run
Baseline (
main,b49be183):This PR (
dd0b65f1onamd-devbf7c82ee):AI use