GPU: hash and detile unwatched textures from a kernel-read copy #143
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/143"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by AndyLatimer on 2026-11-24T00:57:11Z.
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 #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
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:36:07Z.
Tested head
652f06057d13bb183ff64d48806205d25f9debd2:cargo test -p victory-gpu --lib texture -- --test-threads=1was blocked before running tests byE0428:crates/victory-gpu/src/host.rsdefinesmod teststwice (lines 252 and 1974; PR head).cargo check -p victory-gpupassed.#143 changes only
crates/victory-gpu/src/texture.rs;host.rsis unchanged from this branch's base. The duplicate is not present on current upstreamd2a4bae1(mainhost.rs, which has one test module). Texture unit tests could not run until the branch is updated to a base without that duplicate.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:52:32Z.
Review: APPROVED
Tested
8d9e40fon Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (264 passed, 0 failed).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.Heads-up for whoever merges: this collides with #472. Both add an item named
SCRATCHtotexture.rs: #472 astatic Mutex<Vec<u8>>for the watched path, this PR athread_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).
Imported from Marvisak/VIctory. Originally posted by AndyLatimer on 2026-11-24T07:47:01Z.
Thanks @jeremygold02. The duplicate
mod testscame from this branch's old base (9aef3d9); upstream fixed it in #129. I mergedmain(d2a4bae) into the branch, new head8d9e40f, without changing the fix.cargo test -p victory-gpu --libnow builds and passes here: 43 passed, 1 ignored.Imported from Marvisak/VIctory. Originally posted by AndyLatimer on 2026-11-24T11:20:19Z.
Thanks @mercuryVM for the review and the heads-up about the
SCRATCHname collision with #472!Renamed the thread-local buffer in
crates/victory-gpu/src/texture.rstoUNWATCHED_SCRATCHin525a713so both branches compose cleanly without anE0428duplicate definition.Verified on Windows 11 (
rustc 1.98.1):cargo test -p victory-gpu: 43 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --features diagnostics: 45 passed, 0 failed, 1 ignoredcargo clippy -p victory-gpu --lib -- -D warnings(default and--features diagnostics),rustfmt --edition 2024 --check crates/victory-gpu/src/texture.rs,cargo xtask policy: cleanImported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T14:18:33Z.
Review: COMMENTED
Re-tested
525a713on Windows 11, RTX 5070, MSVC, merged on top of current upstream main plus #472:cargo check --workspace --testsis clean, andcargo test --workspacepasses, with victory-shader run single-threaded.SCRATCHthat I hit earlier (E0428), so the two now land together without conflict.AI-assisted (Claude Code).
upstream-sync referenced this pull request2026-11-24 19:03:41 +00:00
Pull request closed