D3D12.X: reclaim ON_QUEUE uploads across all queues and clean up on release #2912
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!2912
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2912"
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?
@real-alponzo on GitHub · 2026-11-26 22:55 UTC · original
real-alponzo:fix/amd-on-queue-reclaim→amd-dev· +69 −13 · 2 files · 1 commits · openReclaim 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.@DarkPanda69 on GitHub · 2026-11-26 23:16 UTC · original
RDNA4 run next to your RX 6800 one: the two new tests pass, and the PR adds no failure. One
title_texturestest already fails onamd-devwithout the PR.Tested: head
baaf024applied on its baseamd-devbf7c82e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010.cargo test -p xcl --lib -- drain_completed_reclaims_only_finished_batches on_queue_release_removes_tracked_queue_entry --nocapture: 2 passed, 0 failed, 0 SKIPPED.cargo test -p xcl --lib -- title_textures, 3 runs at--test-threads=4and 1 at--test-threads=1:amd-devalone: 33 passed, 1 failed every time (and one of the 4-thread runs also hadgpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_releasedandplaced_title_textures_share_vram_and_preserve_pixelsfail).The one that fails with and without the PR, also single-threaded (panic text from the
amd-dev-alone run):The new tests make their device with
D3D12CreateDevice(None, ..), so they ran on the first adapter, the RX 9070 XT here.Not tested: the full workspace suite, a soak or title run, NVIDIA (these tests don't follow
XCL_ADAPTER), Intel.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@vibryxcx on GitHub · 2026-11-27 00:08 UTC · original · edited 2026-11-27 03:30 UTC
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
on_queue_releasethat could explain a GPU-side problem. I have not shown that it does.Setup: AMD Radeon RX 6800 (driver 32.0.21045.5002), i5-10600KF, 32 GB, Windows 11 Pro 26200, release. Head
baaf024dvs its baseamd-devbf7c82ee, each in its own worktree with no uncommitted changes. Same retail title, warm caches.Regression run (60 s, after one warm-up run of base)
300 s,
XCL_PRESS_A_ATevery 10 s, alternating base / headbf7c82eebaaf024d0x887a0006at 239 sXCL_DRED=1)bf7c82eeXCL_DRED=1)baaf024d0x887a0006at 273 sXCL_DRED=1logged no fault.bf7c82eeitself is not stable on this card (#2874). But the split is 2/2 against 0/2 at the same point in the title.Review point:
on_queue_releasedrops buffers the GPU may still be copying from.release_taking_firstruns itstakeclosure before the originalReleasewhen the count was 1. Sotitle_textures::on_queue_releaseremoves the queue'sQueueUploads(itsin_flighttexture::InFlightstaging buffers) before the queue goes away, with no check ofq.fenceagainstq.value.q.fenceforq.value(bounded) before removing the entry, would close it.Reclaim across all queues.
reclaim_completed_on_queuenow locksON_QUEUEand callsGetCompletedValueon every tracked queue on each call. That seems fine for a handful of queues. I note it only because the function keeps its_queue_keyparameter and its old name.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:
bf7c82eealone (same title, same settings, A every 10 s) lost the device in 3 of 3 600 s runs:0x887a0006at 226 s, then0x887a0007at 407 s and at 380 s. The last two were followed by the title's ownint3atgame_scarlett_master.exe+0x2474606. With the two 300 s base runs above that survived, the base lost the device in 3 of 5 runs. So the 2 of 2 on this head does not show that this PR causes the hangs: on this card the base hangs about as often. The review point abouton_queue_releasestands on its own; it does not depend on these runs.Update: full lib suite on this head (
baaf024d, RX 6800, debug,cargo test -p xcl --lib -- --test-threads=1, with the tests skipped that hang or abort only inside the fullamd-devrun, see #42): 1654 passed, 11 failed, 27 ignored. Against basebf7c82eerun the same way (1651 / 12 / 27), the two new tests (drain_completed_reclaims_only_finished_batches,on_queue_release_removes_tracked_queue_entry) pass. The only failure that changed isgpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, which passed here, and it is the known flaky one on this card (#2842). No failure is new on this head. The review point abouton_queue_releaseis unchanged: as @pickles976 noted, the new test uses an emptyin_flight, so it cannot catch it.@JJAutoCompare on GitHub · 2026-11-27 01:00 UTC · original
Tested
Clean
baaf024d2c0b3c19c2944ce45c501ab768896e4c, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. Used synthetic inputs. Built the libtest artifact with Cargo restricted to two jobs outside the shared GPU lock. WithXCL_ADAPTER=A770 XCL_NETWORK=0, ran these libtest filters separately under the lock with--exact --test-threads=1 --nocapture.hle::d3d12x::title_textures::tests::gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released: later queue work read back the uploaded pixels and tracked upload bytes cleared after completion.gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels: the 138,412,032-byte RGBA8/BC7 request grew staging capacity from 134,217,728 to 150,994,944 bytes, reused it on repeat and read back exact bytes.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 (
gpt-6.2-solfor the worker run) built and ran the existing tests. Codex in the coordinator session independently reran these two and drafted this report.@pickles976 on GitHub · 2026-11-27 01:33 UTC · original
Pending upload lifetime concern at
baaf024d2c0b3c19c2944ce45c501ab768896e4c(source review, no title/test run).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:
q_release/release_taking_firstordinarily runs its cleanup closure before the native final Release.title_textures::on_queue_releaseunconditionally removesQueueUploads, including all unfinishedin_flightbatches, without checking their fence values or transferring ownership.texture::InFlightexplicitly requires retention until submission completion. Dropping it returns small staging buffers to the reusable pool and frees oversized ones, as well as releasing its allocator/list.[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
on_queue_release_removes_tracked_queue_entryuses an emptyin_flightdeque, so it cannot detect the lifetime problem.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
ON_QUEUE's mutex. Add a deterministic pending-fence/drop-or-reuse regression proving staging stays retained after queue cleanup and becomes reclaimable only after completion. That is the useful next memory gate here, rather than another long title run.Actual PR base is
amd-devbf7c82ee1b2685bb40417e09c4128177aa68d719; this review does not establish compatibility with our separate stock-vkd3d integration. AI-assisted review: omp (openai-codex/gpt-6-astra); the cited ownership/release code was inspected directly.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.