GPU: read small buffer diagnostics via read_into instead of VirtualQuery #2140

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2142 into main
fuzeofficlal commented 2026-11-25 05:55:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:55:31Z.


Problem

While 6d021fe switched describe()'s View::Constant path to host::read_into, the small closure added right above it in 7000573 (crates/victory-gpu/src/draw.rs) still queries texture::committed (VirtualQuery) and constructs std::slice::from_raw_parts over live title memory for <= 64-byte buffer SRV and UAV views. That walks pool regions on every noted draw/dispatch, leaves a TOCTOU window against concurrent unmapping or page-guard changes, and passes (null, 0) to from_raw_parts when at == 0 && len == 0.

Changes

  • Read 4..=64-byte buffer SRV/UAV spans into a 64-byte stack buffer via crate::host::read_into (omitting empty and sub-dword < 4-byte spans), eliminating VirtualQuery and unsafe slice construction.
  • Add draw::tests::describe_reads_small_buffers_without_faulting_on_unmapped_memory under diagnostics covering unaligned SRV/UAV float formatting, boundary lengths (0, 2, 6, 64, 68), and reserved/unmapped page boundaries.

Closes #913.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6598219423 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2142). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T05:55:31Z. --- ### Problem While `6d021fe` switched `describe()`'s `View::Constant` path to `host::read_into`, the `small` closure added right above it in `7000573` (`crates/victory-gpu/src/draw.rs`) still queries `texture::committed` (`VirtualQuery`) and constructs `std::slice::from_raw_parts` over live title memory for `<= 64`-byte buffer SRV and UAV views. That walks pool regions on every noted draw/dispatch, leaves a TOCTOU window against concurrent unmapping or page-guard changes, and passes `(null, 0)` to `from_raw_parts` when `at == 0 && len == 0`. ### Changes - Read `4..=64`-byte buffer SRV/UAV spans into a 64-byte stack buffer via `crate::host::read_into` (omitting empty and sub-dword `< 4`-byte spans), eliminating `VirtualQuery` and `unsafe` slice construction. - Add `draw::tests::describe_reads_small_buffers_without_faulting_on_unmapped_memory` under `diagnostics` covering unaligned SRV/UAV float formatting, boundary lengths (`0`, `2`, `6`, `64`, `68`), and reserved/unmapped page boundaries. Closes #913.
DenRakEiw commented 2026-11-25 07:02:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T06:02:46Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --features diagnostics --lib describe_reads_small_buffers_without_faulting_on_unmapped_memory — passed
  • cargo clippy -p victory-gpu --all-targets and --features diagnostics --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean replacement of VirtualQuery with read_into for small buffer diagnostics, verified against unmapped memory without faulting. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052603279 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2142#pullrequestreview-6052603279). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T06:02:46Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --features diagnostics --lib describe_reads_small_buffers_without_faulting_on_unmapped_memory` — passed - `cargo clippy -p victory-gpu --all-targets` and `--features diagnostics --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean replacement of `VirtualQuery` with `read_into` for small buffer diagnostics, verified against unmapped memory without faulting. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 07:02:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T06:33:05Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Small buffer diagnostics via read_into instead of VirtualQuery — diagnostic path change; pairs with the diagnostics cluster (#2110, #1972).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052889059 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2142#pullrequestreview-6052889059). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T06:33:05Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Small buffer diagnostics via read_into instead of VirtualQuery — diagnostic path change; pairs with the diagnostics cluster (#2110, #1972).
Marvisak commented 2026-11-25 12:03:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T11:23:57Z.


Automated triage for the maintainers.

Merge candidate. It is rebased onto current main (one commit, c994126) and merges cleanly. It fixes #913, a diagnostics-only path. In describe in crates/victory-gpu/src/draw.rs, the small closure no longer checks texture::committed and then builds a slice over live title memory. Instead, it copies 4 to 64 bytes into a stack buffer through host::read_into, the same way main already reads the View::Constant path just below. That closes the window between the check and the read, and it drops the (null, 0) slice case. The only visible change: spans under 4 bytes now print nothing instead of = []. The new test (diagnostics, Windows) covers unaligned SRV/UAV reads, the 0/2/6/64/68-byte limits, and a view that crosses into a reserved but uncommitted page.

CI: passing (check). Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160993908 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2142#issuecomment-7160993908). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T11:23:57Z. --- <!-- victory-triage v1 head=c994126800e14e5aba1679c6d62b6ce84c6c108e verdict=merge-candidate at=2026-11-26T01:21:24Z --> Automated triage for the maintainers. **Merge candidate.** It is rebased onto current `main` (one commit, `c994126`) and merges cleanly. It fixes #913, a diagnostics-only path. In `describe` in `crates/victory-gpu/src/draw.rs`, the `small` closure no longer checks `texture::committed` and then builds a slice over live title memory. Instead, it copies 4 to 64 bytes into a stack buffer through `host::read_into`, the same way `main` already reads the `View::Constant` path just below. That closes the window between the check and the read, and it drops the `(null, 0)` slice case. The only visible change: spans under 4 bytes now print nothing instead of `= []`. The new test (diagnostics, Windows) covers unaligned SRV/UAV reads, the 0/2/6/64/68-byte limits, and a view that crosses into a reserved but uncommitted page. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2142:upstream-pr/2142'
git switch 'upstream-pr/2142'

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