HLE: DirectStorage page-destination writes tell the GPU write watch only after writing #2503
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#2503
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@BastienRodz on GitHub · 2026-11-25 14:57 UTC · original
What happens
DirectStorage page-destination requests write into physical pages through our own views of them (
xmem::page_windowandxmem::write_physical). The GPU write watch cannot see those writes, because its guards are on the title's views of the same pages.xmemtells the watch only after writing:report_writtencallsdrop(victory_gpu::kernel_will_write(page, PAGE))at the end ofwrite_physicaland inPageWindow::drop, for the title views it found before the write.kernel_will_write(watch::writing) is meant to come before the write. It saves an armed page's bytes before they change (changed(.., save = true)). Called afterwards, it saves the bytes DirectStorage just wrote. If a submission has that page armed for marked writes,copy_back_markedthen compares the copy against those new bytes, takes the copy's old bytes for the GPU's, and puts them back over the streamed data.A title view mapped over the pages while a
PageWindowis open is not in the list taken before the write, so it is never told and its copy misses the write.Expected
watch.rsonwriting: "Before our own write into title memory[at, at + len)through the kernel (which does not fault into our handler) or another write the guards do not see: opens its guarded blocks, marks them changed and keeps them open while the result lives." The title's views of the destination pages should be opened before the write and held until it is done, asReadFile,freadand DirectStorage's address destinations already do. Views mapped meanwhile should be told too.Where
crates/victory-hle/src/modules/xmem.rs:report_written,write_physical,PageWindow,page_window, used bydstorage.rs(into_destination) for page destinations.AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
github-bot referenced this issue2026-11-26 05:09:22 +00:00
@Marvisak on GitHub · 2026-11-25 18:51 UTC · original · edited 2026-11-25 21:46 UTC
Automated triage for the maintainers.
The first half is confirmed in main (
61bfc77), incrates/victory-hle/src/modules/xmem.rs:write_physicalcopies the bytes through its own views first, and only then callsreport_written.PageWindowcallsreport_writtenfromDrop, after DirectStorage has decoded into it.report_writtenrunsdrop(victory_gpu::kernel_will_write(page, PAGE))for each title view.So the watch's "before the write" step comes after the bytes have already landed. An armed page then saves the new bytes as its "before" bytes.
The second half does not match the code as stated.
PageWindowlooks up the title views withshown_at(&self.pages)when it is dropped, not when it opens, so a view mapped while the window is open is reported. It is reported with the same wrong order, though: if it was armed mid-window, the end-of-write report saves the streamed bytes as its "before" bytes too.Two open PRs: #2504 and #2566. A review above (by reading, not run) finds that #2504 opens only the views present when the write begins and keeps the end-of-write
report_written, so a view mapped and armed mid-window keeps the problem; #2566 covers both cases (it marks views mapped meanwhile as written, without saving). It also suggests a test that arms the mid-window view and checks nothing was saved, which fails on main and on #2504. The two PRs touch the same functions and conflict.Generated by Claude Code
@Kajanos on GitHub · 2026-11-25 19:02 UTC · original
Review of the two fix PRs (main
13f91ca), by reading the code:report_written(kernel_will_write, save = true, after the bytes landed), so a view mapped during aPageWindowstill has the original problem: a tracker that takes the page there mid-window (takeclears it, since that address is not busy) and arms it gets the streamed bytes saved as its "before" bytes at the end report.copy_back_markedthen takes the copy's stale bytes for shader writes and writes them over the streamed data. #2504's own test has this shape (t2mapped and taken mid-window) but does not armt2, so it cannot see it.title_memory_written(no save).copy_back_markedthen hits the "nothing saved, changed" path and keeps title memory. Itsa_write_reported_after_the_fact_saves_nothingdoes not tell the two apart, though: the earlierdrop(writing(..))already marked the page, sokernel_will_writewould not save there either. A test like #2504's end-to-end one, witht2.arm(..)after the mid-window take andassert!(t2.saved(..).is_none()), would; it fails on #2504 and on main.AI-assisted (Claude Code). Reasoning only; tests not run (no Windows host).