Repository navigation
GPU: hash and detile unwatched textures from a kernel-read copy - #143
AndyLatimer wants to merge 3 commits into
Conversation
Textures in memory with no write watch (the physical-page views of the texture pool) were checked with committed() and then read directly, twice (hash, detile). A title unmapping those pages in between, for example evicting a texture a big descriptor table still lists, faulted on the read, and the vectored handler takes only writes. The memory is now read through copy_mapped (ReadProcessMemory, zeros for unmapped pages), as the watched path already does, into a per-thread scratch buffer reused between textures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… kernel-read copy) into the integration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
…read copy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested head
#143 changes only |
|
Thanks @jeremygold02. The duplicate |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 8d9e40f on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed).
- The race is real.
committed()followed by a direct read leaves a window where the title can unmap the view, andwatch.rs's vectored handler only takes write faults. Reading throughcopy_mapped, the sameReadProcessMemorypath the watched branch uses, turns that into zeros instead of a crash. Splitting the hash and detile intochangedis a pure move. - A thread-local scratch buffer is the right cost model, since it holds no per-texture copy.
Heads-up for whoever merges: this collides with #472. Both add an item named SCRATCH to texture.rs: #472 a static Mutex<Vec<u8>> for the watched path, this PR a thread_local!. The two merge without a textual conflict, but the result doesn't compile (E0428, the name is defined twice). If both land, the unwatched path could just reuse #472's buffer (or the thread-local could replace it), since both are "one scratch buffer for reading texture memory". I have not merged this into our fork for that reason.
AI-assisted (Claude Code).
…llision Rename the thread-local SCRATCH buffer in crates/victory-gpu/src/texture.rs to UNWATCHED_SCRATCH so PR Marvisak#143 composes cleanly with PR Marvisak#472's static SCRATCH mutex without an E0428 duplicate-definition error (flagged by @mercuryVM).
|
Thanks @mercuryVM for the review and the heads-up about the Renamed the thread-local buffer in Verified on Windows 11 (
|
…es from a kernel-read copy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mercuryVM
left a comment
There was a problem hiding this comment.
Re-tested 525a713 on Windows 11, RTX 5070, MSVC, merged on top of current upstream main plus #472: cargo check --workspace --tests is clean, and cargo test --workspace passes, with victory-shader run single-threaded.
- Renaming the unwatched-texture scratch buffer resolves the duplicate-definition clash with #472's
SCRATCHthat I hit earlier (E0428), so the two now land together without conflict.
AI-assisted (Claude Code).
…itives, capture), verified together Merges #124 #119 #515 #934 #484 #143 #1191 #278 #553 #153 #270 #1158 #1204 #1220 #488 #1146 #631 onto main (ffe310e), each head unchanged, no conflicts, no changes of mine. cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (372 passed, 8 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ures, device, DXGI, objects, primitives, capture) Kept from our side: - watch.rs: the per-submission journal (Journal.round, new_round, covered, cover, writes_once) and the WatchKernelUs/WatchGuardUs/WatchPages counters; the guard timing now wraps the PR's by-allocation fallback, and the per-allocation kernel askings (#515) count into WatchKernelUs and WatchPages too. Both sets of watch tests kept. - texture.rs: our version (CommittedRegions, RUNTIME_WRITES and the last.checked skip, changed-subresource detiling, mip drop, widened packed16) with the PR's footprint fix on top: upload footprints end at the last row's data bytes (GetCopyableFootprints row sizes), detiling goes through detile_plane, title_written_flags, overflow-checked committed() and refresh range, and the PR's tests. #143 was already merged; the SCRATCH -> UNWATCHED_SCRATCH rename is left out (no #472 here). - copystat.rs: our counters and lines, plus the PR's process memory line. - primitive.rs: our position+color fast path, plus the PR's zero and overflowing stride guards in the generic path. - #124, #119, device.rs and object.rs changes were already in our tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rnel-read copy
…rnel-read copy
Staging::refresh_now(crates/victory-gpu/src/texture.rs) has two paths for a sampled texture's memory:copy_mapped(ReadProcessMemory), which reports unmapped pages instead of faulting.committed()and then read the memory directly, twice: once forblake3::hashand once fordetile.If the title unmaps those pages between the check and the reads, the read faults. That happens, for example, when it evicts a texture that a big descriptor table still lists, because the GPU would never sample it. The vectored handler in
watch.rstakes only write faults, so the process dies.The unwatched path now reads through
copy_mappedas well. Unmapped pages come back as zeros. The copy goes into a per-thread scratch buffer that is reused between textures, so no CPU copy is kept per texture (keeping one inLast::read, as the watched path does, would hold a copy of every sampled texture in the pool). Thecommitted()early-out stays. The hash and detile code moved unchanged intoStaging::changed.Cost: one extra copy of each hashed texture per refresh, on top of the hash's own read. I have not measured it in game. The
diagnosticscopy statistics (MoveUs,TexHashed) show it.Testing
cargo test -p victory-gpu: 43 passed, 1 ignored, with this commit rebased ontod2a4bae. That commit includes GPU: rename the second test module in host.rs so the tests compile #129, which fixed the duplicatemod testsinhost.rsthat keptvictory-gpu's tests from building on the branch's base9aef3d9.cargo test --workspace --exclude victory-gpuon the branch: 221 passed, 3 ignored (need external files).cargo clippy -p victory-gpu --all-targetsandcargo clippy -p victory --features diagnostics: no new warnings. The ones inhost.rs:267(test code) andxmem.rsare onmain.cargo xtask policy: pass.rustfmt --checkontexture.rs: clean.🤖 Generated with Claude Code