GPU: a partial refresh of an armed page updates the bytes saved of it #2377
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!2377
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2377/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?
@BastienRodz on GitHub · 2026-11-25 12:15 UTC · original
BastienRodz:gpu/armed-page-refresh→main· +71 −2 · 2 files · 2 commits · merged 2026-11-25 21:56 UTCWhat's wrong
Since
cd94d35, marked writes arm pages instead of taking a snapshot. The title's first write to an armed page saves the page's old bytes, andcopy_back_markedcompares the copy against them. A refresh of only part of such a page in the same submission (update_busyunder a written range,update_freebeside a sub-page one) copies the title's newer bytes into the copy but leaves the saved bytes as they were:Tracked::takekeeps a partly covered page changed, andupdate_busyupdates onlyShadow::before, the snapshots of unmarked ranges. Copy-back then takes the refreshed bytes for the GPU's, which puts them back over later title writes, and misses shader writes back to the saved value.What the fix does
Tracked::refreshed(from, bytes)(watch.rs) copies freshly refreshed bytes into the saved bytes of the pages they cover. It returns at once when nothing is saved, the usual case.Shadow::copycalls it after copying. That keepscopy_back_marked's rule ("what differs from the copy's bytes before the submission") for armed pages, asupdate_busyalready does for the snapshots of unmarked ranges.Tests
New
shadow::tests::partial_refresh_under_marked_range_updates_saved_bytes: two pages armed by a range ending 16 bytes into the second, the title writes both pages, part of each is refreshed (under and beside the range), the title then writes again and a shader-side write goes into the copy. Copy-back must keep the later title writes and take the shader's.main(940d32f) it fails:left: [170, 85, 68, 17](stale0x55over the title's0x66, the shader's0x00lost),right: [170, 102, 0, 17].shadow::tests(5) andwatch::tests(6) pass. Run under Wine 10 with vkd3d-proton 3.1 on llvmpipe: the copy needs a host device, and the test returns early without one.Not tested
No title run, and no AMD/NVIDIA GPU. How often the title refreshes part of a page it is also writing through marked views is not measured.
Relation to #2172: that PR widens refreshes of marked view ranges to whole pages, which takes such pages whole and drops their saved bytes. It does not cover a refresh of another range (a constant buffer, say) in the same page, which is what this fixes. The two don't touch the same lines.
Fixes #2375
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code
@BastienRodz on GitHub · 2026-11-25 12:33 UTC · original
Thanks @AndyLatimer, that's a thorough check, and good to have it confirmed on a real device. The ordering and lock analysis match my reading. I hadn't thought of the whole-page window between
takedropping the saved bytes and the copy being made; that's a nice extra.Doc nit addressed in 81e7648:
SavedandTracked::savednow say the saved bytes have later refreshes laid over them, i.e. the copy's bytes before the submission.On #2169: agreed, whichever lands second needs
self.changed.0.lock()/state.bytesinrefreshedand thescratchargument in the test's two calls. I'll rebase if this one ends up second.@Marvisak on GitHub · 2026-11-25 14:55 UTC · original · edited 2026-11-25 16:45 UTC
Automated triage for the maintainers.
Merge candidate.
Shadow::copynow callsTracked::refreshed(watch.rs). When a refresh covers only part of an armed page, the page's saved bytes take the refreshed bytes too. Before,takeleft a partly covered page changed with its old saved bytes, socopy_back_markedmistook the refresh for a GPU write. Whole-page takes already drop the saved bytes throughtaken, andrefreshedreturns at once when nothing is saved, so the usual path costs nothing extra. The test covers a refresh both under and beside the marked range.Relation to the other
shadow.rsPRs:Shadow::before) incopy_back_marked. This PR updates a different buffer (the watch's saved bytes) in a different function, so the two are complementary. Merged together, they conflict only where both add tests beforemark_runs_are_reused_and_joined. Keep both tests.Shadow::copy_back_marked. The production change here still applies with it, but this test callscopy_back_marked, so whichever lands second needs to adapt the test.CI:
checkpassing.Generated by Claude Code
@BastienRodz on GitHub · 2026-11-25 15:49 UTC · original
Rebased onto main
da82e44(the tests block conflicted with main's two new shadow tests; kept both). Checked again on the new main: withTracked::refreshedremoved the test still fails (left: [170, 85, 68, 17],right: [170, 102, 0, 17]), and it passes with it.shadow::9/9,watch::12/12 (Wine + vkd3d-proton).