Skip to content

XGameRuntime: retain an async operation's queue after handle close - #641

Draft
WebIdentity1 wants to merge 1 commit into
xcl-dev:mainfrom
WebIdentity1:codex/xasync-retain-queue
Draft

WebIdentity1 wants to merge 1 commit into
xcl-dev:mainfrom
WebIdentity1:codex/xasync-retain-queue

Conversation

@WebIdentity1

@WebIdentity1 WebIdentity1 commented Nov 24, 2026 •

Copy link
Copy Markdown

Closing the caller's queue handle after XAsyncBegin can make later scheduling fail or silently drop completion. XAsyncRun also loses its completion callback if its original handle closes before dispatch. Retain the queue in the operation's state and use that reference for scheduling and completion, following the existing libHttpClient contract.

Part of #576, item 2 only. Items 1, 3 and 4 remain unresolved. The cleanup-guard changes from closed #197 are not included or tested in combination. #235's fallback selection is outside this patch.

What is in it

  • State retains a queue reference captured by Begin/Run; Schedule/Complete use it. Three synthetic queue-handle regressions and README behavior note. No new dependency or copied reference code.

Tested

  • Head 8d0bbc87fb9423f1c2d49b9d43b4ab7ecba710b6, base 18c105af86929d6ae26c44096c85b66f1644e743. Native Windows 10 build 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74 plus AMD integrated driver 32.0.21030.2001, Rust 1.98.1 MSVC, SDK DXC 1.8.2502.11, Agility 1.620.2, debug.
  • cargo build --locked --workspace succeeded. cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output: 691 passed, 1 failed, 41 ignored. Only gpu_clamp_and_omod_per_instruction failed, previously reproduced on main. All three new regressions passed. Desktop session1, XCL_ADAPTER=3090; some upstream fixtures select AMD directly.
  • Before rebasing from 3db536e, cargo test --locked -p xcl --lib after_queue_handle_close -- --test-threads=1 --show-output: original runtime plus tests 0/3/0 (Complete/Run delivered zero callbacks; Schedule returned E_INVALIDARG), candidate 3/0/0. The original xasync.rs is identical on both base revisions. Immediate/manual ports avoid timing-dependent sleeps; the completion test also verifies the retained queue is released. cargo test --locked -p xcl --lib hle::xgameruntime:: -- --test-threads=4 --show-output: 76/0/0, no skips.
  • Four explicit full-suite skips: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no native wave64 on NVIDIA), test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state (debug layer unavailable). Sample variables unset; those opt-in cases return early.

Regression run
Independent contributor Anon64 supplied these exact-head/main runs, copied verbatim from that report. These are their measurements, not ours. RTX3060 12GB driver581.80, i9-14900KF, Windows11 26200.9974, Rust1.90.0, release; same title/duration, clean source, scripts/smoke.ps1. They report no test of early queue-handle closure in that title; our synthetic regressions cover that path.

xcl-smoke v1
commit: 18c105af86929d6ae26c44096c85b66f1644e743
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14584 MB
xcl-smoke v1
commit: 8d0bbc87fb9423f1c2d49b9d43b4ab7ecba710b6
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14586 MB

Draft retained: upstream CI run45315130577 awaits maintainer approval (action_required), and our local full suite retains the disclosed baseline CLAMP failure. No source update has invalidated these exact-head runs.

Not tested
By us: retail titles, release, Wine, installed PC XGameRuntime, or integration with #197. The independently reported startup smoke above is not gameplay or early-handle-close validation. This does not fix stale queued work or callback/wait ordering, and demonstrates no retail title gameplay progress.

AI use
Codex (GPT-6) inspected public code and overlap, implemented the queue-retention change and tests, ran native Windows validation, and prepared this description.

Begin and Run now keep the queue reference in State. Schedule and Complete
use that reference instead of resolving the caller's potentially closed
handle, preserving scheduled work and completion delivery.

Three synthetic tests reproduce lost completion callbacks or invalid
scheduling on the old path and pass with retention. Part of xcl-dev#576 item 2;
stale work items and completion-wait ordering are separate issues.
@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 8d0bbc8 (on its base 18c105a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 692 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: async_complete_after_queue_handle_close_delivers_callback, async_run_after_queue_handle_close_delivers_callback, async_schedule_after_queue_handle_close_uses_begins_queue.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Anon64

Anon64 commented Nov 24, 2026

Copy link
Copy Markdown

Regression runs for this PR's head 8d0bbc8 and for its base main 18c105a, on a retail title (same title, 60 s each), made with scripts/smoke.ps1 (release, clean tree at each commit) and pasted unedited, for Regression run.

main:

xcl-smoke v1
commit: 18c105af86929d6ae26c44096c85b66f1644e743
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14584 MB

this PR:

xcl-smoke v1
commit: 8d0bbc87fb9423f1c2d49b9d43b4ab7ecba710b6
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14586 MB

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0

Not tested

  • the unit tests on this machine
  • whether the title closes an async queue handle early; this is a regression check only

Report written with Claude Code (Claude Opus 5.5) from runs on this machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants