DirectStorage: a destination page number the title has not written yet is read again, not failed at once #855

Open
github-bot wants to merge 7 commits from github-bot/gh-855 into main AGit
Owner

@⁠PiloteCode on GitHub · 2026-11-25 10:47 UTC · original
PiloteCode:pr/runtime → main · +130 −36 · 10 files · 7 commits · open

Based on 9376fd6. It changes one file of victory-hle (modules/dstorage.rs) and adds a README line.

What was wrong

A request to a destination of physical pages carries an array of page numbers, one per 64 KiB. The title may fill that array after it has enqueued the request. A queue also submits on its own once it is half full, so a worker can take the request before the numbers are there. Until now, an unknown page number failed the request at once. The title never reads a request's result (it only polls for completion), so the model or texture kept whatever its pages held.

Measured at the opening's loading on an RTX 5090: 302 requests of one burst failed this way in one run, and 44 and 9 in two other runs.

What changes (into_destination)

  • The page numbers are read as the title has them now, with volatile reads each time, instead of once as a slice.
  • If one is not known after the data is decoded, the numbers are read again for up to 250 ms (15 yields, then 1 ms sleeps) until every page is known.
  • The retries that were already there (VICTORY_DSTORAGE_RETRIES, 12 tries, about 0.9 s) read the numbers again before each try.
  • Consecutive pages of one allocation, the usual case, still go through one view as before.
  • Logging. Requests that had to wait are counted in the lanes' periodic line (destination_waits). The first wait that ends with every number known is logged once, with the tries and microseconds it took. When a request still fails, one warning now says why: a page number is unknown, or the host could not map the pages. It also gives the first page number, the tries, and the totals given up and recovered on a retry. This one warning replaces two.

Measured

RTX 5090, the opening's loading and the first minutes after it:

  • With the change, no request failed. In one run, a number was known 17 µs after the worker first read it.
  • Before, 302, 44 and 9 requests failed in three runs.

Switches

  • VICTORY_DSTORAGE_RETRIES=0: as before, no retry of the write. The wait for page numbers has no switch of its own: it only runs where the request would otherwise fail.

Tested

RTX 5090, Intel i9-14900KF, Windows 11. The branch was checked as it is, on 9376fd6:

  • cargo test -p victory-hle: 98 + 1 passed, none failed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean. The first commit fixes the three lints that make CI fail on 9376fd6; the shader and GPU PRs start with the same commit.
  • cargo build --release -p victory, cargo build --profile diag -p victory --features diagnostics and cargo xtask policy pass.
  • Game runs of our tree, with this change, on the RTX 5090.

No unit test: the race needs the title's own queue.

Overlaps with open pull requests

#816 (VICTORY_DSTORAGE_ZERO_FAILED) and #836 (decode intermediates) touch the same file, for other failures.

Not tested

Other GPUs, the Series S profile, Linux/Proton.

