GPU/HLE: pipelined startup reads and pooled small buffers, rebased onto main #2665

Open
kais7654 wants to merge 4 commits from upstream-pr/2667 into main
kais7654 commented 2026-11-25 17:46:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T17:46:14Z.


Rebases #2427 by @imjustprism onto current main (67e8ae1), authorship preserved
commit by commit. This carries the measured startup numbers of the original PR
forward:

launch to first screen main this branch
cold, file cache purged 48.8, 49.5 s 21.0, 21.3, 21.3 s
launched again, files cached 37.0, 47.5 s 5.5, 5.5, 5.5 s

(same bytes read; RX 9070 XT, game folder on a 7200 rpm drive, per the
original report on top of 940d32f).

The rebase points:

  • placed.rs (pooled 16 MiB heaps for small shared buffers) coexists with
    main's placement.rs — main's is for textures, this one for CPU-mapped
    shared buffers; Host::shared_buffer keeps main's diagnostics GPU-upload
    heap preference where a pool slot does not apply.
  • main's held queue (#1663-fixup commit eddde73, "reads into physical pages
    wait for the title's Submit") is integrated into the overlap scheduler: an
    explicit Submit releases the held reads, a queue that submitted itself
    keeps its page reads held until then, and a moved read returns its count
    for a per-read wake (Scheduler::submit_and_wake).
  • the held-queue test adopts the overlapped finish's now must-use return.

The two narrow edges from the review's reading stand as written (the placed
resource's deferred teardown on a fast re-take; dropped_flags staying as
conservative as it is) — flagged for _

Local check: clippy --workspace --all-targets -D warnings with and without
--all-features; victory-hle 162/162 (28 dstorage tests including the held and
overlap suites), victory-gpu 207 passed (the two heap-cap failures that
#1943's fix owns), victory-shader 266 passed (the NVIDIA machine trio of
#2317).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6610315991 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2667). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T17:46:14Z. --- Rebases #2427 by @imjustprism onto current main (67e8ae1), authorship preserved commit by commit. This carries the measured startup numbers of the original PR forward: | launch to first screen | main | this branch | |---|---|---| | cold, file cache purged | 48.8, 49.5 s | 21.0, 21.3, 21.3 s | | launched again, files cached | 37.0, 47.5 s | 5.5, 5.5, 5.5 s | (same bytes read; RX 9070 XT, game folder on a 7200 rpm drive, per the original report on top of 940d32f). The rebase points: - `placed.rs` (pooled 16 MiB heaps for small shared buffers) coexists with main's `placement.rs` — main's is for textures, this one for CPU-mapped shared buffers; `Host::shared_buffer` keeps main's diagnostics GPU-upload heap preference where a pool slot does not apply. - main's held queue (#1663-fixup commit eddde73, "reads into physical pages wait for the title's Submit") is integrated into the overlap scheduler: an explicit Submit releases the held reads, a queue that submitted itself keeps its page reads held until then, and a moved read returns its count for a per-read wake (`Scheduler::submit_and_wake`). - the held-queue test adopts the overlapped `finish`'s now must-use return. The two narrow edges from the review's reading stand as written (the placed resource's deferred teardown on a fast re-take; `dropped_flags` staying as conservative as it is) — flagged for _ Local check: clippy --workspace --all-targets -D warnings with and without --all-features; victory-hle 162/162 (28 dstorage tests including the held and overlap suites), victory-gpu 207 passed (the two heap-cap failures that #1943's fix owns), victory-shader 266 passed (the NVIDIA machine trio of #2317).
kotekompotek commented 2026-11-25 18:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:57:16Z.


Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170232957 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7170232957). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:57:16Z. --- Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified.
kais7654 commented 2026-11-25 19:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T18:26:32Z.


Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified.

