tests: wait for the queues before settling retired resources #3509
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3509"
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 Leyukaka on 2026-11-29T19:04:28Z.
Refs #3507 (item c).
tests/startup_resource_retire_title.cppchecked retirement right after a release at several stages without waiting for the release-time fences.settle()only resubmits the drain list and never waits on the GPU, so a "freed" check could run before the fence passed. This is the failure seen in CI run 46260430363 on thehardware_debug1variant, case 6:retained=131072/2,expected=65536/1, i.e. the newer wrapper was still retained.The change adds a wait on both registered guest queues (
direct,gated) after the release and before the check. It is the same pattern as80ab69e8(#3457) in the sibling testtests/startup_resource_retire.cpp. One file, +9/-2, no change undersrc/.Sites
8 wait sites, 9 stages:
T_addr2 kept while slot70 SRV live, thenT_addr2 retired after heap releasedT_rgba_after_bc7 retiredTv1 held by heap1 and heap2, thenTv1 retired after descriptor overwriteTv2 held by overwritten heap2[0], thenTv2 retired after heap2 releasednewer wrapper retired with older SRV liveolder generation retiredslot 133 texture held by the closed draw list, thenslot 133 draw hold droppedgatedadded before the existingdirectwaitsclass texture with a refused RTV in a tracked slotgatedadded next todirectclass texture with a refused RTV in an untracked slotgatedadded next todirectNo assertion is removed or relaxed.
The gated queue waits on a gate fence in three cases, each signalled inside the same case: case 1 (
tests/startup_resource_retire_title.cpp:633, signalled at:638), case 2 (:659, signalled at:687) and case 11 (:1110, signalled at:1147). Cases 1 and 2 signal before the first added wait (:724). Case 11 runs only in inline mode, wheremain()returns right after it (:1467-:1474) and no case with an added wait runs. So the added waits cannot block. In off mode nothing retires and the waits are inert.Tests
At
994a36e5ond3e306a7, dev preset, each variant 20 times in a row (ctest --parallel 1 --repeat until-fail:20), on WARP and on one desktop GPU:warp_debug0,hardware_debug0,off_warp,off_hardware,inline_warp_debug0,inline_hardware_debug0.warp_debug1,hardware_debug1,inline_warp_debug1,inline_hardware_debug1. The D3D12 debug layer is not installed on this machine.Not covered
hardware_debug1, the variant that failed in CI, was not run locally. The fix is not proven locally against that failure.warp_debug0andhardware_debug0each passed 120 runs out of 120. Without the debug layer the release fences pass within the drain loop, so this machine does not show that the wait is needed. That rests on the CI failure above and on the code argument.d3e306a7was not run separately.Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T20:58:36Z.
Review: COMMENTED
I checked this against #3457, which fixed the same race in the sibling
tests/startup_resource_retire.cpp. It's the same pattern, and the added waits sit in the right places.settle()only resubmits the drain list, so without a queue wait a "freed" check can run before the release fence passes. I also agree that the "kept" checks get stronger, not weaker, and no assertion changes.On the claim that the added waits can't block: they can't, but the gated queue also waits on a gate in case 11 (
case11_inline_stale_descriptor_draw, inline mode), not only in cases 1 and 2. That gate is signalled inside case 11 before it returns, and the cases run in a fixed order frommain(), so no added wait can run while a gate is pending. Also,Context::synctimes out and fails rather than hanging. The conclusion holds, and only the "cases 1 and 2" wording in the PR body is incomplete.Same caveat as #3457: without the debug layer, the mutation can't fail locally, so the proof against
hardware_debug1is the CI failure plus the code argument. A full workflow run on the fork would exercise the_debug1variants on the runner, if you want that before merge.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T21:05:59Z.
Confirmed: case 11 also queues a gate wait on the gated queue (
tests/startup_resource_retire_title.cpp:1110, signalled at:1147). The PR body now names cases 1, 2 and 11 with their lines; case 11 runs only in inline mode, where no added wait runs.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T08:08:23Z.
Review: APPROVED
Reviewed
994a36e5by reading the diff; not built or run.Verdict: approve. The waits close the race in every retire check of this file. No MUST.
settle()/stays()that follows ac.release()in the file, not only the eight changed sites. Each one now runs after both guest queues are synced. Case 1 (:621,:638), case 2 T1 (:687) and case 11 (:1147) already syncedgatedafter their gate signal, anddirectthrough an earlierstays(). Case 7's finalsettle()(:1018) follows the loop at:995-:998, which now syncs both. No gap is left in this file.:888also coversTold, released at:869.heap.Reset()at:895only drops the view reference, so the secondsettle()needs no extra wait. This agrees with the PR body.startup_resource_retire_title_hardware_debug1at stagenewer wrapper retired with older SRV live,retained=131072/2 expected=65536/1, which is case 6.Tests: the PR changes only the test file. Its CI ran only
startup_resource_retire_title_inline_warp_debug0, and inline mode returns right after case 11 (:1467-:1474), so no changed line ran on CI. The/O2job, the one that runs the_debug1variants and caught the failure, was skipped on the PR. So the first real check is main's/O2run after merge. The local 20x runs in the PR body cover the debug0 and off variants only.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-30T19:31:16Z.
Review: COMMENTED
The current head conflicts with
mainintests/startup_resource_retire_title.cpp. #3542 already landed the direct and gated queue waits for the reported case 6 failure in2e30cc59. Please rebase the remaining wait sites onto currentmainand keep the existing assertions. A fresh run of the affected retirement variants on that head would make the remaining test-only scope clear.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:46:25Z.
Review: COMMENTED
I merged main into the contributor branch. The only conflict was the comment above the case 6 wait that main already has. Kept the main explanation and all remaining waits from the PR.
ctest --preset dev --no-tests=error -j 1 --repeat until-fail:3 -R '^startup_resource_retire_title_' --output-on-failurepassed all 10 tests three times on Windows 11 26300.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, including the debug-layer on/off variants and inline paths. Please re-review the updated head.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:48:29Z.
Review: APPROVED
Reviewed
2667da0dagainst current main. The earlier independent review covers the remaining waits, and I verified the branch update resolved only the comment at the case 6 wait already on main. The remaining changes wait on the registered queues before the existing retained/freed assertions. Windows 11 build 26300 / MSVC Debugctest --preset dev --no-tests=error -j 1 --repeat until-fail:2 --output-on-failure -R '^startup_resource_retire_title_'passed all ten tests twice, on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, including inline and debug-layer on/off cases.