Skip to content

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

Open
fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-describe-small-read-into-913
Open

fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-describe-small-read-into-913

Conversation

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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.

`describe` still queried `texture::committed` (`VirtualQuery`) and formed a
raw slice over live title memory for `<= 64`-byte buffer SRV and UAV ranges,
walking pool regions on every noted draw and dispatch while exposing a TOCTOU
window against concurrent unmapping or page protection changes. Read `4..=64`
byte spans into a 64-byte stack buffer with `host::read_into`, matching the
constant-view path.

Closes Marvisak#913.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

RecompLive added a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
Ported from Marvisak/VIctory#2142 (GPL-3.0-or-later).

describe()'s small-buffer path still queried committed pages and built a
slice over live title memory for <=64-byte buffer views, on every noted
draw: a TOCTOU window against unmapping or guard changes, and an invalid
(null, 0) slice for an empty range. It now reads 4..=64-byte spans with
host::read_into into a stack buffer; empty and sub-dword ranges omit the
float suffix.

Test describe_reads_small_buffers_without_faulting_on_unmapped_memory
covers unaligned SRV/UAV formatting, boundary lengths and reserved or
unmapped pages.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. In describe (crates/victory-gpu/src/draw.rs, diagnostics-only), the small closure for buffer SRV/UAV views of at most 64 bytes no longer calls texture::committed (VirtualQuery) and builds a slice over title memory. It now reads into a 64-byte stack buffer through host::read_into (ReadProcessMemory). That is the same approach main already uses for View::Constant in the same function, and the cost #913 describes. Spans shorter than 4 bytes now print no suffix instead of = [], which is harmless. The new test covers unaligned reads, boundary lengths, and spans that cross into reserved or unmapped pages. I found no other open PR for this, and it merges cleanly.

CI: passing (check).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU diagnostics: DRED command notes call VirtualQuery per draw, world frames ~10x slower (fix on a fork)

4 participants