[BUNDLE] XAsync, kernel, lifecycle and DirectStorage HLE: #114 #122 #247 #1098 #186 #373 #512 #451 #1080 #430 #577 #1238 #1363

Open
github-bot wants to merge 28 commits from github-bot/gh-1363 into main AGit
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 17:36 UTC · original
MamaLeVrai:bundle/hle-async → main · +801 −89 · 4 files · 28 commits · open

One PR in place of 12. The HLE PRs on XAsync, the kernel module, window lifecycle and DirectStorage: call completion and cancel races, GetModuleFileName, relaunch and suspend, queued reads. Every head is merged unchanged onto main (70564ae, after the maintainer's 28 commits of Nov 24, 22:36 CET), and the result is built and tested together.

For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a [BUNDLE] PR. The re-verification commands are below, so one run covers all of it.

What is inside

PR Author Head Title
#114 AndyLatimer 0b729de6e XAsync: run a failed call's cleanup without the completion lock
#122 Dufftwt d01b17070 XAsync: end the call that finished, not whatever call the block holds now
#247 Maraco91 5cff0007a XAsync: a new block where a result was left behind begins a call
#1098 BastienRodz 44ce06784 XAsync: canceling a call that already completed leaves it alone, as documented
#186 Maraco91 3c7d845b3 Kernel: a title image's file name that fits clears the last error
#373 marquezinii c000581df Kernel: GetModuleFileName of a title image into a null buffer
#512 Quat3rnion 829f77472 HLE: resolve ordinals on pseudo-module handles
#451 enzoduarte1 8ff871b71 HLE: keep fitted window dimensions positive
#1080 giusepperainone a7847a520 HLE: constrain the title before suspending it (window close never suspended)
#430 marquezinii 129d2897c DirectStorage: Close completes what was submitted
#577 DenRakEiw 40816378b dstorage: retain queued file references and validate null out pointers
#1238 Jitheswar 591932ac8 Grow DirectStorage BCPack intermediates as zlib inflates

Changes made while bundling

No merge conflicts. One change of mine, in its own commit: the test #512 adds passed a pointer written 1 as *const u8 to GetProcAddress, which clippy::manual_dangling_ptr rejects under -D warnings (#512's own CI run fails on it). It is now std::ptr::dangling::<u8>(), the same address (1). A second commit makes a flaky test race-free: factory_methods_reject_null_out_without_leaking (#577) counted all the lanes of the shared DirectStorage scheduler before and after a call while the other tests of the module create and close queues at the same time; with cargo test -p victory-hle dstorage it failed on every run here (3 of 3), and in the full workspace run only some of the time. It now creates its queue with a capacity no other test uses (0x5EED) and checks that no lane of that capacity exists afterwards (8 of 8 runs pass).

Rebuilt on the new main. The branch is the previous one with main merged in (no textual conflict), plus one line: main moved a DirectStorage request into QueuedRead, so a line of one of this bundle's PRs that counts page-destination jobs (job.request.options) merged cleanly but no longer compiled; it reads job.read.request.options now (a separate commit).

Verification

Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain):

Check Result
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo test --workspace --locked 491 passed, 0 failed, 7 ignored (4 of 5 runs; the fifth failed in emit::memory_tests::title_memory_is_read_and_written_at_computed_addresses, a test of main in victory-shader that passes alone and that also failed once on two other trees here; main: 476 passed, 7 ignored)

The title was not run, so this says nothing about in-game effect. No game data is used or committed.

Re-verify in one go

git fetch https://github.com/MamaLeVrai/VIctory.git bundle/hle-async
git checkout FETCH_HEAD
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked

To confirm that no component PR moved since this was built, compare each Head above with gh pr view <n> --repo Marvisak/VIctory --json headRefOid. If one differs, the branch needs a rebuild: merge the new head in the same order.

If this lands