**@⁠PiloteCode** on GitHub · 2026-11-25 10:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/855) `PiloteCode:pr/runtime` → `main` · +130 −36 · 10 files · 7 commits · open Based on `9376fd6`. It changes one file of `victory-hle` (`modules/dstorage.rs`) and adds a README line. ## What was wrong A request to a destination of physical pages carries an array of page numbers, one per 64 KiB. The title may fill that array after it has enqueued the request. A queue also submits on its own once it is half full, so a worker can take the request before the numbers are there. Until now, an unknown page number failed the request at once. The title never reads a request's result (it only polls for completion), so the model or texture kept whatever its pages held. Measured at the opening's loading on an RTX 5090: 302 requests of one burst failed this way in one run, and 44 and 9 in two other runs. ## What changes (`into_destination`) - The page numbers are read as the title has them now, with volatile reads each time, instead of once as a slice. - If one is not known after the data is decoded, the numbers are read again for up to 250 ms (15 yields, then 1 ms sleeps) until every page is known. - The retries that were already there (`VICTORY_DSTORAGE_RETRIES`, 12 tries, about 0.9 s) read the numbers again before each try. - Consecutive pages of one allocation, the usual case, still go through one view as before. - **Logging.** Requests that had to wait are counted in the lanes' periodic line (`destination_waits`). The first wait that ends with every number known is logged once, with the tries and microseconds it took. When a request still fails, one warning now says why: a page number is unknown, or the host could not map the pages. It also gives the first page number, the tries, and the totals given up and recovered on a retry. This one warning replaces two. ## Measured RTX 5090, the opening's loading and the first minutes after it: - With the change, no request failed. In one run, a number was known 17 µs after the worker first read it. - Before, 302, 44 and 9 requests failed in three runs. ## Switches - `VICTORY_DSTORAGE_RETRIES=0`: as before, no retry of the write. The wait for page numbers has no switch of its own: it only runs where the request would otherwise fail. ## Tested RTX 5090, Intel i9-14900KF, Windows 11. The branch was checked as it is, on `9376fd6`: - `cargo test -p victory-hle`: 98 + 1 passed, none failed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. The first commit fixes the three lints that make CI fail on `9376fd6`; the shader and GPU PRs start with the same commit. - `cargo build --release -p victory`, `cargo build --profile diag -p victory --features diagnostics` and `cargo xtask policy` pass. - Game runs of our tree, with this change, on the RTX 5090. No unit test: the race needs the title's own queue. ## Overlaps with open pull requests #816 (`VICTORY_DSTORAGE_ZERO_FAILED`) and #836 (decode intermediates) touch the same file, for other failures. ## Not tested Other GPUs, the Series S profile, Linux/Proton.
`cargo clippy --workspace --all-targets -- -D warnings` (CI) fails on 9376fd6
with this toolchain: unnecessary_sort_by in draw.rs, the bench's
depth_written in indirect.rs never read, and placed_filler_twins unused
without the diagnostics feature. No code changes.
The title may fill a request's page numbers after it enqueued the
request, and a queue submits on its own once half full, so a worker can
take the request first. An unknown page failed the request at once, and
its model or texture kept whatever its pages held (the title never reads
a request's result): 302 requests of one burst at the opening's loading
in one run, 44 and 9 in others (RTX 5090).

The page numbers are now read as the title has them (volatile, each
time, not kept as a slice). One not known after the decode is read again
for up to 250 ms (15 yields, then 1 ms sleeps); the retries of the write
(VICTORY_DSTORAGE_RETRIES) read them again before each try. In a run, a
number was known 17 us later, and no request failed.

Requests that waited are counted in the lanes' line (destination_waits);
the first wait that ends with every number known is logged once. A
request that still fails says why in one warning: a page number unknown,
or pages the host could not map.
One conflict, in crates/victory-hle/src/modules/dstorage.rs: each side
added a static after into_destination (DESTINATION_WAITS here,
AUTO_SUBMITS upstream). Both are kept.

Upstream's 79cfdd96 leaves the reads into physical pages out when a
half-full queue submits itself, until the title's Submit
(Lanes::submit_as), and starts them before it only where a full queue
would otherwise never empty. It does not touch into_destination: the
page numbers are still read volatile each time, read again for up to
250 ms where one is unknown, and read again before each retry of the
write.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
Since upstream's 79cfdd96, a queue that submits itself half full leaves
its reads into physical pages for the title's Submit. The wait in
into_destination is then reached only by a read that starts before the
title wrote its numbers: a full queue's held reads. Its note and the
README line said that a half-full queue's own submission brought a worker
to the request first. Both now say where that still happens, and that the
failures they count were measured before reads were held.

The test submits a read whose list holds no page number yet and writes
the number 20 ms later: the request succeeds and the page holds its
bytes. No change of behaviour.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:37 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head e821cdb into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean, and the same with --all-features: clean (main itself fails both on this machine: dead code and a sort in victory-gpu). cargo test --workspace --locked: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

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

**@⁠MamaLeVrai** on GitHub · 2026-11-25 12:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7162308928) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `e821cdb` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: **clean**, and the same with `--all-features`: clean (`main` itself fails both on this machine: dead code and a sort in `victory-gpu`). `cargo test --workspace --locked`: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (`main` alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 16:23 UTC · original

@⁠MamaLeVrai Thanks for the build and test run on an RX 6950 XT. It confirms that the branch merges into f85101b without a conflict, passes clippy with and without --all-features, and keeps main's test count (555 passed, 11 ignored).

The clippy failures you saw on main alone are the ones this PR's first commit fixes (19d40a7), all in victory-gpu:

  • unnecessary_sort_by in draw.rs;
  • the bench's depth_written, never read, in indirect.rs;
  • placed_filler_twins, unused without the diagnostics feature.

#854 starts with the same commit.

For the effect in the title: on our RTX 5090 test machine, 302, 44 and 9 requests failed in three runs of the opening's loading before the change, and none after. If you run the title with it, any build logs:

  • one line the first time a request's page numbers become known only after a worker took it;
  • one warning, with the reason, for each request that still fails.

A diagnostics build with VICTORY_LOG=victory_hle::modules::dstorage=debug,info also counts the requests that waited, every 5 s (destination_waits).

**@⁠PiloteCode** on GitHub · 2026-11-25 16:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7167901527) @⁠MamaLeVrai Thanks for the build and test run on an RX 6950 XT. It confirms that the branch merges into `f85101b` without a conflict, passes clippy with and without `--all-features`, and keeps `main`'s test count (555 passed, 11 ignored). The clippy failures you saw on `main` alone are the ones this PR's first commit fixes (`19d40a7`), all in `victory-gpu`: - `unnecessary_sort_by` in `draw.rs`; - the bench's `depth_written`, never read, in `indirect.rs`; - `placed_filler_twins`, unused without the `diagnostics` feature. #854 starts with the same commit. For the effect in the title: on our RTX 5090 test machine, 302, 44 and 9 requests failed in three runs of the opening's loading before the change, and none after. If you run the title with it, any build logs: - one line the first time a request's page numbers become known only after a worker took it; - one warning, with the reason, for each request that still fails. A diagnostics build with `VICTORY_LOG=victory_hle::modules::dstorage=debug,info` also counts the requests that waited, every 5 s (`destination_waits`).
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:11 UTC · original

