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

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2269 into main
denkencar-sketch commented 2026-11-25 09:28:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T09:28:51Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5488654106 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2269). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T09:28:51Z. --- ## 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.
catminou4 commented 2026-11-25 09:35:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:35:38Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055074080 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2269#pullrequestreview-6055074080). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:38Z. **Review:** COMMENTED --- 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.
Marvisak commented 2026-11-25 13:02:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:42:20Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162741237 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2269#issuecomment-7162741237). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T12:42:20Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-26 15:54:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T15:54:36Z.

Review: APPROVED


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.
<!-- greyfinch-sync:Marvisak/VIctory:review:6077100741 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2269#pullrequestreview-6077100741). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T15:54:36Z. **Review:** APPROVED --- 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.
Dukestar69 commented 2026-11-26 22:11:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:11:29Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Keeping marks in the final dword of the written-pages bitmap ensures boundary page writes are not dropped.
  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081021129 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2269#pullrequestreview-6081021129). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:11:29Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Keeping marks in the final dword of the written-pages bitmap ensures boundary page writes are not dropped. - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2269:upstream-pr/2269'
git switch 'upstream-pr/2269'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2269'
git switch 'upstream-pr/2269'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2269'
git switch 'upstream-pr/2269'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2269'
git switch 'main'
git merge --squash 'upstream-pr/2269'
git switch 'main'
git merge --ff-only 'upstream-pr/2269'
git switch 'main'
git merge 'upstream-pr/2269'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2267
No description provided.