GPU: refresh unwatched textures without a region query; detile into cached memory #388
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!388
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-388"
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?
@ItsYusei99 on GitHub · 2026-11-24 02:51 UTC · original
ItsYusei99:perf/texture-refresh-no-region-query→main· +32 −13 · 1 files · 1 commits · openUnder Wine, the menus and the intro stuttered. Each frame spent about 28 ms refreshing sampled textures. Two parts of
Staging::refresh_nowcaused it.1.
committed()on the unwatched path. Before it hashes a texture that is not write-watched,refresh_nowcheckscommitted(self.memory, size). That check walks the range withVirtualQuery, one region at a time. Wine implementsVirtualQuerywith a server round trip, so for big texture pools this one check costs most of the refresh. The path now copies the whole texture out withhost::read_into(ReadProcessMemory) intoLast::read, which the watched path already uses. The copy fails by itself when any page is not committed, so it replaces the check and keeps the same "not committed, skip it" result. A side effect: the hash and the detile now read the copy rather than the title's memory directly. That removes the fault #143 describes, where the title unmaps the pages between the check and the read.2. Detiling straight into the upload heap.
detilewrote each subresource directly into the mapped staging buffer. That buffer is an upload heap, which is write-combined memory, and the scattered writes of a detile are very slow there. Each subresource is now detiled into a cached scratchVeckept inLast, then copied to the staging buffer in one sequentialcopy_nonoverlapping.Cost: one extra CPU copy of each unwatched texture per refresh (the read), and one scratch buffer per staged texture, as large as its biggest subresource.
Measured
Linux, Wine 11.22, vkd3d-proton 3.2.0, RTX 4070 (driver 620.70.06), Ryzen 7 9800X3D. These are frame lines in the menu intro:
I measured this on my local tree, which also carries other patches: #177, and a 16-bit render target substitution like #89. I have not re-measured on this exact commit, and I have not measured the two parts separately. Not tested on native Windows.
VirtualQueryis much cheaper there, so most of the gain there would come from part 2, if any.Relation to open PRs
committed()check, which is the slow call under Wine. It uses a thread-local buffer, so it keeps no copy per texture. If that memory matters more, this change can use #143's / #215's thread-local scratch instead ofLast::read, as long as thecommitted()call goes away.Checks
cargo xwin test -p victory-gpuunder Wine: 43 passed, 1 ignored.cargo xwin clippy -p victory-gpu --all-targets: no warnings intexture.rs. The one warning is athost.rs:267, which is onmain.diag(--features diagnostics) builds OK.cargo xtask policypasses, andrustfmt --check texture.rsis clean.🤖 Generated with Claude Code
@ChruutvoLuzi on GitHub · 2026-11-24 03:08 UTC · original
Native Windows numbers, since the description says it isn't tested there. RTX 4090, driver 621.01, Windows 11, i9-14900K, diag build, from boot through the first mission's opening. Base:
d2a4baeplus other PRs I was testing; two runs with this PR and two without. The other PRs differ slightly between the runs (#282 and a depth-view patch from #392), and neither touches texture refresh. This PR (e54b675) conflicts with #89 indetile; I kept #89'sdetile_subresourcecall and pointed it at this PR's scratch buffer, followed by this PR's single copy to the staging buffer.From the
textures X ms Y MBpart of the frame lines, as time per MB:In the world that's 86 to 95 ms of texture preparation per frame with this PR, against 54 to 68 ms without, for 118 to 137 MB.
So on native Windows it costs about 40% more per MB in the menus and more in the world. That fits the caveat in the description:
VirtualQueryis cheap here, so skippingcommitted()saves little, while the extra read intolast.readand the copy out of the scratch buffer add work. Would it make sense to keep the old path on native Windows and use this one only under Wine, or to keep just the detile-into-cached-memory part?AI-assisted (Claude Code).
@DaviTostes on GitHub · 2026-11-24 13:10 UTC · original
A phase split from a real title run on the gap your thread lacks: Linux/Wine, AMD. I instrumented
Staging::refreshlocally (not upstream) to time its parts; this is a release build ofmainffe310e, package 1.0.2.1,build unknown (b99f876b…).Setup: RX 9060 XT (RDNA4, RADV 26.3.1), Arch Linux, kernel 6.18.x; Wine 11.22 (system), DXVK 3.1.1
dxgi, vkd3d-proton 3.2.0 (Proton Experimental DLLs),WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n".In-world, per 512 texture refreshes:
committed(VirtualQuery)watch(GetWriteWatch)hashdetilecopyThe frame line in the same run is
textures 871–1413 ms / 80–91 MB, so the region query on the unwatched path is the largest single part, ahead of the write-watch askings and hashing.copy/detileare small.That matches what this PR removes. It also suggests #776 (write-watch askings) and #401 (hash bypass) stack after it, but this one is the biggest on Wine, where each
VirtualQuery/GetWriteWatchcrosses into the host kernel.Not tested: a controlled A/B with the PR itself (I can run it on this machine next), Windows/NVIDIA, long sessions (runs freeze at #774 ~3 min in).
@DaviTostes on GitHub · 2026-11-24 13:41 UTC · original
Stack result on AMD/Wine (main
ffe310e+ #783 + this PR + #282 + #454), real game, release build:VirtualQueryshare is gone.rectangles not expandedwarnings with #282.RtlReleaseSRWLockExclusiveand no frame progress. With #454'sVICTORY_NO_WATCHDOG=1the process stays alive instead of the title's null-write exit.Setup: RX 9060 XT (RDNA4/RADV 26.3.1), Arch, Wine 11.22, DXVK 3.1.1
dxgi, vkd3d-proton 3.2.0, package 1.0.2.1. Not a controlled same-save A/B; not tested on Windows/NVIDIA.This was the biggest texture win in the stack — thanks.
@Yaekai on GitHub · 2026-11-24 15:54 UTC · original
Independent test & review on Windows 11 + NVIDIA RTX 3070 (8 GB, Rust 1.98.1) at head
e54b675:cargo test -p victory-gpu --lib texture: passed (3 passed, 0 failed, 1 ignored).cargo clippy -p victory-gpu -- -D warnings: 0 warnings.1.0.2.1,--console series-s, release build onffe310ewith#452+#493+#587+#211+#492): ran 19+ minutes in the world (~135–145 MB/frame texture uploads, ~45 ms/frame) with zero texture corruption or stalls.detile()computeslen = pitch * rows * f.Depth(same as before this PR); if#601lands alongside this, clampinglento the allocated staging slice (footprint_len) composes cleanly with the cachedlinearscratch buffer here.Looks clean and ready to merge once rebased on
main.@neonbyte1 on GitHub · 2026-11-24 16:29 UTC · original
Measured on Linux: RTX 5090, Wine 11.22 with the wineserver view-tree patch from #340, vkd3d-proton from GE-Proton11-14. Prologue world frames, medians over about 55 summary lines per run.
With this PR merged together with #514,
textureswas 10.6 ms per frame, compared with 7.8 ms before both. So no gain showed on this setup.The patched wineserver has already made the
VirtualQuerywalk this PR removes cheap. With a stock wineserver (no view-tree patch),textureswas 46–213 ms per frame in the same scenes. That's the setup where this PR's saving should show up; I haven't measured this PR on a stock wineserver.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 00:31 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(4118f33b). Conflicting files:crates/victory-gpu/src/texture.rs.The content will be reviewed once the branch is rebased onto
main.Generated by Claude Code
@aycow on GitHub · 2026-11-25 01:33 UTC · original · edited 2026-11-25 01:36 UTC
@ItsYusei99 I tested a local FIND-2 candidate on
ccfb029that preserves the exact BLAKE3 digest. It speeds up single-caller synthetic refreshes but loses under concurrent refresh, so it stays off by default. #388 already gives the unwatched hash and detile an immutable input through the checked read. If your design keeps that snapshot stable through both operations, I can test the digest change against it and measure the added read and scratch costs together. Would that input lifetime still hold with your current revision?Local follow-up: exact #388
e54b675and the FIND-2 candidate compose with the digest and detiler using the same owned input under the existing lock. Both strict GPU Clippy configurations passed. Digest, range, and staging checks also passed with hashing off and on using the default hardware adapter and WARP. Combined read/scratch cost and title impact remain unmeasured.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.