gpu: keep one readback queue in the hardware lease fixtures #2557

Merged
alvaroolt merged 1 commit from upstream-pr/2565 into main 2026-11-25 21:16:35 +00:00
alvaroolt commented 2026-11-25 21:10:36 +00:00 (Migrated from github.com)

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*_hardware and startup_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 clear
and readback copy. A stack of a hung process showed the main thread inside
NtGdiDdDDIDestroyAllocation2 while it released one of those queues
(ComputeCommands::~ComputeCommands in run(), 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 two
run() call sites switch to it. All other callers keep the existing constructor. The tested behaviour does not change: the fixture still
checks 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 OpenExistingHeapFromAddress heap, a
held 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:

  • one process;
  • a held queue without pending work;
  • a second process that holds but does not release a queue;
  • releasing a buffer instead of a queue;
  • WARP;
  • the AMD Radeon iGPU on the same PC (driver 32.0.11034.2).

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, dev preset.
D3D12 debug layer unavailable (Graphics Tools not installed).

The ten hardware lease cases, in parallel:

ctest --preset dev --no-tests=error -R '^startup_indirect_mesh_(xmem_arguments(_skip_wait)?_hardware|lease_hardware_.*)$' -j 8 --repeat until-fail:5
Build Result
This PR, 837d37a0 on 44e54584 10/10 passed in each of 5 consecutive runs.
This PR, ed6750fa on e26ade7f 10/10 passed in each of 5 consecutive runs. Each case took 0.5–7.1 s.
Negative control on e26ade7f: tests/startup_indirect_draw_indexed.cpp from upstream/main, same build otherwise, one run 5/10 at the 60 s timeout: xmem_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 8 gave 70/70 passed.
tests/docs_links_check.py gave exit 0 (488 links).

On ed6750fa:

  • ctest --preset dev --no-tests=error -j 8: 1874/1874 passed, with 49 capability skips (exit 77).
  • The Linux CI check list from .github/workflows/windows.yml, run with tools/run_checks_parallel.py
    (142 checks): 141 ok. tests/startup_run_sh_check.py returned 77. It tests a POSIX launcher and runs
    on 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 ed6750fa come from tests that
upstream/main added after bfba03c9: startup_resource_retire_title_{hardware,warp}_debug1 and
startup_sharedexp_target_warp.

Before the change, a full dev run on upstream/main ab3f4819 had two failures, both at the
timeout: startup_indirect_mesh_xmem_arguments_skip_wait_hardware and
startup_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_hardware and
startup_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 pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

This change was AI-assisted (Claude Code); I reviewed the diff and the test results.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6613825450 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2565). Originally posted by [alvaroolt](https://github.com/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*_hardware` and `startup_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 clear and readback copy. A stack of a hung process showed the main thread inside `NtGdiDdDDIDestroyAllocation2` while it released one of those queues (`ComputeCommands::~ComputeCommands` in `run()`, 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 two `run()` call sites switch to it. All other callers keep the existing constructor. The tested behaviour does not change: the fixture still checks 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 `OpenExistingHeapFromAddress` heap, a held 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: - one process; - a held queue without pending work; - a second process that holds but does not release a queue; - releasing a buffer instead of a queue; - WARP; - the AMD Radeon iGPU on the same PC (driver 32.0.11034.2). 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, `dev` preset. D3D12 debug layer unavailable (Graphics Tools not installed). The ten hardware lease cases, in parallel: ```powershell ctest --preset dev --no-tests=error -R '^startup_indirect_mesh_(xmem_arguments(_skip_wait)?_hardware|lease_hardware_.*)$' -j 8 --repeat until-fail:5 ``` | Build | Result | |---|---| | This PR, `837d37a0` on `44e54584` | 10/10 passed in each of 5 consecutive runs. | | This PR, `ed6750fa` on `e26ade7f` | 10/10 passed in each of 5 consecutive runs. Each case took 0.5–7.1 s. | | Negative control on `e26ade7f`: `tests/startup_indirect_draw_indexed.cpp` from `upstream/main`, same build otherwise, one run | 5/10 at the 60 s timeout: `xmem_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 8` gave 70/70 passed. `tests/docs_links_check.py` gave exit 0 (488 links). On `ed6750fa`: - `ctest --preset dev --no-tests=error -j 8`: 1874/1874 passed, with 49 capability skips (exit 77). - The Linux CI check list from `.github/workflows/windows.yml`, run with `tools/run_checks_parallel.py` (142 checks): 141 ok. `tests/startup_run_sh_check.py` returned 77. It tests a POSIX launcher and runs on 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 `ed6750fa` come from tests that `upstream/main` added after `bfba03c9`: `startup_resource_retire_title_{hardware,warp}_debug1` and `startup_sharedexp_target_warp`. Before the change, a full `dev` run on `upstream/main` `ab3f4819` had two failures, both at the timeout: `startup_indirect_mesh_xmem_arguments_skip_wait_hardware` and `startup_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_hardware` and `startup_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 - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. This change was AI-assisted (Claude Code); I reviewed the diff and the test results.
upstream-sync closed this pull request 2026-11-25 22:02:06 +00:00
tedin7 commented 2026-11-25 22:02:07 +00:00 (Migrated from github.com)

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. Both run() call sites (clear and readback copy) switch to it; no other nullptr/DIRECT ComputeCommands left in that function. <mutex> and <vector> are included.
  • Checked pixels, refusals and lease lifetimes are unchanged. The hang cannot be reproduced on Linux, so a mutation test is not possible here. The CI Windows job and the contributor's full dev/release runs (1807/1807 each, on this head's base) cover it.
  • Docs addition in docs/experiments.md states the conditions and the scope (fixtures only, one GPU).
  • No other open or merged PR covers this slice.

Commands run locally (Linux worktree on this head):

  • git diff --stat origin/main...HEAD: 4 files, +51/-2
  • python3 tests/docs_links_check.py: pass
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean

No blocking findings. Note: the fix is validated on one GPU (RTX 5080), as the PR says.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065095993 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2565#pullrequestreview-6065095993). Originally posted by [tedin7](https://github.com/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. Both `run()` call sites (clear and readback copy) switch to it; no other `nullptr`/DIRECT `ComputeCommands` left in that function. `<mutex>` and `<vector>` are included. - Checked pixels, refusals and lease lifetimes are unchanged. The hang cannot be reproduced on Linux, so a mutation test is not possible here. The CI Windows job and the contributor's full dev/release runs (1807/1807 each, on this head's base) cover it. - Docs addition in `docs/experiments.md` states the conditions and the scope (fixtures only, one GPU). - No other open or merged PR covers this slice. Commands run locally (Linux worktree on this head): - `git diff --stat origin/main...HEAD`: 4 files, +51/-2 - `python3 tests/docs_links_check.py`: pass - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean No blocking findings. Note: the fix is validated on one GPU (RTX 5080), as the PR says. AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2557
No description provided.