gpu: wait for every queue before settling the in-flight retire stage #3457
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3457"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T13:57:11Z.
Change
startup_resource_retirefailed once in the /O2 job of main at6747721con WARP (Microsoft Basic Render Driver), at thein flight passedstage, with 2 textures (131072 bytes) still retained. This fixes that failure in the test. Refs #3426.The runtime frees a released texture of the retire class only after two things: every queue has passed its release-time fence, and every submission that names the texture has completed (
retire_fences_reachedand the flight list insrc/startup_stubs/d3d12_xs_device.cpp). Neither the runtime nor the test's drain waits for the GPU.in_flight()releases R and D while one queue is gated and the other three are idle, so each release signals a release-time fence on all four queues. The stage then waited only for the gated queue (c.sync(queue)) beforesettle(), which retries the drain up to 200 times in a row without sleeping. When WARP had not passed another queue's release-time fence within those 200 drains, both textures were still retained.The test now syncs all four queues before
settle(), as every other stage that settles after a release already does. The expectation is unchanged: both textures must be freed, andstays("in flight")still checks that nothing goes early while the submission is held. The runtime is unchanged.Verification
Base
212d4b5f; fix5530c7a3. The branch is rebased ontoe3f9a64fwithout conflicts (80ab69e8); the loops below were measured before the rebase, and main has since changed the retire hold path ind3d12_xs_device.cpp. Windows 11 build 26300; WARP (Microsoft Basic Render Driver); NVIDIA GeForce RTX 4090, driver 32.0.16.1088; Windows SDK 10.0.26100; debug layer off (debug0). Builds:dev(Debug) andrelease(/O2) presets.Locally,
startup_resource_retire_hardware_debug0picks the RTX 4090. The CI run that failed picked the Basic Render Driver, sostartup_resource_retire_warp_debug0, which runs the same steps on WARP, stands in for it.Each loop runs
ctest --preset <dev|release> --no-tests=error -R '^<test>$'a fixed number of times and counts failures (script below). "load 24" adds 24 busy-loop processes on a 24-thread CPU. "2 cores" pins ctest, the test and 4 busy-loop processes to affinity mask0x3.startup_resource_retire_warp_debug0, failures out of 1000:212d4b5f)Every failure before the fix is the CI line, at the gated-queue step (17 textures live) or the copy-queue step (15 live):
Revert control. With
settle_limitset to 1 (a single drain), Debug, load 24, 200 runs: the test before the fix fails 183/200, all atin flight passed. With the fix it fails 0/200. With all four queues synced, one drain is enough, so the stage no longer depends on how fast WARP finishes. (Idle, one drain: 0/200 before and 0/200 after; an idle WARP passes those fences in time.)startup_resource_retire_hardware_debug0on the RTX 4090: before the fix 0/1000 idle and 0/1000 under load 24, in each build. After: 0/1000 idle in Debug and 0/1000 idle in /O2 (not repeated under load, which took 1.5 h per configuration before the fix).One run of each
startup_resource_retire_*test passed with the fix on both adapters:warp_debug0,warp_debug1,off_warp,hardware_debug0,hardware_debug1andoff_hardware. The passingwarp_debug1run prints D3D12 debug-layer lines (ExecuteCommandLists: ... the command queue fence has not advanced past previous executions of the command list). This change doesn't touch submission, and I did not check whether those lines also appear before it.Loop script (loop.py)
Evidence and follow-up
The test is unchanged apart from the extra syncs, and no new fixture is added. The other two failures in #3426 are separate.
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T14:16:16Z.
Review of head
80ab69e8(one commit onmaine3f9a64f).git merge-tree --write-tree origin/main 80ab69e8againstmain0ed385dcexits 0. The diff is three lines intests/startup_resource_retire.cpp. The runtime is unchanged.Semantics (checked against
src/startup_stubs/d3d12_xs_device.cpponmain)retire_resourcesignals the release-time fence on every registered queue (q.queue->Signal(q.fence, q.signaled + 1)).retire_fences_reachedcompares eachfence->GetCompletedValue()with its target.drain_retired_resourcesstarts withTryAcquireSRWLockExclusiveand never waits. The body describes this correctly.Context::syncsignals the test's own fence on the same queue, after those markers, and waits for it. A queue completes its signals in order, so aftersyncon all four queues every release-time target has passed. Then one drain is enough, which matches yoursettle_limit = 1control.closed_lists,discards,destination_released,texture_region,resolve_destination,open_listandclassessync all four.release_time_fencesyncs three and then the gated one.second_submissionsettlesR, which was released and synced in stage 1.in_flightwas the only stage that settled before the release-time fences of the idle queues had passed.stays("in flight")has already passed. So the early-release check still runs while the submission is held. The stage still requires both textures to be freed, so a runtime that kept them would still fail atin flight passed.Default path: none.
X2W_D3D12_RELEASE_RETIRED=1is in thebaseenv oftools/startup/run_presets.json, so the retire path is used in real runs, but this PR does not touch it. The drain never blocks. The flake was a race in the test's timing, not a wait or a stall in the runtime.MUST: none.
NIT
gpu: wait for every queue …reads like a runtime change that adds a GPU wait. The change is test-only. Someone bisecting a present or queue stall could pick it up as a suspect.tests:would match how this repo labels test-only commits (e.g.c68ffa88 tests: compute stand-in source lines instead of pinning them). Optional.CI note: CI on
80ab69e8is green. But the Windows job runs the 82-testprpreset, and its log has nostartup_resource_retire_(warp|hardware|off)line (grep -cgives 0). The only retire test in that job isstartup_resource_retire_title_inline_warp_debug0. So CI did not run this change. Your 1000-run loops are the only Windows evidence, and main's full job will run it after merge. There are no WARP reports on the PR yet. I could not run D3D12 WARP here (Linux).No reviews or change requests. No binary files, no title-specific inputs.
Merging.
AI-assisted.