The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠MamaLeVrai** on GitHub · 2026-11-24 17:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1363) `MamaLeVrai:bundle/hle-async` → `main` · +801 −89 · 4 files · 28 commits · open **One PR in place of 12.** The HLE PRs on XAsync, the kernel module, window lifecycle and DirectStorage: call completion and cancel races, `GetModuleFileName`, relaunch and suspend, queued reads. Every head is merged unchanged onto `main` (`70564ae`, after the maintainer's 28 commits of Nov 24, 22:36 CET), and the result is built and tested together. > For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a `[BUNDLE]` PR. The re-verification commands are below, so one run covers all of it. ## What is inside | PR | Author | Head | Title | |---|---|---|---| | #114 | AndyLatimer | `0b729de6e` | XAsync: run a failed call's cleanup without the completion lock | | #122 | Dufftwt | `d01b17070` | XAsync: end the call that finished, not whatever call the block holds now | | #247 | Maraco91 | `5cff0007a` | XAsync: a new block where a result was left behind begins a call | | #1098 | BastienRodz | `44ce06784` | XAsync: canceling a call that already completed leaves it alone, as documented | | #186 | Maraco91 | `3c7d845b3` | Kernel: a title image's file name that fits clears the last error | | #373 | marquezinii | `c000581df` | Kernel: GetModuleFileName of a title image into a null buffer | | #512 | Quat3rnion | `829f77472` | HLE: resolve ordinals on pseudo-module handles | | #451 | enzoduarte1 | `8ff871b71` | HLE: keep fitted window dimensions positive | | #1080 | giusepperainone | `a7847a520` | HLE: constrain the title before suspending it (window close never suspended) | | #430 | marquezinii | `129d2897c` | DirectStorage: Close completes what was submitted | | #577 | DenRakEiw | `40816378b` | dstorage: retain queued file references and validate null out pointers | | #1238 | Jitheswar | `591932ac8` | Grow DirectStorage BCPack intermediates as zlib inflates | ## Changes made while bundling No merge conflicts. One change of mine, in its own commit: the test #512 adds passed a pointer written `1 as *const u8` to `GetProcAddress`, which `clippy::manual_dangling_ptr` rejects under `-D warnings` (#512's own CI run fails on it). It is now `std::ptr::dangling::<u8>()`, the same address (1). A second commit makes a flaky test race-free: `factory_methods_reject_null_out_without_leaking` (#577) counted all the lanes of the shared DirectStorage scheduler before and after a call while the other tests of the module create and close queues at the same time; with `cargo test -p victory-hle dstorage` it failed on every run here (3 of 3), and in the full workspace run only some of the time. It now creates its queue with a capacity no other test uses (`0x5EED`) and checks that no lane of that capacity exists afterwards (8 of 8 runs pass). **Rebuilt on the new `main`.** The branch is the previous one with `main` merged in (no textual conflict), plus one line: `main` moved a DirectStorage request into `QueuedRead`, so a line of one of this bundle's PRs that counts page-destination jobs (`job.request.options`) merged cleanly but no longer compiled; it reads `job.read.request.options` now (a separate commit). ## Verification Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain): | Check | Result | |---|---| | `cargo clippy --workspace --all-targets --locked -- -D warnings` | clean | | `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` | clean | | `cargo test --workspace --locked` | 491 passed, 0 failed, 7 ignored (4 of 5 runs; the fifth failed in `emit::memory_tests::title_memory_is_read_and_written_at_computed_addresses`, a test of `main` in `victory-shader` that passes alone and that also failed once on two other trees here; `main`: 476 passed, 7 ignored) | The title was not run, so this says nothing about in-game effect. No game data is used or committed. ## Re-verify in one go ```powershell git fetch https://github.com/MamaLeVrai/VIctory.git bundle/hle-async git checkout FETCH_HEAD cargo clippy --workspace --all-targets --locked -- -D warnings cargo clippy --workspace --all-targets --all-features --locked -- -D warnings cargo test --workspace --locked ``` To confirm that no component PR moved since this was built, compare each `Head` above with `gh pr view <n> --repo Marvisak/VIctory --json headRefOid`. If one differs, the branch needs a rebuild: merge the new head in the same order. ## If this lands The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Our own completions looked their call up again by block address: after a
provider's DoWork returned, after a cancel, after a failed begin, and when
queued DoWork ran. A provider usually ends its call itself (XAsyncComplete
from DoWork or Cancel), and once it has, the title may begin a new call on
the same block, from its completion routine or from a thread that polls
the status. The lookup then found that new call:

- the old call's DoWork result (S_OK, size 0) or cancel (E_ABORT) ended
  the new call before it had done anything, ran its cleanup and fired the
  completion routine a second time;
- DoWork still queued for a canceled call ran the new call's DoWork.

Each queued DoWork now carries the call that scheduled it and runs only
while that call is still the block's, and DoWork, cancel and begin
complete that call. A call that is already over ignores a second
complete, so nothing reaches the next call. XAsyncComplete itself still
goes by block, as providers name their call by its block.
XAsyncComplete held the call's `done` lock while the title's provider
ran OP_CLEANUP. A cleanup that waits for a worker thread which is itself
completing the same call (it took the call before the cleanup removed
it) deadlocked: the worker blocks on `done`. The first completion now
claims the call with an atomic flag and runs unlocked; the status is
still published after the cleanup, while the block is valid, and `done`
is set only for the waiters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetModuleFileNameA/W on the host clears the thread's last error when
the name fits, and code tells a truncated name from a whole one by it
(grow the buffer while the last error is ERROR_INSUFFICIENT_BUFFER; or
fail if it is, also when the name filled the buffer exactly). Our
answer for a title image set the error when the name was cut and left
it alone otherwise, so after one call with too small a buffer, or
after any earlier call on the thread that left 122, a whole name still
read as truncated.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Calls are filed by their block's address, and a call that succeeded with
a result stays filed until XAsyncGetResult takes it. XAsyncBegin refused
any block whose address had a call filed. So when a title never took a
result and freed the block, the next block it was given at that address
could not begin a call: E_INVALIDARG, every time, with the old call's
provider never cleaned up.

A zeroed block is a new one: the block of a result left behind holds the
result's size, so it never reads zero. XAsyncBegin now ends a finished
call filed under the address of a zeroed block (its provider gets its
cleanup) and begins the new one. A call still in flight keeps its
address, and a block still holding a result is refused as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A slice may not start at null, even an empty one, so asking for a title
image's name with (NULL, 0) was undefined behaviour; a debug build
aborted the process. A null buffer is now no buffer: nothing is written,
0 is returned and the last error is ERROR_INSUFFICIENT_BUFFER.
IDStorageQueueX::Close blocks until all enqueued requests complete or
fail. close_lane dropped submitted reads that had not started and every
pending status entry, and waited only for the reads already running, so
a title polling a status entry after Close waited forever. Requests
enqueued but never submitted are still dropped.
GetProcAddress rejected every ordinal below 0x10000 for our pseudo modules, but some APIs (GameInputCreate) are exported only as ordinal 1. Look up the registry's #n export name so a title that loads the module and asks for its ordinal gets the implementation. Add a regression for gameinput.dll #1 and an unexported ordinal.
Closing the window never suspended Grand Theft Auto VI: its suspend
routine waits for a state that only its constrained-change routine
starts, and RegisterAppConstrainedChangeNotification bound to the host's
version, which never calls it. Every close ended in the one-second
deadline.

Register constrained-change routines here and run them (constrained)
before the suspend routines (quiesced), as the console does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Microsoft's XAsyncCancel reference says: "If the XAsyncCancel function
is invoked for an asynchronous call that has already completed, nothing
happens."

A call that completed successfully with a nonempty result stays in
CALLS until the title reads the result via XAsyncGetResult, so
XAsyncCancel still found it and invoked the provider with OP_CANCEL
before XAsyncComplete returned early on call.done.

Check call.done under its lock in XAsyncCancel and return immediately
when the call is already complete, dropping the lock before invoking
the provider.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merges #114 #122 #247 #1098 #186 #373 #512 #451 #1080 #430 #577 #1238 onto
main (ffe310e), each head unchanged, no conflicts.

One change of mine: the test #512 adds passed a pointer built as
`1 as *const u8` to GetProcAddress, which clippy::manual_dangling_ptr
rejects under -D warnings; it is now `std::ptr::dangling::<u8>()`, the same
address (1).

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(357 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
factory_methods_reject_null_out_without_leaking (#577) counted all lanes of
the shared DirectStorage scheduler before and after a call, while the other
tests of the module create and close queues at the same time. With
`cargo test -p victory-hle dstorage` it failed on every run here (the full
workspace run only sometimes). It now creates the queue with a capacity no
other test uses and checks that no lane of that capacity exists afterwards.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
main moved the request into QueuedRead (job.read.request); one PR of the bundle counts pages
destination jobs with the old path, which merged textually but no longer compiled.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:50 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 18:45 UTC · original

Runtime boot check on real hardware with a retail dump

Result: no difference from main in this test.

I merged head 490668a onto main ffe310e (clean merge), built it (release), and ran victory run <title exe> --execute with an empty data folder for 100 s, without any input. I compared the run with main built and run the same way.

main ffe310e this PR
Reaches the first-boot screens yes yes
Caption at 100 s (one sample) 30 fps, 12 draws/frame 30 fps, 12 draws/frame
Frames presented 2,048 2,048
crashes.log entries 0 0
Committed memory 11.1 GB 11.1 GB

Warnings: 7, the same kinds and counts as on main. 0 errors.

Limits. Without input, the title stays on the first-boot screens. This run does not exercise saves, the intro video, the start screen, loading or the world. It shows only that the change does not break startup or the first menus on this machine. I did not run the PR's tests.

Machine: Ryzen 7 7800X3D, RTX 4070 SUPER, Windows 11 25H2, game 1.0.2.1. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 18:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1363#issuecomment-7141106861) ### Runtime boot check on real hardware with a retail dump **Result: no difference from `main` in this test.** I merged head 490668a onto `main` ffe310e (clean merge), built it (release), and ran `victory run <title exe> --execute` with an empty data folder for 100 s, without any input. I compared the run with `main` built and run the same way. | | `main` ffe310e | this PR | |---|---|---| | Reaches the first-boot screens | yes | yes | | Caption at 100 s (one sample) | 30 fps, 12 draws/frame | 30 fps, 12 draws/frame | | Frames presented | 2,048 | 2,048 | | `crashes.log` entries | 0 | 0 | | Committed memory | 11.1 GB | 11.1 GB | **Warnings:** 7, the same kinds and counts as on `main`. 0 errors. **Limits.** Without input, the title stays on the first-boot screens. This run does not exercise saves, the intro video, the start screen, loading or the world. It shows only that the change does not break startup or the first menus on this machine. I did not run the PR's tests. Machine: Ryzen 7 7800X3D, RTX 4070 SUPER, Windows 11 25H2, game 1.0.2.1. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:24 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-hle/src/modules/xasync.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1363#issuecomment-7149508776) <!-- victory-triage v1 head=8e6d0b71b6f94af6431df16abc055bd5daf9446a verdict=needs-rebase at=2026-11-25T01:24:12Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-hle/src/modules/xasync.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-hle/src/modules/dstorage.rs
  • crates/victory-hle/src/modules/xasync.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1363'
git switch 'github-bot/gh-1363'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1363'
git switch 'github-bot/gh-1363'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1363'
git switch 'main'
git merge --squash 'github-bot/gh-1363'
git switch 'main'
git merge --ff-only 'github-bot/gh-1363'
git switch 'main'
git merge 'github-bot/gh-1363'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1363
No description provided.