GPU: marks in the last dword of the written-pages bitmap are not discarded #2269

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

@⁠denkencar-sketch on GitHub · 2026-11-25 09:28 UTC · original
denkencar-sketch:fix/shadow-001 → main · +33 −11 · 1 files · 1 commits · open

Summary

The written-pages bitmap's last dword took the marks of offsets past it by clearing the whole dword, which dropped the writes to the 31 pages before its last bit. Only the last bit is cleared now.

Testing

Test marks_in_the_last_dword_are_read_but_the_sink_bit_is_not fails with the old clearing (= 0) and passes with this change. cargo test --workspace --locked passes apart from the known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a run in the game.

AI-assisted.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 09:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2269) `denkencar-sketch:fix/shadow-001` → `main` · +33 −11 · 1 files · 1 commits · open ## Summary The written-pages bitmap's last dword took the marks of offsets past it by clearing the whole dword, which dropped the writes to the 31 pages before its last bit. Only the last bit is cleared now. ## Testing Test `marks_in_the_last_dword_are_read_but_the_sink_bit_is_not` fails with the old clearing (`= 0`) and passes with this change. `cargo test --workspace --locked` passes apart from the known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a run in the game. AI-assisted.
Only its last bit takes the marks of offsets past it; clearing the whole
dword dropped the writes to the 31 pages before it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:00:27 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:42 UTC · original · edited 2026-11-26 01:25 UTC

Automated triage for the maintainers.

Merge candidate. Rebased cleanly. copy_back_marks in crates/victory-gpu/src/shadow.rs used to zero the whole last dword of the written-pages bitmap, but only its top bit is the sink (lower.rs caps the mark index at VIEW_WRITE_BITS - 1), while the mark allocator hands out bits up to VIEW_WRITE_BITS - 2. So the 31 bits before the sink can belong to copies, and their writes were dropped. The new drain_marks clears only the sink bit, and marks_in_the_last_dword_are_read_but_the_sink_bit_is_not checks exactly that. It only matters once the mark space is almost full, but the fix is right and small.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2269#issuecomment-7162741237) · edited 2026-11-26 01:25 UTC <!-- victory-triage v1 head=356929dd893386ee753bb0ff9c9e36ab3e3ccb37 verdict=merge-candidate at=2026-11-26T01:25:08Z --> Automated triage for the maintainers. **Merge candidate.** Rebased cleanly. `copy_back_marks` in `crates/victory-gpu/src/shadow.rs` used to zero the whole last dword of the written-pages bitmap, but only its top bit is the sink (`lower.rs` caps the mark index at `VIEW_WRITE_BITS - 1`), while the mark allocator hands out bits up to `VIEW_WRITE_BITS - 2`. So the 31 bits before the sink can belong to copies, and their writes were dropped. The new `drain_marks` clears only the sink bit, and `marks_in_the_last_dword_are_read_but_the_sink_bit_is_not` checks exactly that. It only matters once the mark space is almost full, but the fix is right and small. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 09:35 UTC · original · reviewed

Refactors copy_back_marks bitmap draining into drain_marks (clears bit 31 of the last word, returns marked offsets) with the same last-word fix as #2267 plus coverage. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Cleaner than #2267 and supersedes it; check the merge order.

**@⁠catminou4** on GitHub · 2026-11-25 09:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2269#pullrequestreview-6055074080) · **reviewed** Refactors copy_back_marks bitmap draining into drain_marks (clears bit 31 of the last word, returns marked offsets) with the same last-word fix as #2267 plus coverage. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Cleaner than #2267 and supersedes it; check the merge order.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 15:54 UTC · original · approved these changes

Reviewed 356929dd893386ee753bb0ff9c9e36ab3e3ccb37 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer.

Audit

  • crates/victory-gpu/src/shadow.rs:894, :896, :930: Marks::take allocates bit runs strictly below VIEW_WRITE_BITS (1 << 22), reserving only bit VIEW_WRITE_BITS - 1 (bit 31 of the final dword) as the out-of-range sink. Replacing bits[words - 1] = 0 with *last &= !(1 << 31) in drain_marks preserves all 31 valid copy bits (0..=30) in the final dword while still clearing the sink bit even when end == 0.

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features)
  • victory-gpu shadow:: with VICTORY_D3D12_DEBUG=1: 11/11 passed on RTX 5090; 11/11 passed (--features diagnostics) on WARP (including marks_in_the_last_dword_are_read_but_the_sink_bit_is_not).
  • Also verified an edge-case probe on drain_marks covering empty slices, end == 0 (sink cleared), single-word bitmaps, end == 32 / end == 33, and full VIEW_WRITE_BITS - 1 with all 32 bits set in the final dword.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 15:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2269#pullrequestreview-6077100741) · **approved these changes** Reviewed `356929dd893386ee753bb0ff9c9e36ab3e3ccb37` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer. ### Audit - `crates/victory-gpu/src/shadow.rs:894`, `:896`, `:930`: `Marks::take` allocates bit runs strictly below `VIEW_WRITE_BITS` (`1 << 22`), reserving only bit `VIEW_WRITE_BITS - 1` (bit 31 of the final dword) as the out-of-range sink. Replacing `bits[words - 1] = 0` with `*last &= !(1 << 31)` in `drain_marks` preserves all 31 valid copy bits (`0..=30`) in the final dword while still clearing the sink bit even when `end == 0`. ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default & `--all-features`) - `victory-gpu` `shadow::` with `VICTORY_D3D12_DEBUG=1`: **11/11 passed** on RTX 5090; **11/11 passed** (`--features diagnostics`) on WARP (including `marks_in_the_last_dword_are_read_but_the_sink_bit_is_not`). - Also verified an edge-case probe on `drain_marks` covering empty slices, `end == 0` (sink cleared), single-word bitmaps, `end == 32` / `end == 33`, and full `VIEW_WRITE_BITS - 1` with all 32 bits set in the final dword.
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/2269/head:github-bot/gh-2269'
git switch 'github-bot/gh-2269'

Merge

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