Fix bitmap mark clearing in copy_back_marks #2265

Closed
Kholoso wants to merge 1 commit from upstream-pr/2267 into main
Kholoso commented 2026-11-25 09:24:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Kholoso on 2026-11-25T09:24:16Z.


## Problem

In copy_back_marks, the last bitmap word is currently cleared entirely:

bits[words - 1] = 0;

However, the last bit is reserved as an overflow sentinel, while the preceding 31 bits may still contain valid marks.

Clearing the entire word could discard valid GPU write marks, preventing the corresponding memory from being copied back.

## Proposed fix

Clear only the overflow sentinel bit while preserving the remaining bits:

bits[words - 1] &= !(1u32 << 31);

## Testing

Not tested yet. This change is based on code inspection and should be validated with a test covering valid marks in the last bitmap word.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601273493 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2267). Originally posted by [Kholoso](https://github.com/Kholoso) on 2026-11-25T09:24:16Z. --- **## Problem** In `copy_back_marks`, the last bitmap word is currently cleared entirely: ```rust bits[words - 1] = 0; ``` However, the last bit is reserved as an overflow sentinel, while the preceding 31 bits may still contain valid marks. Clearing the entire word could discard valid GPU write marks, preventing the corresponding memory from being copied back. **## Proposed fix** Clear only the overflow sentinel bit while preserving the remaining bits: ```rust bits[words - 1] &= !(1u32 << 31); ``` **## Testing** Not tested yet. This change is based on code inspection and should be validated with a test covering valid marks in the last bitmap word.
catminou4 commented 2026-11-25 10:07:15 +00:00 (Migrated from github.com)

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

Review: COMMENTED


One-line fix: copy_back_marks no longer zeroes the whole last bitmap word, only bit 31 (marks past the bitmap land there, no copy owns it). 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. Correct minimal fix — but #2269 refactors the same code into drain_marks with the same correction plus tests; whichever lands second should reconcile (likely #2269 supersedes this).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055073851 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2267#pullrequestreview-6055073851). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:37Z. **Review:** COMMENTED --- One-line fix: copy_back_marks no longer zeroes the whole last bitmap word, only bit 31 (marks past the bitmap land there, no copy owns it). 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. Correct minimal fix — but #2269 refactors the same code into drain_marks with the same correction plus tests; whichever lands second should reconcile (likely #2269 supersedes this).
welisonzika14-jpg commented 2026-11-25 12:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T12:00:07Z.


First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head 9ad90fa merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

The PR adds no test, so this only shows it breaks nothing here. The rest is the same as main on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in victory-gpu, 3 in victory-shader), nothing new.

One run, unit tests only, title not run.

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161787203 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2267#issuecomment-7161787203). Originally posted by [welisonzika14-jpg](https://github.com/welisonzika14-jpg) on 2026-11-25T12:00:07Z. --- First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head `9ad90fa` merged onto `main` `940d32f`, `cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast`. The PR adds no test, so this only shows it breaks nothing here. The rest is the same as `main` on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in `victory-gpu`, 3 in `victory-shader`), nothing new. One run, unit tests only, title not run. Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
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:26Z.


Automated triage for the maintainers.

Proposed close: duplicate of #2269. Both PRs make the same fix in copy_back_marks (crates/victory-gpu/src/shadow.rs): clear only the sink bit 31 of the bitmap's last dword, not the whole dword. The fix is right. #2269 also factors the drain into drain_marks and adds a test for the last-dword case (marks_in_the_last_dword_are_read_but_the_sink_bit_is_not). Both merge cleanly. #2269 is marked as a merge candidate.

This PR will be closed in 48 hours unless you push a change or a maintainer removes the triage: proposed close label. Thanks for finding it.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162743384 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2267#issuecomment-7162743384). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T12:42:26Z. --- <!-- victory-triage v1 head=9ad90fac80f786e6eba9e7bddd2fd4e7e0d80522 verdict=proposed-close at=2026-11-25T12:44:00Z --> Automated triage for the maintainers. **Proposed close: duplicate of #2269.** Both PRs make the same fix in `copy_back_marks` (`crates/victory-gpu/src/shadow.rs`): clear only the sink bit 31 of the bitmap's last dword, not the whole dword. The fix is right. #2269 also factors the drain into `drain_marks` and adds a test for the last-dword case (`marks_in_the_last_dword_are_read_but_the_sink_bit_is_not`). Both merge cleanly. #2269 is marked as a merge candidate. This PR will be closed in 48 hours unless you push a change or a maintainer removes the `triage: proposed close` label. Thanks for finding it. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 14:06:18 +00:00
Kholoso commented 2026-11-25 14:07:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Kholoso on 2026-11-25T13:16:31Z.


Thanks for the review! I agree that #2269 supersedes this PR. Closing this one to avoid duplicate work.
Glad the fix was useful!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163540258 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2267#issuecomment-7163540258). Originally posted by [Kholoso](https://github.com/Kholoso) on 2026-11-25T13:16:31Z. --- Thanks for the review! I agree that #2269 supersedes this PR. Closing this one to avoid duplicate work. Glad the fix was useful!

Pull request closed

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!2265
No description provided.