Thanks @kotekompotek. For the maintainer's pass on the rebase-specific
hunks, these are the three places where the rebase touches more than
moving lines:

  1. crates/victory-gpu/src/lib.rs — mod placed; (this PR's small shared
    buffers) now sits next to main's mod placement; (wbkepler's texture
    pools). They do not share code; Host::shared_buffer resolves the two
    — pool slot first, then the committed fallback with main's
    diagnostics GPU-upload heap preference preserved (host.rs, the
    #[cfg(feature = "diagnostics")] let heap block inside the new
    &'static self signature).

  2. crates/victory-hle/src/modules/dstorage.rs — main's held queue
    (eddde73) is integrated into the overlapped scheduler: submit returns
    the read count for submit_and_wake's per-read wake, submit_as(id, explicit) keeps main's semantics (an explicit Submit releases the held
    reads, a self-submit leaves its page reads held, statuses behind a held
    read wait with it). The two pre-existing test suites (held queue +
    overlap) both pass on this merge, which was the intended proof.

  3. The held-queue test adopts the overlapped finish's now must-use
    return (let _ = l.finish(...)), nothing else changed in tests.

Everything else is a clean cherry-pick of d08323e^..d08323e with
imjustprism's authorship preserved per commit.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170912007 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7170912007). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T18:26:32Z. --- > Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified. Thanks @kotekompotek. For the maintainer's pass on the rebase-specific hunks, these are the three places where the rebase touches more than moving lines: 1. `crates/victory-gpu/src/lib.rs` — `mod placed;` (this PR's small shared buffers) now sits next to main's `mod placement;` (wbkepler's texture pools). They do not share code; `Host::shared_buffer` resolves the two — pool slot first, then the committed fallback with main's diagnostics GPU-upload heap preference preserved (host.rs, the `#[cfg(feature = "diagnostics")] let heap` block inside the new `&'static self` signature). 2. `crates/victory-hle/src/modules/dstorage.rs` — main's held queue (eddde73) is integrated into the overlapped scheduler: `submit` returns the read count for `submit_and_wake`'s per-read wake, `submit_as(id, explicit)` keeps main's semantics (an explicit Submit releases the held reads, a self-submit leaves its page reads held, statuses behind a held read wait with it). The two pre-existing test suites (held queue + overlap) both pass on this merge, which was the intended proof. 3. The held-queue test adopts the overlapped `finish`'s now must-use return (`let _ = l.finish(...)`), nothing else changed in tests. Everything else is a clean cherry-pick of d08323e^..d08323e with imjustprism's authorship preserved per commit.
fuzeofficlal commented 2026-11-25 19:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:37:16Z.


Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of df7cb800 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 185 files ok.
  • cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings: 0 warnings.
  • cargo clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-hle --lib: 162 passed, 0 failed, 0 ignored.
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1 -> 212 passed, 0 failed, 1 ignored (all 14 new placed::tests pass).
  • NVIDIA GeForce RTX 5090:
    • cargo test --locked -p victory-gpu --features diagnostics --lib placed::tests -- --test-threads=1 -> 14 passed, 0 failed (0.36s).
    • Full victory-gpu --features diagnostics --lib -- --test-threads=1 -> 210 passed, 2 failed, 1 ignored (1.93s). The only 2 failures are the pre-existing RTX 5090 1M view-heap cap baseline failures (#1744: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views).

Code Review Notes

  • Pipelined startup reads (dstorage.rs, files.rs): Overlapped ReadFile with per-worker manual-reset events, CancelIoEx + volatile Internal == STATUS_PENDING drain on error, staging starvation wakeup (starved -> notify_all), kernel_will_write guard lifetime, and dropped_flags scoping (CreateFileW, GENERIC_READ, non-overlapped only) all look sound.
  • Small buffer pool (placed.rs, host.rs, shadow.rs): Leaf-lock discipline (Pool::slots never held across D3D12 heap/resource creation or drop), 64 KiB alignment and write_bytes zeroing of [0..width_bytes.max(1)), and fence-deferred retirement via ID3DDestructionNotifier look solid.
  • Minor diagnostics-mode ordering nit (crates/victory-gpu/src/host.rs:3230-3240): Host::shared_buffer calls self.small_buffers.buffer(width_bytes) before checking #[cfg(feature = "diagnostics")] self.copies_in_video_memory(), so VICTORY_COPIES_IN_VIDEO_MEMORY=1 still places <= 64 KiB buffers in the system-memory WRITE_BACK pool instead of GPU_UPLOAD. Checking copies_in_video_memory() first would keep that diagnostic switch consistent across all buffer sizes.
  • Note on dstorage.rs merge ordering: touches Lanes::submit_as / Lane alongside #2617 (plain reads held behind a held Status fence).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7171161135 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7171161135). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T18:37:16Z. --- Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of `df7cb800` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **185 files ok**. - `cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings`: **0 warnings**. - `cargo clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-hle --lib`: **162 passed, 0 failed, 0 ignored**. - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1` -> **212 passed, 0 failed, 1 ignored** (all 14 new `placed::tests` pass). - **NVIDIA GeForce RTX 5090:** - `cargo test --locked -p victory-gpu --features diagnostics --lib placed::tests -- --test-threads=1` -> **14 passed, 0 failed** (0.36s). - Full `victory-gpu --features diagnostics --lib -- --test-threads=1` -> **210 passed, 2 failed, 1 ignored** (1.93s). The only 2 failures are the pre-existing RTX 5090 1M view-heap cap baseline failures (#1744: `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`). ### Code Review Notes - **Pipelined startup reads (`dstorage.rs`, `files.rs`):** Overlapped `ReadFile` with per-worker manual-reset events, `CancelIoEx` + volatile `Internal == STATUS_PENDING` drain on error, `staging` starvation wakeup (`starved` -> `notify_all`), `kernel_will_write` guard lifetime, and `dropped_flags` scoping (`CreateFileW`, `GENERIC_READ`, non-overlapped only) all look sound. - **Small buffer pool (`placed.rs`, `host.rs`, `shadow.rs`):** Leaf-lock discipline (`Pool::slots` never held across D3D12 heap/resource creation or drop), 64 KiB alignment and `write_bytes` zeroing of `[0..width_bytes.max(1))`, and fence-deferred retirement via `ID3DDestructionNotifier` look solid. - **Minor diagnostics-mode ordering nit (`crates/victory-gpu/src/host.rs:3230-3240`):** `Host::shared_buffer` calls `self.small_buffers.buffer(width_bytes)` *before* checking `#[cfg(feature = "diagnostics")] self.copies_in_video_memory()`, so `VICTORY_COPIES_IN_VIDEO_MEMORY=1` still places `<= 64 KiB` buffers in the system-memory `WRITE_BACK` pool instead of `GPU_UPLOAD`. Checking `copies_in_video_memory()` first would keep that diagnostic switch consistent across all buffer sizes. - **Note on `dstorage.rs` merge ordering:** touches `Lanes::submit_as` / `Lane` alongside #2617 (plain reads held behind a held `Status` fence).
Marvisak commented 2026-11-25 23:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:23:16Z.


Automated triage for the maintainers.

Proposed close. This branch repackages #2427 (imjustprism's small-buffer pool, buffered pack opens in files.rs, and the DirectStorage scheduling and overlapped reads in dstorage.rs) as a new PR. #2427 is still open, merged cleanly into main when it was last triaged, and its author is answering that triage. The triage on #2427 asked for the four changes to be split into separate PRs and for their relation to #1457 and #234 to be explained. This branch keeps them bundled, about 1,400 lines in one PR, so it does not address that and only adds a second copy to track. The rebase work around main's held queue (submit_as / submit_and_wake) is better offered to imjustprism on #2427 or on the split PRs.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176298606 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7176298606). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:23:16Z. --- <!-- victory-triage v1 head=df7cb800ff5e9b4aa7b5f79029196e4498f4937e verdict=proposed-close at=2026-11-25T22:28:30Z --> Automated triage for the maintainers. **Proposed close.** This branch repackages #2427 (imjustprism's small-buffer pool, buffered pack opens in `files.rs`, and the DirectStorage scheduling and overlapped reads in `dstorage.rs`) as a new PR. #2427 is still open, merged cleanly into `main` when it was last triaged, and its author is answering that triage. The triage on #2427 asked for the four changes to be split into separate PRs and for their relation to #1457 and #234 to be explained. This branch keeps them bundled, about 1,400 lines in one PR, so it does not address that and only adds a second copy to track. The rebase work around `main`'s held queue (`submit_as` / `submit_and_wake`) is better offered to imjustprism on #2427 or on the split PRs. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2667:upstream-pr/2667'
git switch 'upstream-pr/2667'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2667'
git switch 'upstream-pr/2667'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2667'
git switch 'upstream-pr/2667'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2667'
git switch 'main'
git merge --squash 'upstream-pr/2667'
git switch 'main'
git merge --ff-only 'upstream-pr/2667'
git switch 'main'
git merge 'upstream-pr/2667'
git push origin 'main'
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
Marvisak/VIctory!2665
No description provided.