Merged main (c36971b) into the branch: a merge commit on top of the commits already here (fee0239), then three small commits. The branch merges into main without a conflict again.

The conflict. One, in dstorage.rs: each side had added a static after into_destination (DESTINATION_WAITS here, AUTO_SUBMITS on main). Both are kept.

What main's 79cfdd9 changes for this PR. A queue that submits itself half full now leaves its reads into physical pages for the title's Submit. That closes the path this PR was written for. It also covers a list that still names a page's previous owner, which this PR never did: it only waits for a number that is not known. What this PR still adds on top of the hold:

  • The page numbers are read with volatile reads each time, not through a slice over memory the title may be writing.
  • A read that starts before the title wrote its numbers reads them again for up to 250 ms, and again before each retry of the write. With reads held, only a full queue's held reads start that early (queue).
  • The waits are counted in the lanes' line, and a request that still fails says why in one warning.

The numbers in the description (302, 44 and 9 failed requests before, none after) were measured before 79cfdd9. What this PR changes in the title on top of the hold has not been measured: the merged branch has not run in the title.

Added after the merge:

  • Two lint commits for main's newer code, the same as on our other open branches: manual_is_multiple_of in shadow.rs, queue.rs, draw.rs and watch.rs, map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs. Without them cargo clippy --workspace --all-targets --locked -- -D warnings fails on c36971b, with or without --all-features.
  • One commit that brings the note in into_destination and the README line up to date (they said a half-full queue's own submission brought a worker to the request first), and adds a test, a_page_number_written_after_its_read_started_is_read_again: a read is submitted with no page number in its list, the number is written 20 ms later, the request succeeds and the page holds its bytes. The test passes on main alone too (c36971b with only the test added): there the retries of the write read the list's memory again. So it holds the behaviour, and does not tell this branch from main. No change of behaviour in this commit.

Checked, the branch as it is (f0c8068), every test on the software adapter:

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy, cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics: pass.
  • cargo test -p victory-hle -- --test-threads=1: 101 + 1 passed (main: 100 + 1; the one more is the new test).
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 200 passed, 1 failed, 6 ignored, as on main. The failure is depth_bounds_pipeline_loads_and_filters_draws: WARP does not reject the pixels outside the depth bounds.
  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 212 passed, 4 failed, 3 ignored, the same four as on main on the software adapter.
  • cargo test -p victory -p victory-loader: passed.
**@⁠PiloteCode** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7176054556) Merged `main` (`c36971b`) into the branch: a merge commit on top of the commits already here (`fee0239`), then three small commits. The branch merges into `main` without a conflict again. **The conflict.** One, in `dstorage.rs`: each side had added a static after `into_destination` (`DESTINATION_WAITS` here, `AUTO_SUBMITS` on `main`). Both are kept. **What `main`'s 79cfdd9 changes for this PR.** A queue that submits itself half full now leaves its reads into physical pages for the title's Submit. That closes the path this PR was written for. It also covers a list that still names a page's previous owner, which this PR never did: it only waits for a number that is not known. What this PR still adds on top of the hold: - The page numbers are read with volatile reads each time, not through a slice over memory the title may be writing. - A read that starts before the title wrote its numbers reads them again for up to 250 ms, and again before each retry of the write. With reads held, only a full queue's held reads start that early (`queue`). - The waits are counted in the lanes' line, and a request that still fails says why in one warning. The numbers in the description (302, 44 and 9 failed requests before, none after) were measured before 79cfdd9. What this PR changes in the title on top of the hold has not been measured: the merged branch has not run in the title. **Added after the merge:** - Two lint commits for `main`'s newer code, the same as on our other open branches: `manual_is_multiple_of` in `shadow.rs`, `queue.rs`, `draw.rs` and `watch.rs`, `map_entry` in `fpsbox.rs`, `collapsible_if` in `pipeline/library.rs`. Without them `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on `c36971b`, with or without `--all-features`. - One commit that brings the note in `into_destination` and the README line up to date (they said a half-full queue's own submission brought a worker to the request first), and adds a test, `a_page_number_written_after_its_read_started_is_read_again`: a read is submitted with no page number in its list, the number is written 20 ms later, the request succeeds and the page holds its bytes. The test passes on `main` alone too (`c36971b` with only the test added): there the retries of the write read the list's memory again. So it holds the behaviour, and does not tell this branch from `main`. No change of behaviour in this commit. **Checked**, the branch as it is (`f0c8068`), every test on the software adapter: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo xtask policy`, `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics`: pass. - `cargo test -p victory-hle -- --test-threads=1`: 101 + 1 passed (`main`: 100 + 1; the one more is the new test). - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 200 passed, 1 failed, 6 ignored, as on `main`. The failure is `depth_bounds_pipeline_loads_and_filters_draws`: WARP does not reject the pixels outside the depth bounds. - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 212 passed, 4 failed, 3 ignored, the same four as on `main` on the software adapter. - `cargo test -p victory -p victory-loader`: passed.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/fpsbox.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/pipeline/library.rs
  • crates/victory-gpu/src/resource.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/855/head:github-bot/gh-855'
git switch 'github-bot/gh-855'

Merge

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