XGameRuntime: wake XAsyncGetStatus waiters before immediate completion callback #1176

Open
github-bot wants to merge 1 commit from github-bot/gh-1176 into main AGit
Owner

@⁠b3IKK on GitHub · 2026-11-24 12:52 UTC · original
b3IKK:xgameruntime/xasync-notify-before-immediate-cb → main · +54 −1 · 1 files · 1 commits · open

XAsyncComplete called s.cv.notify_all() after taskqueue::submit_now(). When the completion port uses MODE_IMMEDIATE, submit_now() runs the completion callback synchronously on the completing thread, so any callback that synchronises with a thread blocked in XAsyncGetStatus(b, true) deadlocked deterministically because waiters were never woken.

This moves s.cv.notify_all() directly after publishing completion and before submitting the completion callback.

What is in it

  • crates/xcl/src/hle/xgameruntime/xasync.rs: call s.cv.notify_all() before taskqueue::submit_now() in XAsyncComplete; add regression test complete_wakes_waiters_before_immediate_completion_callback (verified timing out before the fix and passing in ~20 ms after).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib complete_wakes_waiters_before_immediate_completion_callback: 1 passed, 0 failed (timed out before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: 978a5dedf432ecdf57d00497e884044a9c3f7dd2
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1638 (PresentX 1639)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14582 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited xasync.rs, wrote the fix and regression test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
**@⁠b3IKK** on GitHub · 2026-11-24 12:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1176) `b3IKK:xgameruntime/xasync-notify-before-immediate-cb` → `main` · +54 −1 · 1 files · 1 commits · open `XAsyncComplete` called `s.cv.notify_all()` after `taskqueue::submit_now()`. When the completion port uses `MODE_IMMEDIATE`, `submit_now()` runs the completion callback synchronously on the completing thread, so any callback that synchronises with a thread blocked in `XAsyncGetStatus(b, true)` deadlocked deterministically because waiters were never woken. This moves `s.cv.notify_all()` directly after publishing completion and before submitting the completion callback. **What is in it** - `crates/xcl/src/hle/xgameruntime/xasync.rs`: call `s.cv.notify_all()` before `taskqueue::submit_now()` in `XAsyncComplete`; add regression test `complete_wakes_waiters_before_immediate_completion_callback` (verified timing out before the fix and passing in ~20 ms after). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`) - `cargo test -p xcl --lib complete_wakes_waiters_before_immediate_completion_callback`: 1 passed, 0 failed (timed out before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: 978a5dedf432ecdf57d00497e884044a9c3f7dd2 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1638 (PresentX 1639) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14582 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `xasync.rs`, wrote the fix and regression test, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
XAsyncComplete called s.cv.notify_all() after taskqueue::submit_now().
When the completion port uses MODE_IMMEDIATE, submit_now() runs the
completion callback synchronously on the completing thread, so any
callback that synchronises with a thread blocked in
XAsyncGetStatus(b, true) deadlocked deterministically because waiters
were never woken.

Notify the condvar as soon as completion is published and before
submitting the completion callback.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:46:07 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:09 UTC · original

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug.

  • cargo test -p xcl --lib xasync: 16 passed, 0 failed — the waiter-wake ordering change keeps the XAsync suite green.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

**@⁠DavidM1911** on GitHub · 2026-11-24 13:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1176#issuecomment-7132429402) Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug. - `cargo test -p xcl --lib xasync`: **16 passed, 0 failed** — the waiter-wake ordering change keeps the XAsync suite green. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠PedroNunes11 on GitHub · 2026-11-24 13:16 UTC · original

Independent GTA VI long-run regression on the PR head. The XAsync regression test passes, but this change does not resolve the later world-loading stop tracked in #232 on this machine.

Build

  • PR head 978a5de, cherry-picked as local 6c64715 on current main 47efa2e + #549 (d0554f3)
  • one disclosed local, env-gated change: XCL_NO_SYSTEM_XGAMERUNTIME=1 forces XCL's XTaskQueue/XAsync because the system XGameRuntime path crashes on this installation
  • release build; DXC 1.9.2602.17

Machine

  • NVIDIA RTX 4070 Ti SUPER 16 GB, driver 32.0.16.2124
  • Ryzen 7 9800X3D, 32 GB RAM
  • Windows 11 build 26200

Checks

  • cargo test -p xcl --lib complete_wakes_waiters_before_immediate_completion_callback -- --test-threads=1: 1 passed
  • 300 s GTA VI run, warm shader/pipeline cache, XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_UMA_MB=4095 XCL_COHERENT_MB=4095; XCL_PSO_WAIT_MS unset

Result

  • no skipped draws or dispatches before the stop
  • DirectStorage failures: 0; bcpack_refused: empty
  • presents dropped to 0 at 72 s, immediately after the dispatch count crossed 8,192
  • at 98.420 s: 0xc0000005 null write in game_scarlett_master.exe+0x23cf683, with the same title stack through +0x4e4ba89, +0x2215c35, +0x71b9a20, +0x2215eca
  • no device removal; peak commit 33,002 MB

So the waiter-wake ordering fix behaves correctly in its focused test, but the later GTA VI stop remains independently reproducible. This is intended as scope information, not evidence against the XAsync fix.

AI use: Codex applied the PR in an isolated worktree, ran the tests, extracted the counters from XCL's log/report, and drafted this comment; I observed the game run.

**@⁠PedroNunes11** on GitHub · 2026-11-24 13:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1176#issuecomment-7132602419) Independent GTA VI long-run regression on the PR head. The XAsync regression test passes, but this change does **not** resolve the later world-loading stop tracked in #232 on this machine. **Build** - PR head `978a5de`, cherry-picked as local `6c64715` on current `main` `47efa2e` + #549 (`d0554f3`) - one disclosed local, env-gated change: `XCL_NO_SYSTEM_XGAMERUNTIME=1` forces XCL's XTaskQueue/XAsync because the system XGameRuntime path crashes on this installation - release build; DXC 1.9.2602.17 **Machine** - NVIDIA RTX 4070 Ti SUPER 16 GB, driver 32.0.16.2124 - Ryzen 7 9800X3D, 32 GB RAM - Windows 11 build 26200 **Checks** - `cargo test -p xcl --lib complete_wakes_waiters_before_immediate_completion_callback -- --test-threads=1`: 1 passed - 300 s GTA VI run, warm shader/pipeline cache, `XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_UMA_MB=4095 XCL_COHERENT_MB=4095`; `XCL_PSO_WAIT_MS` unset **Result** - no skipped draws or dispatches before the stop - DirectStorage failures: 0; `bcpack_refused`: empty - presents dropped to 0 at 72 s, immediately after the dispatch count crossed 8,192 - at 98.420 s: `0xc0000005` null write in `game_scarlett_master.exe+0x23cf683`, with the same title stack through `+0x4e4ba89`, `+0x2215c35`, `+0x71b9a20`, `+0x2215eca` - no device removal; peak commit 33,002 MB So the waiter-wake ordering fix behaves correctly in its focused test, but the later GTA VI stop remains independently reproducible. This is intended as scope information, not evidence against the XAsync fix. AI use: Codex applied the PR in an isolated worktree, ran the tests, extracted the counters from XCL's log/report, and drafted this comment; I observed the game run.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1176/head:github-bot/gh-1176'
git switch 'github-bot/gh-1176'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1176'
git switch 'github-bot/gh-1176'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1176'
git switch 'github-bot/gh-1176'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1176'
git switch 'main'
git merge --squash 'github-bot/gh-1176'
git switch 'main'
git merge --ff-only 'github-bot/gh-1176'
git switch 'main'
git merge 'github-bot/gh-1176'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.