GPU: hash and detile unwatched textures from a kernel-read copy #143
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!143
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/143/head"
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?
@AndyLatimer on GitHub · 2026-11-24 00:57 UTC · original
AndyLatimer:fix/gpu-texture-hash-unmapped→main· +21 −2 · 1 files · 3 commits · closed without mergingStaging::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
@jeremygold02 on GitHub · 2026-11-24 04:36 UTC · original
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.@AndyLatimer on GitHub · 2026-11-24 07:47 UTC · original
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.@AndyLatimer on GitHub · 2026-11-24 11:20 UTC · original
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: cleanPull request closed