gdk rt: XAsync return codes match the reference (6 conformance scenarios) #266

Closed
QuentinDanblon wants to merge 1 commit from upstream-pr/266 into main
QuentinDanblon commented 2026-11-23 08:41:38 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-23T08:41:38Z.


Library / area: compat-common, GDK runtime XAsync (src/gdk/rt.rs), conformance table (tests/gdk_xtaskqueue_conformance.rs)

Exports changed (exports.txt rows): none

Source of the behaviour: libHttpClient Source/Task/AsyncLib.cpp and TaskQueue.cpp at c5007fd9 (MIT): the rules were followed and rewritten in Rust, no code copied. The existing libHttpClient line of THIRD_PARTY/CREDITS now names src/gdk/rt.rs too. The same six scenarios pass against the xgameruntime.dll of Gaming Services on my PC (gdk_xtaskqueue_conformance_real).

Six rows leave the DIFFERS table. Each one was a return code that differed from the reference:

scenario before now, as the reference
verify_global_queue XAsyncBegin with no queue in the block and no process queue returned S_OK returns E_NO_TASK_QUEUE and leaves that status in the block
verify_begin_after_terminate XAsyncBegin on a queue whose termination has started returned S_OK returns E_ABORT
verify_failed_begin_completes a failing Begin op made XAsyncBegin return that failure XAsyncBegin returns S_OK and the call completes with the failure, so the completion callback runs
verify_cant_schedule_twice a second XAsyncSchedule returned S_OK returns E_UNEXPECTED until the worker callback has run
verify_failure_in_do_work DoWork returning a success code without XAsyncComplete left the status S_OK the call completes with E_UNEXPECTED
verify_result_buffer_checks XAsyncGetResult with a null buffer returned 0x8007007a returns E_INVALIDARG, checked before the size; XAsyncGetResultSize writes 0 for a pending or failed call

Two side changes these needed:

  • XAsyncRun's provider now calls XAsyncComplete with the result of the work function, as the reference does. Without it, the new E_UNEXPECTED rule would have turned every successful XAsyncRun into a failure.
  • The worker callback only acts on the call it was scheduled for (it compares the state it captured with the state the block has now), so a block reused before a stale worker runs is not completed by it.

What is still different, and not claimed here

  • The E_ABORT of XAsyncBegin reads the queue's terminated flags. The reference gets it from XTaskQueueSuspendTermination, which also holds termination back while the call is in flight. That part is the verify_terminate_waits_for_async_in_flight row, which stays in DIFFERS.
  • XAsyncBegin with a non-zero queue handle that is not a queue is still accepted, as before.
  • XAsyncSchedule on a call whose state is gone returns E_INVALIDARG, as before. The reference returns the call's failure code first when it has one.

Tests

  • cargo test -p compat-common --release --test gdk_xtaskqueue_conformance, on this commit rebased on 6e81ffc: 3 runs, 60 passed each.
  • Before the rebase (base 902209a, the two differ by docs/BLOCKERS.md only) I ran it 6 times while other builds and GPU tests were running on the machine: 4 runs passed, 2 failed.
    • One run failed verify_simple_async_call ("XAsyncGetStatus(wait) returned before the completion callback ran"). That scenario also fails now and then on main without this change: 2 failures in 10 runs on 902209a, on verify_simple_async_call and verify_async_block_reuse.
    • One run took 10.7 s instead of 4 s and failed verify_immediate_dispatch, verify_serialized_queues_do_not_keep_threads and verify_serialized_port_final_release ("a delayed callback on an immediate port never ran"). These three do not use XAsync. I did not see them fail on main, and I did not reproduce the failure. I think it is a timing limit under load, but I have not proven it.
  • gdk_xtaskqueue_conformance_real (the same scenarios against the real xgameruntime.dll): 60 passed.
  • TOMBOX_XTQ_ALL=1 ... -- --test-threads=1 --skip verify_get_async_status_no_deadlock: 43 passed, 16 failed. The 16 are rows still in DIFFERS.
  • cargo test -p compat-common --release --no-fail-fast: lib 125 passed. gdk_multi_dll did not build here (the d3d12_xs build script did not find DXC in that shell), every other integration test passed.
  • pr_gate.py: 0 problems.

