Skip to content

GPU: include uncopied pages in Shadow stale/merge under pending writes (#168, #89) - #206

Open
AscilCH wants to merge 1 commit into
fxceless:mainfrom
AscilCH:fix/shadow-uncopied-pages-under-writes
Open

AscilCH wants to merge 1 commit into
fxceless:mainfrom
AscilCH:fix/shadow-uncopied-pages-under-writes

Conversation

@AscilCH

@AscilCH AscilCH commented Nov 24, 2026

Copy link
Copy Markdown

Problem

Related to #168 (VICTORY_LATE_WAIT=3 / VICTORY_RELAY=2 missing geometry) and #89 (VICTORY_RELAY=2 artifacts). Complementary to #191 (which only touches host.rs).

In crates/victory-gpu/src/shadow.rs:

  • Shadow::copy_stale (default synchronous path) scans every page in [from, to) and copies any page where copied[page - base] == 0 || write > copied[page - base].
  • Shadow::stale_under_writes and Shadow::merge_under_writes (used under VICTORY_LATE_WAIT and VICTORY_RELAY) only iterated the write-watch delta written. Any page inside an in-flight GpuWrite range that had never been copied yet (copied == 0) and did not appear in written was silently skipped, leaving those bytes zeroed in the host copy while Shadow::update also skipped the pending range.

Fix

  • Extract stale_pages_in(base, copied, a, e, written) in crates/victory-gpu/src/shadow.rs to scan every page in a / PAGE..=(e - 1) / PAGE and return pages with copied == 0 || write > copied, matching copy_stale.
  • Use stale_pages_in in both Shadow::stale_under_writes and Shadow::merge_under_writes.
  • Add shadow::relay_tests::stale_pages_include_uncopied_pages_absent_from_write_watch.

Verification

  • rustfmt --edition 2024 --check crates/victory-gpu/src/shadow.rs (changed hunks): clean
  • 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.)

fxceless#168, fxceless#89)

Under `VICTORY_LATE_WAIT` and `VICTORY_RELAY`, `Shadow::stale_under_writes`
and `Shadow::merge_under_writes` (`crates/victory-gpu/src/shadow.rs`) only
iterated pages returned by the write-watch delta (`written`). Any page inside
a pending shader `GpuWrite` range whose `copied` timestamp was still `0`
(never copied into the host copy yet) and that did not appear in `written`
was silently skipped, leaving it zeroed on the GPU while `Shadow::update`
also skipped the pending range.

Mirror `Shadow::copy_stale` by extracting `stale_pages_in` and scanning every
page in `[a, e)` for `copied == 0 || write > copied` in both
`stale_under_writes` and `merge_under_writes`. Add
`shadow::relay_tests::stale_pages_include_uncopied_pages_absent_from_write_watch`.
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
oz-stanislav-zhukov added a commit to oz-stanislav-zhukov/victory-fork that referenced this pull request Nov 25, 2026
…ess#206 reverted)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
triippywhale pushed a commit to triippywhale/victory-fork that referenced this pull request Nov 25, 2026
Shadow::stale_under_writes and Shadow::merge_under_writes looked only at
the write-watch journal, so a page of a range shaders may be writing that
the copy never took, and the title had not written lately, was neither
merged nor a reason to settle the flights in the air. The refresh leaves
such ranges alone, and shaders read zeros there (missing geometry with
VICTORY_LATE_WAIT / VICTORY_RELAY). Both now decide by page as
Shadow::copy_stale does: never taken, or written after it was taken.

Ported from fxceless#206.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017V7WBDcuSkQXqyyY47pR31
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