Repository navigation
D3D12.X: reclaim ON_QUEUE uploads across all queues and clean up on release - #2912
real-alponzo wants to merge 269 commits into
Conversation
Each chained dispatch made a scratch buffer for all its groups and kept it until the allocator's reset. A retail title's 176 split programs need 187 KB a group (median), 3 GB for 960x540 pixels in groups of 8x4. At most XCL_SPLIT_SCRATCH_MB (256) of groups now run at once, each piece adding the slab's origin to the group ids, and the chains recorded on one list share the buffer.
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 (#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>
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 (#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 #1773. Co-Authored-By: Claude Fable 5.2 <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/xcl#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 #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 #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 #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 #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 #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)
…elease reclaim_completed_on_queue now drains completed InFlight batches across all tracked title queues so idle/secondary queues do not pin staging buffers. Also remove released queues from ON_QUEUE in q_release to avoid leaking fences/staging buffers and pointer-reuse ABA. Assisted-by: Antigravity (Gemini 4 Neon)
|
RDNA4 run next to your RX 6800 one: the two new tests pass, and the PR adds no failure. One Tested: head
The one that fails with and without the PR, also single-threaded (panic text from the The new tests make their device with Not tested: the full workspace suite, a soak or title run, NVIDIA (these tests don't follow AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
Title run on RDNA2 (the report above ran unit tests only): the 60 s pair is fine, but in 300 s runs this head lost the device in 2 of 2 runs, and its base in 0 of 2. There is also one review point in Setup: AMD Radeon RX 6800 (driver 32.0.21045.5002), i5-10600KF, 32 GB, Windows 11 Pro 26200, release. Head Regression run (60 s, after one warm-up run of base) 300 s,
Review point:
Reclaim across all queues. Not tested: the full suite on this head; whether the hang is in the release path or the cross-queue reclaim (no per-queue logging); NVIDIA. AI use: Claude Code (Claude Opus 5.5) read the diff, ran the builds and title runs, read the logs and wrote this comment. The numbers come from those runs on the hardware above. Correction, after a soak of the base: Update: full lib suite on this head ( |
|
Tested Clean
Both passed with zero failures, ignores or skips. Both logged the Arc A770 backend. The executable SHA-256 matched before, under and after the lock. Not tested A submit on one queue reclaiming completed uploads from a second tracked queue, final release with an upload pending, aggregate staging-pool totals during rendering, full workspace suite and retail smoke. These Arc results do not exercise the reported RX 6800 device hangs. AI use T3 Code / Codex ( |
|
Pending upload lifetime concern at The new cross-queue completed-batch drain checks each fence and looks appropriate for reclaiming idle-queue staging. The final-release hook needs the same ownership protection:
[INFERENCE] If final queue release occurs while an upload is pending, staging can therefore become reusable/freed before its consumer completes. This is independent of whether native queue destruction might subsequently wait. I have not reproduced GPU corruption/device removal, and am not attributing other reporters' device removals to this path. The new Suggested correction: remove the queue-address entry immediately to avoid stale-address reuse, but transfer unfinished batches and their fence/value into fence-owned retirement; reclaim only after completion or an explicitly handled device-teardown path. Do not block waiting while holding Actual PR base is |
Port #2912 so finished staging allocations are reaped even when the originating queue goes quiet. Assisted-by: Codex (exact model identifier unavailable)
|
This branch carries about 220 commits from an older amd-dev history that origin/amd-dev no longer contains. Only the top commit (baaf024) is this PR's change. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Reclaim completed
ON_QUEUEtexture upload batches across all tracked title queues and remove released queues fromON_QUEUEinq_release.Why
reclaim_completed_on_queuepreviously only polled the submittingqueue_key, allowing completed upload batches on idle or secondary command queues to keep staging buffers pinned until those queues uploaded again.q_releasecleaned uplist_xstate for the released queue but left its entry intitle_textures::ON_QUEUE, leaking itsID3D12Fenceand anyInFlightstaging buffers (up to 512 MiB) and risking pointer-reuse ABA if a later queue is allocated at the same address.What is in it
reclaim_completed_on_queueincrates/xcl/src/hle/d3d12x/title_textures.rsto drain completed batches across all tracked queues viadrain_completed.title_textures::on_queue_release(queue_key)and wired it intoq_releaseincrates/xcl/src/hle/d3d12x/real.rs.drain_completed_reclaims_only_finished_batchesandon_queue_release_removes_tracked_queue_entry.Regression run
Base (
main):PR head (
baaf024d):Tested
rustc 1.100.0, DXC 1.9.2602.17.cargo test -p xcl --lib drain_completed_reclaims -- --nocapture:1 passed; 0 failed; 0 ignored; 1695 filtered out.cargo test -p xcl --lib on_queue_release_removes -- --nocapture:1 passed; 0 failed; 0 ignored; 1695 filtered out..\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60on8b957becandbaaf024d(blocks above).Not tested
cargo test --workspaceonamd-dev(noteamd-devhas pre-existing no-GPU CI test failures unrelated to this change).AI use
q_releasecleanup, implemented the fix and unit tests, ran the tests and paired smoke runs, and drafted this PR description.