Skip to content

GPU: track expand_rects title reads and prioritize WHY_RUN in blocked_by (#168, #89) - #207

Open
AscilCH wants to merge 1 commit into
fxceless:mainfrom
AscilCH:fix/relay-host-read-and-run-precedence
Open

AscilCH wants to merge 1 commit into
fxceless:mainfrom
AscilCH:fix/relay-host-read-and-run-precedence

Conversation

@AscilCH

@AscilCH AscilCH commented Nov 24, 2026

Copy link
Copy Markdown

Problem

Related to #168 and #89; orthogonal to #191 (which covers aliased Step::Refresh, texture read_backs, and Late::Write).

Two remaining gaps in blocked_by under VICTORY_LATE_WAIT and VICTORY_RELAY=2:

  1. expand_rects CPU title-memory reads invisible to blocked_by (crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/host.rs):
    • expand_rects reads title vertex memory [from, from + n * 3 * stride) on the CPU at submission, but scheduled the closure with defer_host (Step::Host), which blocked_by ignores.
    • If an in-flight shader wrote that vertex buffer, VICTORY_LATE_WAIT / VICTORY_RELAY=2 could expand the stale title-memory bytes before copy-back landed.
  2. WHY_READ short-circuiting ahead of Step::Run (crates/victory-gpu/src/host.rs):
    • blocked_by returned Some(WHY_READ) on the first matching read step without scanning the remaining steps in runs for Step::Run(_).
    • Under VICTORY_RELAY=2, why == WHY_READ takes the selective relay_wait path (waiting only until line.written clears) instead of self.settle(..., WHY_RUN) (which settles all flights, including flights without shader writes, ahead of a Step::Run).

Fix

  • Add Step::HostRead(usize, usize, Box<dyn Fn() + Send>) and HostList::defer_host_read in crates/victory-gpu/src/host.rs.
  • Switch expand_rects in crates/victory-gpu/src/draw.rs from defer_host to defer_host_read(from as *const u8, n * 3 * stride, ...).
  • Update blocked_by / blocked_by_steps to check Step::HostRead against written and continue scanning for Step::Run(_) so WHY_RUN takes precedence over WHY_READ (without double-counting LATE_STATS).
  • Add host::relay_tests::blocked_by_steps_checks_host_read_and_prioritizes_run.

Verification

  • cargo test -p victory-gpu --locked -- --test-threads=1: 111 passed, 0 failed
  • cargo xtask policy: 169 files ok
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean
  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean

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

…_by (fxceless#168, fxceless#89)

Two synchronization gaps in `blocked_by` under `VICTORY_LATE_WAIT` and
`VICTORY_RELAY=2` (orthogonal to fxceless#191):

1. `expand_rects` (`crates/victory-gpu/src/draw.rs`) reads title vertex memory
   `[from, from + n * 3 * stride)` on the CPU at submission, but deferred the
   step with `HostList::defer_host` (`Step::Host`), which `blocked_by` ignores.
   Under `VICTORY_LATE_WAIT`/`VICTORY_RELAY`, a rect draw reading vertices
   produced by an in-flight shader could run before the copy-back landed.
2. `blocked_by` (`crates/victory-gpu/src/host.rs`) returned `Some(WHY_READ)` on
   the first matching copy/fill/texture step without scanning later steps for
   `Step::Run(_)`. Under `VICTORY_RELAY=2`, `WHY_READ` waits only until
   `blocked_by` clears rather than settling all flights, whereas `Step::Run(_)`
   requires a full `WHY_RUN` settle.

Add `Step::HostRead` / `HostList::defer_host_read`, switch `expand_rects` to
use it, and scan all steps in `blocked_by` so `WHY_RUN` takes precedence over
an earlier `WHY_READ`. Add
`host::relay_tests::blocked_by_steps_checks_host_read_and_prioritizes_run`.
VlREX added a commit to VlREX/victory-fork that referenced this pull request Nov 25, 2026
…B testing

Original contributions: gdawid9407 (fxceless#191) and AscilCH (fxceless#206, fxceless#207).
Preserve credits and source commits in docs/virex-world-geometry-recovery.md.
Resolve overlapping host hazard checks without changing upstream PRs.
Native validation pending; AI-assisted integration.
VlREX added a commit to VlREX/victory-fork that referenced this pull request Nov 25, 2026
[Integration test only] World Geometry Recovery: combine fxceless#191, fxceless#206, fxceless#207
RecompLive pushed a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
…-local

Media: a share is refused however it is spelled
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
…-local

Media: a share is refused however it is spelled
(cherry picked from commit 5d1fbac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant