GPU: rectangle vertices are read from title memory through the kernel at submission #2294

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2296 into main
denkencar-sketch commented 2026-11-25 10:05:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:26Z.


Summary

Rectangle vertices were read from title memory with a raw slice at submission. The title may unmap the vertex buffer between the draw and the submission, and the slice then faulted. They are now read through the kernel and rectangles of unmapped vertices are skipped. The allocation is bounded by the earlier shadow::find.

Testing

Test rectangles_of_unmapped_vertices_are_skipped crashes (0xc0000005) with the old raw slice and passes with this change. cargo test --workspace --locked passes apart from 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. Known nits: a failed read leaves stale scratch, and a Vec is made per draw.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601982176 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2296). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:05:26Z. --- ## Summary Rectangle vertices were read from title memory with a raw slice at submission. The title may unmap the vertex buffer between the draw and the submission, and the slice then faulted. They are now read through the kernel and rectangles of unmapped vertices are skipped. The allocation is bounded by the earlier `shadow::find`. ## Testing Test `rectangles_of_unmapped_vertices_are_skipped` crashes (`0xc0000005`) with the old raw slice and passes with this change. `cargo test --workspace --locked` passes apart from 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. Known nits: a failed read leaves stale scratch, and a `Vec` is made per draw. AI-assisted.
catminou4 commented 2026-11-25 11:04:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:13Z.

Review: COMMENTED


Rectangle vertices read from title memory through the copy (expand_title_rects). 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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055712684 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2296#pullrequestreview-6055712684). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:13Z. **Review:** COMMENTED --- Rectangle vertices read from title memory through the copy (expand_title_rects). 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.
DenRakEiw commented 2026-11-25 15:03:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:56:50Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Reading rectangle vertices from title memory through the kernel at submission and skipping unmapped ranges passes all draw tests cleanly.
  • cargo test -p victory-gpu draw::tests: 6/6 passed on RTX 5090, 6/6 passed on WARP (including rectangles_of_unmapped_vertices_are_skipped).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6059984064 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2296#pullrequestreview-6059984064). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T14:56:50Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Reading rectangle vertices from title memory through the kernel at submission and skipping unmapped ranges passes all draw tests cleanly. - `cargo test -p victory-gpu draw::tests`: 6/6 passed on RTX 5090, 6/6 passed on WARP (including `rectangles_of_unmapped_vertices_are_skipped`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-25 15:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T14:53:44Z.


Automated triage for the maintainers.

Thanks for the rebase. Reviewed at e3e9124, which merges cleanly. CI: passing.

In crates/victory-gpu/src/draw.rs, State::rectangles used to read the title's vertices with a raw slice in its deferred closure. It now calls the new expand_title_rects, which copies them through host::read_into (ReadProcessMemory) first. A vertex buffer the title unmapped before submission therefore skips the expansion instead of faulting. The size is still bounded by the shadow::find and buffer-size checks made at record time. The new test protects a page with PAGE_NOACCESS to exercise the failing path.

One optional improvement, which you already list as a known nit: on a failed read the scratch keeps whatever it held before, possibly an earlier list's vertices. Zeroing dst would turn those rectangles into degenerate triangles rather than stale geometry.

Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165982712 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2296#issuecomment-7165982712). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T14:53:44Z. --- <!-- victory-triage v1 head=e3e9124d59a5e55a7e384490ed52a5d9d94bff4a verdict=merge-candidate at=2026-11-26T03:20:14Z --> Automated triage for the maintainers. Thanks for the rebase. Reviewed at `e3e9124`, which merges cleanly. CI: passing. In `crates/victory-gpu/src/draw.rs`, `State::rectangles` used to read the title's vertices with a raw slice in its deferred closure. It now calls the new `expand_title_rects`, which copies them through `host::read_into` (`ReadProcessMemory`) first. A vertex buffer the title unmapped before submission therefore skips the expansion instead of faulting. The size is still bounded by the `shadow::find` and buffer-size checks made at record time. The new test protects a page with `PAGE_NOACCESS` to exercise the failing path. One optional improvement, which you already list as a known nit: on a failed read the scratch keeps whatever it held before, possibly an earlier list's vertices. Zeroing `dst` would turn those rectangles into degenerate triangles rather than stale geometry. **Verdict: merge candidate** (a recommendation to look, not an approval). CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 16:04:24 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed crates/victory-gpu/src/draw.rs at e3e9124d merged onto origin/main (63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.

Safety & bounds audit

  • State::rectangles (draw.rs:1636) now delegates submission-time expansion to expand_title_rects (draw.rs:2023), copying n * 3 * stride bytes through crate::host::read_into (ReadProcessMemory) and returning early if the title unmapped the vertex pages between record and submission instead of faulting on a raw slice dereference.
  • Record-time checks (stride > 0, u64::from(first + count) * stride <= u64::from(v.size), shadow::find(from, rects * 3 * stride), and list.scratch(rects * 6 * stride)) bound both the temporary buffer and scratch slice sizes cleanly.

Verification

  • cargo run -p xtask -- policy: 191 files ok.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
  • draw:: with VICTORY_D3D12_DEBUG=1: 21/21 passed on RTX 5090 and 21/21 passed on WARP (--features diagnostics), including rectangles_of_unmapped_vertices_are_skipped (draw.rs:2058).
<!-- greyfinch-sync:Marvisak/VIctory:review:6076684782 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2296#pullrequestreview-6076684782). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T15:22:44Z. **Review:** APPROVED --- Reviewed `crates/victory-gpu/src/draw.rs` at `e3e9124d` merged onto `origin/main` (`63bcca43`) and verified on RTX 5090 and WARP (`VICTORY_D3D12_WARP=1`) with `VICTORY_D3D12_DEBUG=1`. ### Safety & bounds audit - `State::rectangles` (`draw.rs:1636`) now delegates submission-time expansion to `expand_title_rects` (`draw.rs:2023`), copying `n * 3 * stride` bytes through `crate::host::read_into` (`ReadProcessMemory`) and returning early if the title unmapped the vertex pages between record and submission instead of faulting on a raw slice dereference. - Record-time checks (`stride > 0`, `u64::from(first + count) * stride <= u64::from(v.size)`, `shadow::find(from, rects * 3 * stride)`, and `list.scratch(rects * 6 * stride)`) bound both the temporary buffer and scratch slice sizes cleanly. ### Verification - `cargo run -p xtask -- policy`: 191 files ok. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - `draw::` with `VICTORY_D3D12_DEBUG=1`: **21/21 passed** on RTX 5090 and **21/21 passed** on WARP (`--features diagnostics`), including `rectangles_of_unmapped_vertices_are_skipped` (`draw.rs:2058`).
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/2296:upstream-pr/2296'
git switch 'upstream-pr/2296'

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/2296'
git switch 'upstream-pr/2296'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2296'
git switch 'upstream-pr/2296'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2296'
git switch 'main'
git merge --squash 'upstream-pr/2296'
git switch 'main'
git merge --ff-only 'upstream-pr/2296'
git switch 'main'
git merge 'upstream-pr/2296'
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!2294
No description provided.