perf(gpu): deduplicate and parallelize texture readback landing across flight lists #4683

Open
github-bot wants to merge 1 commit from github-bot/gh-4682 into main AGit
Owner

@⁠YounesAH15 on GitHub · 2026-12-01 01:42 UTC · original
YounesAH15:perf/cpu-wall-copyback → main · +112 −8 · 2 files · 1 commits · open

Summary

Part of #2415 (CPU wall): deduplicates superseded full-overwrite texture readbacks within a completed flight and parallelizes mutually disjoint texback::land work across the existing victory-land thread pool.

Changes

  • crates/victory-gpu/src/texback.rs:
    • Changed TICKETS from Mutex to RwLock (write() in track / invalidate, read() in land) so concurrent land calls do not serialize on the ticket list while still excluding allocation invalidation.
    • Added keep_latest_full_overwrites, ranges_disjoint, and land_batch(backs: &[Back]) to drop earlier entries superseded by a later valid full-overwrite of the exact same (at, end) range and run mutually disjoint readbacks in parallel via crate::land::each.
    • Added unit tests keep_latest_full_overwrites_drops_superseded_duplicates and ranges_disjoint_detects_overlaps.
  • crates/victory-gpu/src/host.rs:
    • Split read_back_rows out of read_backs and batched texture_backs across flight.order in Late::Run via texback::land_batch, recycling them immediately afterward.

Verification

  • Unit tests: cargo test -p victory-gpu texback — 8 passed, 0 failed (including gpu_texback_and_read_backs_bit_exact_and_pool_benchmark and the 2 new unit tests), 0 new compiler warnings.
  • In-game (RTX 3050 8 GB, Series S, release build): Verified crash-free at ~7,137 draws/frame with ~42k landed texture readbacks (raw view clamp: [0, 0, 0, 0], binds dropped: 0.00/frame). Note: when a scene's readbacks are spread 1 per flight across separate Late::Run items, per-flight batching is a no-op; the win applies whenever a single flight or list accumulates >=2 texture readbacks.
**@⁠YounesAH15** on GitHub · 2026-12-01 01:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4682) `YounesAH15:perf/cpu-wall-copyback` → `main` · +112 −8 · 2 files · 1 commits · open ### Summary Part of #2415 (CPU wall): deduplicates superseded full-overwrite texture readbacks within a completed flight and parallelizes mutually disjoint `texback::land` work across the existing `victory-land` thread pool. ### Changes - **`crates/victory-gpu/src/texback.rs`**: - Changed `TICKETS` from `Mutex` to `RwLock` (`write()` in `track` / `invalidate`, `read()` in `land`) so concurrent `land` calls do not serialize on the ticket list while still excluding allocation invalidation. - Added `keep_latest_full_overwrites`, `ranges_disjoint`, and `land_batch(backs: &[Back])` to drop earlier entries superseded by a later valid full-overwrite of the exact same `(at, end)` range and run mutually disjoint readbacks in parallel via `crate::land::each`. - Added unit tests `keep_latest_full_overwrites_drops_superseded_duplicates` and `ranges_disjoint_detects_overlaps`. - **`crates/victory-gpu/src/host.rs`**: - Split `read_back_rows` out of `read_backs` and batched `texture_backs` across `flight.order` in `Late::Run` via `texback::land_batch`, recycling them immediately afterward. ### Verification - **Unit tests:** `cargo test -p victory-gpu texback` — **8 passed, 0 failed** (including `gpu_texback_and_read_backs_bit_exact_and_pool_benchmark` and the 2 new unit tests), 0 new compiler warnings. - **In-game (RTX 3050 8 GB, Series S, release build):** Verified crash-free at ~7,137 draws/frame with ~42k landed texture readbacks (`raw view clamp: [0, 0, 0, 0]`, `binds dropped: 0.00/frame`). Note: when a scene's readbacks are spread 1 per flight across separate `Late::Run` items, per-flight batching is a no-op; the win applies whenever a single flight or list accumulates >=2 texture readbacks.
`slots_showing` took the slot's `Made` key with `?`, but `Made` has keys
for the title's `count` slots only while `kept` also has the dynamic
ones: a host texture shown by a dynamic slot was no longer reported, so
it was no longer blocked and could be chosen (freeing nothing, as the
dynamic slot holds a reference, while the title made a second copy).
Those slots are reported again with key 0, as before the key was carried;
they are never put back to waiting, only counted as blocking. Test:
`a_dynamic_slot_showing_a_texture_still_blocks_its_eviction`.

`SLOT_LOOKING` is now cleared by a drop guard, so a look that panics does
not stop every later look.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b23c0c4038)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 01:47:01 +00:00
github-bot force-pushed github-bot/gh-4682 from 099ef02d93 to 2575e99c78 2026-12-01 07:53:34 +00:00 Compare
Author
Owner

@⁠tillo88 on GitHub · 2026-12-01 12:07 UTC · original

I queued this PR on my replay bench, but it does not merge on top of v2026.11.30.03, the latest release (merge conflict), so there are no numbers from it yet. I'll try again on the next release.

Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.

**@⁠tillo88** on GitHub · 2026-12-01 12:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4682#issuecomment-7310673617) I queued this PR on my replay bench, but it does not merge on top of v2026.11.30.03, the latest release (merge conflict), so there are no numbers from it yet. I'll try again on the next release. Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4682'
git switch 'github-bot/gh-4682'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4682'
git switch 'github-bot/gh-4682'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4682'
git switch 'main'
git merge --squash 'github-bot/gh-4682'
git switch 'main'
git merge --ff-only 'github-bot/gh-4682'
git switch 'main'
git merge 'github-bot/gh-4682'
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/trustno1-coder--VIctory-NVIDIA!4683
No description provided.