startup: implement XAsyncGetStatus and XAsyncGetResultSize in xgameruntime #2192

Merged
tedin7 merged 2 commits from upstream-pr/2200 into main 2026-11-25 05:14:34 +00:00
tedin7 commented 2026-11-25 04:19:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:19:43Z.


Part of #870

What this unblocks: startup code can poll XAsyncGetStatus(wait=false) and read XAsyncGetResultSize on the manual-queue async blocks from #2179, using the completion-port contract from #2170.

Change

  • XAsyncGetStatus and XAsyncGetResultSize are now implemented in src/xgameruntime_shim.cpp for blocks the shim tracks (XGameSaveInitializeProviderAsync).
  • wait=false: E_PENDING while the completion callback still waits for XTaskQueueDispatch on the manual queue, then S_OK (or the stored error).
  • wait=true never blocks: a started operation has completed before its Begin call returns.
  • XAsyncGetResultSize: E_PENDING before dispatch, then the exact size (one provider handle) without consuming the result. The output is cleared on every refusal.
  • E_INVALIDARG for a null, untracked or already consumed block; E_POINTER for a null size output.
  • Blocks without a callback have nothing to dispatch, so they report complete at once.
  • New CTest xgameruntime_async_status (before/after dispatch, no-callback block, status inside the callback, null/untracked/consumed refusals, queue-close guard, block bytes untouched). xgameruntime_thunks no longer lists XAsyncGetStatus as a stub; xgameruntime_table_check.py requires both rows as implemented.
  • Docs: docs/experiments.md updated.

Note: startup_async_manual_completion documents that the installed runtime reports S_OK for a completed-but-undispatched block. This change deliberately keeps the shim consistent with its existing XGameSaveInitializeProviderResult (E_PENDING until dispatch); follow-up if the two should both follow the runtime.

Verification

Linux:

  • python3 -B tests/xgameruntime_table_check.py -> PASS (exports=32, stub=2)
  • python3 -B tests/docs_links_check.py -> PASS
  • python3 -B tests/run_checks_parallel_check.py -> ok
  • x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only on the shim and the new test -> clean

Win2025 (Build 26100, MSVC 14.44 + D3D12 WARP, 3-slot pool) at 3609d3c1, x2w_pipe.py win2025 2200 --force --regex "^xgameruntime_":

  • dev: ctest --preset dev -R '^xgameruntime_' --no-tests=error -> 8/8 passed, none skipped (incl. xgameruntime_async_status)
  • release: ctest --preset release -R '^xgameruntime_' --no-tests=error -> 8/8 passed, none skipped

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6597122198 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2200). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:19:43Z. --- Part of #870 What this unblocks: startup code can poll `XAsyncGetStatus(wait=false)` and read `XAsyncGetResultSize` on the manual-queue async blocks from #2179, using the completion-port contract from #2170. ## Change - `XAsyncGetStatus` and `XAsyncGetResultSize` are now implemented in `src/xgameruntime_shim.cpp` for blocks the shim tracks (`XGameSaveInitializeProviderAsync`). - `wait=false`: `E_PENDING` while the completion callback still waits for `XTaskQueueDispatch` on the manual queue, then `S_OK` (or the stored error). - `wait=true` never blocks: a started operation has completed before its Begin call returns. - `XAsyncGetResultSize`: `E_PENDING` before dispatch, then the exact size (one provider handle) without consuming the result. The output is cleared on every refusal. - `E_INVALIDARG` for a null, untracked or already consumed block; `E_POINTER` for a null size output. - Blocks without a callback have nothing to dispatch, so they report complete at once. - New CTest `xgameruntime_async_status` (before/after dispatch, no-callback block, status inside the callback, null/untracked/consumed refusals, queue-close guard, block bytes untouched). `xgameruntime_thunks` no longer lists `XAsyncGetStatus` as a stub; `xgameruntime_table_check.py` requires both rows as implemented. - Docs: `docs/experiments.md` updated. Note: `startup_async_manual_completion` documents that the installed runtime reports `S_OK` for a completed-but-undispatched block. This change deliberately keeps the shim consistent with its existing `XGameSaveInitializeProviderResult` (`E_PENDING` until dispatch); follow-up if the two should both follow the runtime. ## Verification Linux: - `python3 -B tests/xgameruntime_table_check.py` -> PASS (exports=32, stub=2) - `python3 -B tests/docs_links_check.py` -> PASS - `python3 -B tests/run_checks_parallel_check.py` -> ok - `x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only` on the shim and the new test -> clean Win2025 (Build 26100, MSVC 14.44 + D3D12 WARP, 3-slot pool) at 3609d3c1, `x2w_pipe.py win2025 2200 --force --regex "^xgameruntime_"`: - dev: `ctest --preset dev -R '^xgameruntime_' --no-tests=error` -> 8/8 passed, none skipped (incl. `xgameruntime_async_status`) - release: `ctest --preset release -R '^xgameruntime_' --no-tests=error` -> 8/8 passed, none skipped AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 05:04:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T04:47:33Z.

Review: CHANGES_REQUESTED


The new queries can turn a native completion poll into a wait that never advances. On the installed Windows runtime, startup_async_manual_completion_system measured XAsyncGetStatus(block, false) == S_OK and a nonzero result size after completion while the callback count was still zero. This implementation returns E_PENDING for both queries until the caller dispatches the callback. A caller that polls status before deciding to dispatch would keep polling even though the provider already completed.