verify_register_*, verify_queue_termination and the two verify_shared_port_queue_rundown_* rows (XTaskQueueRegisterWaiter) are being worked on in a separate branch. It touches lines next to these in DIFFERS, so I will rebase it on whatever you merge first.

  • cargo test -p compat-common passes, with the two exceptions written above (one build failure from my environment, one scenario that is already intermittent on main)
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6555525145 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/266). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-23T08:41:38Z. --- **Library / area:** `compat-common`, GDK runtime XAsync (`src/gdk/rt.rs`), conformance table (`tests/gdk_xtaskqueue_conformance.rs`) **Exports changed (exports.txt rows):** none **Source of the behaviour:** libHttpClient `Source/Task/AsyncLib.cpp` and `TaskQueue.cpp` at `c5007fd9` (MIT): the rules were followed and rewritten in Rust, no code copied. The existing libHttpClient line of `THIRD_PARTY/CREDITS` now names `src/gdk/rt.rs` too. The same six scenarios pass against the `xgameruntime.dll` of Gaming Services on my PC (`gdk_xtaskqueue_conformance_real`). Six rows leave the `DIFFERS` table. Each one was a return code that differed from the reference: | scenario | before | now, as the reference | |---|---|---| | `verify_global_queue` | `XAsyncBegin` with no queue in the block and no process queue returned S_OK | returns `E_NO_TASK_QUEUE` and leaves that status in the block | | `verify_begin_after_terminate` | `XAsyncBegin` on a queue whose termination has started returned S_OK | returns `E_ABORT` | | `verify_failed_begin_completes` | a failing Begin op made `XAsyncBegin` return that failure | `XAsyncBegin` returns S_OK and the call completes with the failure, so the completion callback runs | | `verify_cant_schedule_twice` | a second `XAsyncSchedule` returned S_OK | returns `E_UNEXPECTED` until the worker callback has run | | `verify_failure_in_do_work` | DoWork returning a success code without `XAsyncComplete` left the status S_OK | the call completes with `E_UNEXPECTED` | | `verify_result_buffer_checks` | `XAsyncGetResult` with a null buffer returned 0x8007007a | returns `E_INVALIDARG`, checked before the size; `XAsyncGetResultSize` writes 0 for a pending or failed call | Two side changes these needed: - `XAsyncRun`'s provider now calls `XAsyncComplete` with the result of the work function, as the reference does. Without it, the new `E_UNEXPECTED` rule would have turned every successful `XAsyncRun` into a failure. - The worker callback only acts on the call it was scheduled for (it compares the state it captured with the state the block has now), so a block reused before a stale worker runs is not completed by it. ### What is still different, and not claimed here - The `E_ABORT` of `XAsyncBegin` reads the queue's terminated flags. The reference gets it from `XTaskQueueSuspendTermination`, which also holds termination back while the call is in flight. That part is the `verify_terminate_waits_for_async_in_flight` row, which stays in `DIFFERS`. - `XAsyncBegin` with a non-zero queue handle that is not a queue is still accepted, as before. - `XAsyncSchedule` on a call whose state is gone returns `E_INVALIDARG`, as before. The reference returns the call's failure code first when it has one. ### Tests - `cargo test -p compat-common --release --test gdk_xtaskqueue_conformance`, on this commit rebased on `6e81ffc`: 3 runs, 60 passed each. - Before the rebase (base `902209a`, the two differ by `docs/BLOCKERS.md` only) I ran it 6 times while other builds and GPU tests were running on the machine: 4 runs passed, 2 failed. - One run failed `verify_simple_async_call` ("XAsyncGetStatus(wait) returned before the completion callback ran"). That scenario also fails now and then on `main` without this change: 2 failures in 10 runs on `902209a`, on `verify_simple_async_call` and `verify_async_block_reuse`. - One run took 10.7 s instead of 4 s and failed `verify_immediate_dispatch`, `verify_serialized_queues_do_not_keep_threads` and `verify_serialized_port_final_release` ("a delayed callback on an immediate port never ran"). These three do not use XAsync. I did not see them fail on `main`, and I did not reproduce the failure. I think it is a timing limit under load, but I have not proven it. - `gdk_xtaskqueue_conformance_real` (the same scenarios against the real `xgameruntime.dll`): 60 passed. - `TOMBOX_XTQ_ALL=1 ... -- --test-threads=1 --skip verify_get_async_status_no_deadlock`: 43 passed, 16 failed. The 16 are rows still in `DIFFERS`. - `cargo test -p compat-common --release --no-fail-fast`: lib 125 passed. `gdk_multi_dll` did not build here (the `d3d12_xs` build script did not find DXC in that shell), every other integration test passed. - `pr_gate.py`: 0 problems. `verify_register_*`, `verify_queue_termination` and the two `verify_shared_port_queue_rundown_*` rows (`XTaskQueueRegisterWaiter`) are being worked on in a separate branch. It touches lines next to these in `DIFFERS`, so I will rebase it on whatever you merge first. - [x] `cargo test -p compat-common` passes, with the two exceptions written above (one build failure from my environment, one scenario that is already intermittent on `main`) - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note 🤖 Generated with [Claude Code](https://claude.com/claude-code)
omonkeyz commented 2026-11-23 09:41:48 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-23T09:41:48Z.


Applied in 883d1c8 (merged in e3c62b7) with your authorship kept, thanks. It shipped in r32i (377a22a) after a full-boot Trackmania run: sign-in, the offline menu and the race all matched r32h, with no new gdk errors.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7096981444 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/266#issuecomment-7096981444). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-23T09:41:48Z. --- Applied in 883d1c8 (merged in e3c62b7) with your authorship kept, thanks. It shipped in r32i (377a22a) after a full-boot Trackmania run: sign-in, the offline menu and the race all matched r32h, with no new gdk errors.

Pull request closed

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
omonkeyz/xbox-emulator!266
No description provided.