GPU/host: stop CardInflight::brought from pinning Arc<Shadow> buffers after fallback fetches #805

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

@⁠AscilCH on GitHub · 2026-11-25 08:19 UTC · original
AscilCH:fix/gpu-host-card-inflight-brought-leak → main · +28 −1 · 1 files · 1 commits · open

Summary

Fix two CardInflight::brought retention bugs introduced in 9376fd6 (crates/victory-gpu/src/host.rs):

  1. Skip recording stale brought entries when no later flight is in the air.

    • In Host::relay_card_back(), inflight_tickets_landed(plans) pruned inflight.brought before the fallback fetch ran, after which every fetched piece was unconditionally appended with (shadow.clone(), lo, hi, after - 1) whenever after > 1—even when after - 1 <= max(plan.sent_as) so no later flight could ever match b.3 >= sent_as.
    • Guard inflight.brought.extend(...) with should_record_brought(after, landed) (after > 1 && landed.is_none_or(|last| after - 1 > last)).
  2. Clear inflight.brought in Host::card_done() when all plans have landed.

    • When work.out == 0 (or !relay()), reset inflight.brought.clear() alongside work.taken = 0 so no Arc<Shadow> card/staging buffers remain pinned after all in-flight plans finish.

Verification

  • cargo test -p victory-gpu --locked -- host::batch: 5 passed; 0 failed; 1 ignored (benchmark), including new should_record_brought_only_when_later_flights_exist.
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in crates/victory-gpu/src/host.rs (only pre-existing 9376fd6 warnings in draw.rs and indirect.rs).
  • cargo xtask policy: 171 files ok.

(AI-assisted; synthetic unit tests only, no game data.)

**@⁠AscilCH** on GitHub · 2026-11-25 08:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/805) `AscilCH:fix/gpu-host-card-inflight-brought-leak` → `main` · +28 −1 · 1 files · 1 commits · open ## Summary Fix two `CardInflight::brought` retention bugs introduced in `9376fd6` (`crates/victory-gpu/src/host.rs`): 1. **Skip recording stale `brought` entries when no later flight is in the air.** - In `Host::relay_card_back()`, `inflight_tickets_landed(plans)` pruned `inflight.brought` before the fallback fetch ran, after which every fetched piece was unconditionally appended with `(shadow.clone(), lo, hi, after - 1)` whenever `after > 1`—even when `after - 1 <= max(plan.sent_as)` so no later flight could ever match `b.3 >= sent_as`. - Guard `inflight.brought.extend(...)` with `should_record_brought(after, landed)` (`after > 1 && landed.is_none_or(|last| after - 1 > last)`). 2. **Clear `inflight.brought` in `Host::card_done()` when all plans have landed.** - When `work.out == 0` (or `!relay()`), reset `inflight.brought.clear()` alongside `work.taken = 0` so no `Arc<Shadow>` card/staging buffers remain pinned after all in-flight plans finish. ## Verification - `cargo test -p victory-gpu --locked -- host::batch`: `5 passed; 0 failed; 1 ignored` (benchmark), including new `should_record_brought_only_when_later_flights_exist`. - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: 0 warnings in `crates/victory-gpu/src/host.rs` (only pre-existing `9376fd6` warnings in `draw.rs` and `indirect.rs`). - `cargo xtask policy`: `171 files ok`. *(AI-assisted; synthetic unit tests only, no game data.)*
In `Host::relay_card_back()` (`crates/victory-gpu/src/host.rs`), when
`relay_card_inflight(plans)` returned `false` and fell back to the old fetch:

1. `inflight_tickets_landed(plans)` pruned `inflight.brought` BEFORE the
   fallback fetch ran, and then `relay_card_back()` unconditionally pushed
   `(shadow.clone(), lo, hi, after - 1)` for every fetched piece whenever
   `after > 1`—even when `after - 1 <= landed` (no later flight in the air can
   ever match `b.3 >= sent_as`).
2. `Host::card_done()` reset `work.taken = 0` when `work.out == 0` (no
   `CardPlan`s left in flight) without clearing `inflight.brought`, leaving
   stale `Arc<Shadow>` clones pinned across `settle()`/`let_go_idle()` until a
   future `CardPlan` landed.

Guard `inflight.brought.extend(...)` with `should_record_brought(after, landed)`
(`after > 1 && landed.is_none_or(|last| after - 1 > last)`), clear
`inflight.brought` in `card_done()` when `!relay() || work.out == 0`, and add
`host::batch::should_record_brought_only_when_later_flights_exist`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:31 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 09:54 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 6bf3929 into main 9376fd6 in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails, with the same two errors as main itself on this machine (function placed_filler_twins is never used, field depth_written is never read, victory-gpu): this PR adds none and removes none. cargo test --workspace --locked: 541 passed, 0 failed, 10 ignored, two runs (main alone: 540 passed). 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 09:54 UTC · [original](https://github.com/fxceless/victory-fork/pull/805#issuecomment-7158953442) 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 `6bf3929` into `main` `9376fd6` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails, with the same two errors as `main` itself on this machine (`function placed_filler_twins is never used`, `field depth_written is never read`, `victory-gpu`): this PR adds none and removes none. `cargo test --workspace --locked`: 541 passed, 0 failed, 10 ignored, two runs (`main` alone: 540 passed). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
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/805/head:github-bot/gh-805'
git switch 'github-bot/gh-805'

Merge

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