Please keep operation completion and callback dispatch separate for both new queries. Add a source-built control that does Begin → poll status and size before the first completion dispatch → dispatch exactly once. Also cover a truly pending reserved block and the difference between wait=false and wait=true if a concurrent query can observe it. The per-operation Result behavior already merged in #2179 can be reviewed separately from these two new exports. Please coordinate the shared changes with #2201 so its user-add slots don't inherit a provider-only result-size assumption. GDK status contract

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051999335 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2200#pullrequestreview-6051999335). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T04:47:33Z. **Review:** CHANGES_REQUESTED --- The new queries can turn a native completion poll into a wait that never advances. On the installed Windows runtime, `startup_async_manual_completion_system` measured `XAsyncGetStatus(block, false) == S_OK` and a nonzero result size after completion while the callback count was still zero. This implementation returns `E_PENDING` for both queries until the caller dispatches the callback. A caller that polls status before deciding to dispatch would keep polling even though the provider already completed. Please keep operation completion and callback dispatch separate for both new queries. Add a source-built control that does Begin → poll status and size before the first completion dispatch → dispatch exactly once. Also cover a truly pending reserved block and the difference between `wait=false` and `wait=true` if a concurrent query can observe it. The per-operation Result behavior already merged in #2179 can be reviewed separately from these two new exports. Please coordinate the shared changes with #2201 so its user-add slots don't inherit a provider-only result-size assumption. [GDK status contract](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xasync/functions/xasyncgetstatus)
chatgpt-codex-connector[bot commented 2026-11-25 05:04:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T04:29:59Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T04:33:18.600303Z 3609d3c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152897548 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2200#issuecomment-7152897548). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T04:29:59Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3609d3c1ad67830d74c9f8c645eeba4a2a95070a","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T04:33:18.600303Z">2026-11-25T04:33:18.600303Z</relative-time> | `3609d3c` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
tedin7 commented 2026-11-25 05:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:00:05Z.


Addressed in 7431bdd8.

Fix: XAsyncGetStatus and XAsyncGetResultSize now keep operation completion and callback dispatch separate. Once the provider work has finished, both report the stored status and a result size of one provider handle, even while the callback still waits for XTaskQueueDispatch. Only a block whose work is still in flight is E_PENDING. wait=true on such a block sleeps on the runtime condition variable until the work completes (or the start fails, then E_INVALIDARG); wait=false returns E_PENDING.

Regression test: xgameruntime_async_status now does Begin, polls status (wait=false and wait=true) and size before the first dispatch (expects S_OK and the handle size, zero callbacks), then dispatches exactly once (callback count 1). The refused-queue-close case checks the same. Docs updated in docs/experiments.md.

Not covered: a deterministic test of a block that is still in flight with a concurrent wait=true query. The provider start finishes too fast to hold open from a source-built fixture, so that path is by inspection only.

#2201: the result size here comes from this slot table (one provider handle), not from a shared constant. User-add slots should report their own size.

Verification:

  • Linux: python3 -B tests/xgameruntime_table_check.py, tests/docs_links_check.py, tests/run_checks_parallel_check.py all PASS.
  • Win2025: python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2200 --force --regex "^xgameruntime_" gave dev 8/8 and release 8/8, zero skips, [PASS] PR #2200@7431bdd8.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153356253 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2200#issuecomment-7153356253). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:00:05Z. --- Addressed in 7431bdd8. Fix: `XAsyncGetStatus` and `XAsyncGetResultSize` now keep operation completion and callback dispatch separate. Once the provider work has finished, both report the stored status and a result size of one provider handle, even while the callback still waits for `XTaskQueueDispatch`. Only a block whose work is still in flight is `E_PENDING`. `wait=true` on such a block sleeps on the runtime condition variable until the work completes (or the start fails, then `E_INVALIDARG`); `wait=false` returns `E_PENDING`. Regression test: `xgameruntime_async_status` now does Begin, polls status (wait=false and wait=true) and size before the first dispatch (expects `S_OK` and the handle size, zero callbacks), then dispatches exactly once (callback count 1). The refused-queue-close case checks the same. Docs updated in `docs/experiments.md`. Not covered: a deterministic test of a block that is still in flight with a concurrent `wait=true` query. The provider start finishes too fast to hold open from a source-built fixture, so that path is by inspection only. #2201: the result size here comes from this slot table (one provider handle), not from a shared constant. User-add slots should report their own size. Verification: - Linux: `python3 -B tests/xgameruntime_table_check.py`, `tests/docs_links_check.py`, `tests/run_checks_parallel_check.py` all PASS. - Win2025: `python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2200 --force --regex "^xgameruntime_"` gave dev 8/8 and release 8/8, zero skips, `[PASS] PR #2200@7431bdd8`. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 06:01:24 +00:00
R0Y00 commented 2026-11-25 06:01:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T05:14:26Z.

Review: APPROVED


Re-reviewed 7431bdd8. The two queries now expose a completed provider operation before completion-port dispatch. The operation-specific Result still claims the provider once under the existing queue contract. Independently ran Windows Release xgameruntime async status, save async, thunks and table tests: 4 passed, zero skips. A genuinely in-flight concurrent wait is covered by inspection of the locked predicate and both wake paths here; the native tests exercise the completed-before-dispatch branch.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052190908 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2200#pullrequestreview-6052190908). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T05:14:26Z. **Review:** APPROVED --- Re-reviewed 7431bdd8. The two queries now expose a completed provider operation before completion-port dispatch. The operation-specific Result still claims the provider once under the existing queue contract. Independently ran Windows Release xgameruntime async status, save async, thunks and table tests: 4 passed, zero skips. A genuinely in-flight concurrent wait is covered by inspection of the locked predicate and both wake paths here; the native tests exercise the completed-before-dispatch branch.
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!2192
No description provided.