GPU, HLE: opt-in guarded writes for title memcpy and memset #3375
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!3375
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3375"
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?
@lhnizdo on GitHub · 2026-11-26 20:51 UTC · original
lhnizdo:pr/guard-crt-copy→main· +374 −5 · 4 files · 3 commits · openOn Windows, a title import of
memcpyormemsetfromVCRUNTIME140.dllcan write through a writable view of the same physical section while its title mapping stays read-only. Enable the experiment withVICTORY_COPY_BESIDE=1. The default keeps the host CRT bindings and the existing section layout.The hook processes one 64 KiB destination page at a time. It pins the view registration, verifies protection, marks the page and its aliases dirty, and lets armed trackers save the old bytes before writing under the guard lock. Ordinary writes run after releasing those locks. A small bit table skips registry lookups for ordinary address regions. A stale bit only causes another lookup. Remapping unregisters the view before unmapping it. The resolver still checks the host allow-list and the presence of the actual export.
Measurements
On a Ryzen 7 2700X, the ignored
guarded_crt_copy_benchmarkalternates 3,200 native and redirected 4 KiB writes per sample on the same 32 freshly guarded pages, including the tracker take. Every round checks the dirty range, and every sample verifies the final bytes. On the standalone branch the three native samples measured 7.36, 9.17 and 9.37 µs/copy. The redirected samples measured 0.70, 0.70 and 0.75 µs/copy.On a separate RTX 2080 integration stack, two five-minute runs used the same diagnostic executable with the BVH builder held back. The enabled run logged a redirected CRT write. Both runs reached the world and ended at the cutoff without device removal. Medians below use complete reporting intervals after world entry with at least 500 draws per frame.
Streaming and draw counts differed. An earlier pair, before the region filter, also varied substantially. These runs establish that the title uses the path and show lower guard overhead in the final pair. They do not establish higher world FPS.
Verification against main
Integration
#3069 targets marked GPU copy-back and has independent evidence about readers overlapping a write. This change targets title CRT calls. It holds the guard lock from the dirty mark through the page chunk's write. A refresh that already obtained its dirty ranges can still overlap title activity. A multi-page CRT copy has ordinary CRT visibility. If #3035 lands, its optimistic snapshot validation will need to account for writes through retained guards and their aliases.
The CRT interception idea follows avatarmanz's VIctory work.
AI-assisted (Codex).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.