gpu: keep one readback queue in the hardware lease fixtures #2557
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2565"
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 alvaroolt on 2026-11-25T21:10:36Z.
Change
The hardware cases of the XMem lease fixtures time out at 60 s when CTest runs several of them at once
on an NVIDIA RTX 5080. Alone, each one passes in a few seconds. The affected tests are
startup_indirect_mesh_xmem_arguments*_hardwareandstartup_indirect_mesh_lease_hardware_*.These fixtures hold a writer queue with pending work behind a CPU-signalled fence. During that hold,
run()clears and reads back the targets. It used to create and release a DIRECT queue for each clearand readback copy. A stack of a hung process showed the main thread inside
NtGdiDdDDIDestroyAllocation2while it released one of those queues(
ComputeCommands::~ComputeCommandsinrun(), after the writer was gated).This PR records those clears and copies on one DIRECT queue per device instead. The queue lives until the
process exits, so the fixtures no longer release a queue while their writer is held.
ComputeCommands(tests/desktop_gpu.h) gains a constructor that uses an existing queue. Only the tworun()call sites switch to it. All other callers keep the existing constructor. The tested behaviour does not change: the fixture stillchecks the same pixels, refusals and lease lifetimes. Only the queue that records the fixture's own
clear and readback copy is different.
A plain D3D12 program (about 135 lines, no Xbox2Windows code) reproduced the stall. It needed two
processes, each holding a queue with a pending copy behind a CPU-signalled fence and releasing another
queue during that hold. With a copy into a placed buffer on an
OpenExistingHeapFromAddressheap, aheld DIRECT, COMPUTE or COPY queue stalled. With a copy into a committed buffer, held DIRECT and COPY
queues stalled; COMPUTE was not tried with that destination. The program did not stall in these
cases:
Whether the stall comes from the NVIDIA driver or from the Windows graphics kernel was not established.
Verification
Windows 11 build 26300.9974, NVIDIA GeForce RTX 5080 (driver 32.0.16.2124), MSVC 14.52,
devpreset.D3D12 debug layer unavailable (Graphics Tools not installed).
The ten hardware lease cases, in parallel:
837d37a0on44e54584ed6750faone26ade7fe26ade7f:tests/startup_indirect_draw_indexed.cppfromupstream/main, same build otherwise, one runxmem_arguments_hardware,xmem_arguments_skip_wait_hardware,lease_hardware_dual-trace,lease_hardware_ordered_control,lease_hardware_skip-wait. The other five passed in under 5 s.On
837d37a0:ctest --preset dev --no-tests=error -R '^startup_indirect_' -j 8gave 70/70 passed.tests/docs_links_check.pygave exit 0 (488 links).On
ed6750fa:ctest --preset dev --no-tests=error -j 8: 1874/1874 passed, with 49 capability skips (exit 77)..github/workflows/windows.yml, run withtools/run_checks_parallel.py(142 checks): 141 ok.
tests/startup_run_sh_check.pyreturned 77. It tests a POSIX launcher and runson Linux only.
On
bfba03c9, with the same change:ctest --preset dev --no-tests=error -j 8: 1807/1807 passed;ctest --preset release --no-tests=error -j 8: 1807/1807 passed.Both suites had the same 46 capability skips. The three extra skips on
ed6750facome from tests thatupstream/mainadded afterbfba03c9:startup_resource_retire_title_{hardware,warp}_debug1andstartup_sharedexp_target_warp.Before the change, a full
devrun onupstream/mainab3f4819had two failures, both at thetimeout:
startup_indirect_mesh_xmem_arguments_skip_wait_hardwareandstartup_indirect_mesh_lease_hardware_skip-wait.Evidence and follow-up
The new paragraph in
docs/experiments.md, after the "Cached mesh draw with two queue writers"command, records the measurement and the stack. It also states the conditions that the plain D3D12
program needed. The reproduction program is not included in the PR. Other fixtures that hold a queue
behind a CPU-signalled fence were not changed. They did not stall in these runs:
xmem_section_lease_*_hardware,unified_buffer_paths_hardwareandstartup_upload_lifetime_hardware, each also run in parallel with a lease case.The lease fixtures use the first enumerated hardware adapter with mesh shader tier 1, which is the
RTX 5080 on this PC. The fixtures did not run on another GPU. The AMD iGPU result above comes from the
plain D3D12 program only.
Checklist
This change was AI-assisted (Claude Code); I reviewed the diff and the test results.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:16:21Z.
Review: COMMENTED
Review of head
837d37a0(comment only).What I checked:
ComputeCommands(device, existing_queue, pipeline)takes the list type from the queue, so DIRECT clears and copies stay DIRECT. The old constructor is unchanged, so other callers are not affected.kept_direct_queue()is mutex-guarded, keyed per device, and the queue lives to process exit. Bothrun()call sites (clear and readback copy) switch to it; no othernullptr/DIRECTComputeCommandsleft in that function.<mutex>and<vector>are included.docs/experiments.mdstates the conditions and the scope (fixtures only, one GPU).Commands run locally (Linux worktree on this head):
git diff --stat origin/main...HEAD: 4 files, +51/-2python3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: cleanNo blocking findings. Note: the fix is validated on one GPU (RTX 5080), as the PR says.
AI-assisted; commands listed were executed locally.