GPU: wait for in-flight writes from aliased copies, read-backs and late writes (#89) #191

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

@⁠gdawid9407 on GitHub · 2026-11-24 22:22 UTC · original
gdawid9407:fix/relay-exact-aliased-reads → main · +198 −27 · 1 files · 1 commits · open

Problem

Under VICTORY_RELAY=2 (relay_exact), submit only waits on WHY_READ until blocked_by clears for the current submission's CPU-side reads:

  1. blocked_by ignored Step::Refresh(shadow, address, len). Refreshing the same Shadow that declared an in-flight GpuWrite needs no wait (its GPU buffer receives the write in queue order and Shadow::update skips pending), but refreshing a different Shadow covering overlapping title addresses (e.g. a 4 MiB loose window vs an 8 MiB window, or a sub-buffer vs an enclosing heap buffer) reads title CPU memory before the writing flight's copy-back has landed — matching the missing skinned meshes and overlapping subtitle vertices reported with VICTORY_RELAY=2 in #89.
  2. Title-memory ranges written on landing by texture read_backs (deferred().backs) and Late::Write items (in_hand / line) were not checked by blocked_by (while keeping Late::Write out of line.written so late_met still evaluates known Written::Value writes without unnecessary settles).

Changes

  • Track per-owner in-flight ranges (by_copy, keyed by Shadow pointer or 0 for texture read-backs) alongside written, plus Line::immed_writes for pending/landing Late::Write ranges.
  • Block Step::Refresh in blocked_by iff the refreshed range overlaps an in-flight write from a different Shadow copy, a texture read-back, or a Late::Write (counted in LATE_STATS as another copy).
  • Add relay_tests::refreshes_wait_only_for_writes_from_another_copy_or_readback.
**@⁠gdawid9407** on GitHub · 2026-11-24 22:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/191) `gdawid9407:fix/relay-exact-aliased-reads` → `main` · +198 −27 · 1 files · 1 commits · open ### Problem Under `VICTORY_RELAY=2` (`relay_exact`), `submit` only waits on `WHY_READ` until `blocked_by` clears for the current submission's CPU-side reads: 1. `blocked_by` ignored `Step::Refresh(shadow, address, len)`. Refreshing the *same* `Shadow` that declared an in-flight `GpuWrite` needs no wait (its GPU buffer receives the write in queue order and `Shadow::update` skips `pending`), but refreshing a *different* `Shadow` covering overlapping title addresses (e.g. a 4 MiB loose window vs an 8 MiB window, or a sub-buffer vs an enclosing heap buffer) reads title CPU memory before the writing flight's copy-back has landed — matching the missing skinned meshes and overlapping subtitle vertices reported with `VICTORY_RELAY=2` in #89. 2. Title-memory ranges written on landing by texture `read_backs` (`deferred().backs`) and `Late::Write` items (`in_hand` / `line`) were not checked by `blocked_by` (while keeping `Late::Write` out of `line.written` so `late_met` still evaluates known `Written::Value` writes without unnecessary settles). ### Changes - Track per-owner in-flight ranges (`by_copy`, keyed by `Shadow` pointer or `0` for texture read-backs) alongside `written`, plus `Line::immed_writes` for pending/landing `Late::Write` ranges. - Block `Step::Refresh` in `blocked_by` iff the refreshed range overlaps an in-flight write from a *different* `Shadow` copy, a texture read-back, or a `Late::Write` (counted in `LATE_STATS` as `another copy`). - Add `relay_tests::refreshes_wait_only_for_writes_from_another_copy_or_readback`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:54 +00:00
Author
Owner

@⁠Pin0d1 on GitHub · 2026-11-25 04:12 UTC · original

I checked two ordering cases on 1582757.

  • Queue stores of 1 and then 0 to the same eight bytes, followed by an equality wait for 1. The prediction returned true and the submission retained zero waits. In this ordering the last store before the wait is 0, so I expected false and one retained wait. The result repeated in two fresh processes.
  • Map the second 64 KiB page of one view at the start of a sibling view. A pending four-byte write overlaps two bytes of the recorded read through the sibling. The dependency check returned no wait for this overlap. Adjacent, disjoint and removed-mapping controls also returned no wait.

The replay cases are pr191 and pr191-physical. I included separate candidate patches for the last covering store and for comparing exact byte ranges through the mapping index in #555. Probes and transcripts · Patches and prerequisites

Prepared with the help of Codex 6.2 Astra Max.

**@⁠Pin0d1** on GitHub · 2026-11-25 04:12 UTC · [original](https://github.com/fxceless/victory-fork/pull/191#issuecomment-7152634435) I checked two ordering cases on `1582757`. * Queue stores of 1 and then 0 to the same eight bytes, followed by an equality wait for 1. The prediction returned true and the submission retained zero waits. In this ordering the last store before the wait is 0, so I expected false and one retained wait. The result repeated in two fresh processes. * Map the second 64 KiB page of one view at the start of a sibling view. A pending four-byte write overlaps two bytes of the recorded read through the sibling. The dependency check returned no wait for this overlap. Adjacent, disjoint and removed-mapping controls also returned no wait. The replay cases are `pr191` and `pr191-physical`. I included separate candidate patches for the last covering store and for comparing exact byte ranges through the mapping index in #555. [Probes and transcripts](https://github.com/Pin0d1/victory-fork/tree/73f564e92ca86fe07be7c53492ee0e23a2471fa9/review-evidence) · [Patches and prerequisites](https://github.com/Pin0d1/victory-fork/blob/73f564e92ca86fe07be7c53492ee0e23a2471fa9/review-evidence/candidates/README.md) Prepared with the help of Codex 6.2 Astra Max.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.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/191/head:github-bot/gh-191'
git switch 'github-bot/gh-191'

Merge

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