fix(agc): store idle write-backs and publishes on the CPU at completion, keeping blocks the guest wrote in flight #9521
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9521"
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?
Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-22T00:09:24Z.
What
When every queue idles, the driver stores all pending storage image results back to guest memory. For a host import that store was a GPU copy that landed after the batch ran, so stores the guest made while the batch was in flight were overwritten by the older results.
PPSA16064 (Minecraft Dungeons II) reuses a freed 3D storage image's memory for a CPU-filled volume during loading, and crashes on the stale texels.
Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090, NVIDIA 615.78.08, on
maina6dcea927.agc_storage_idle_writeback_race: refills a dead storage volume's memory on the CPU while its results are pending, idles every queue, and checks that the refill survives in watched memory and in GPU-mapped direct memory, both for a plain idle write-back and after a shadow publish. Before the fix, the direct-memory cases lose the refill. A third case writes a selected unit and collects it after the publish has chosen its units but before it records the copy, and checks that the write survives completion; with the write-tracker baseline taken where it was before, it loses all 256 bytes.agc_driver_sample_order,agc_driver_sample_order_grid_referenceandagc_driver_sample_order_recipe_depth_locations, which fail the same way without this change. The storage, write-back and recorder tests (37) on this branch alone: all pass. Conventions pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)UnitShadow.cpp) and #9508 (CMakeLists.txt,tests/Recorder.cpp); whichever merges second gets rebasedImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:13:10Z.
Review: CHANGES_REQUESTED
I found a race in the new CPU-shadow-publish completion guard (
UnitShadow.cpp:261, 268).publishUnitshas already collected writes, selected the live slab ranges, and builtcopiesbeforerecordCopiesOnCpusampleschecked. If the guest writes one of those blocks after that selection but beforechecked, a concurrent write-watch collection can stamp the write at or below the sampled generation; the completion callback then treats the range as unchanged and stores the older slab bytes over the guest write. This matchesGuestMemory::TrackerGeneration’s documented concurrent-walk behavior: a walk still running when the generation is read may absorb later stores with a stamp not newer than that value. The added regression writes only afterFlushAllPendingreturns, which is aftercheckedis captured, so it does not exercise this interval. Please take the comparison baseline before copy selection/collection and pass it through to completion (or otherwise make selection and store detection race-safe), and add coverage that forces a guest write in this interval. The reported tests do not prove this boundary safe.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:13:26Z.
The reported regression is a crash in Minecraft Dungeons II (PPSA16064), and its Game bring-up discussion is #8868. Please update the checklist from
Unblocks: nonetoUnblocks: PPSA16064 #8868, as required for a title-specific crash fix.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:19:08Z.
A live overlap scan for this head also reports #6682 and #9508. I manually compared the current heads with
git merge-tree: #6682 conflicts inUnitShadow.cpp, and #9508 conflicts inCMakeLists.txtandtests/Recorder.cpp. These are real patch conflicts around this PR’s shadow-publish path and recorder-test registration. The checklist saysDepends on: none; please coordinate merge order with those authors and update the dependency line before merge.Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-22T00:39:42Z.
@MarcZX10 thanks, the race was real.
publishUnitsnow takes the tracker generation before it collects writes and selects units, and passes it to the completion. A store that lands while the copy is being built is now newer than the baseline, so completion keeps it instead of overwriting it.Unblocks: PPSA16064 #8868.LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:03:34Z.
Thanks for adding the generation-baseline regression and correcting the title discussion entry. The current branch note says “whichever merges second gets rebased,” but the live conflicts mean there are two different orders: #6682 edits the same
UnitShadow.cppcompletion path, and #9508 conflicts in the test registration (CMakeLists.txt,tests/Recorder.cpp). Please state the intended dependency/order explicitly (or confirm both merge orders are safe and who rebases each branch) and list required predecessors onDepends onbefore merge. I have not run the tests locally; the hosted conventions/eligibility/report checks pass and Linux/Windows/relinker jobs are skipped.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:42:11Z.
Review: CHANGES_REQUESTED
The latest head
3e7c7bd03aefappears to fix the tracker race I reported:publishUnitssnapshots the generation before the uncached write collection and unit selection, passes that baseline to completion, and the new hook writes/collects a selected unit after selection but before copy recording. The negative-control result in the PR history is consistent with that test. Current diff-check and conventions pass, and the individual branch merge with currentmainis clean.Merge readiness still has three blockers:
main(merge basea6dcea927). Refresh it and run the required same-machine/same-GPU AGC comparison on currentmainand this head withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, usingctest -V. The report must confirm the layer was found, compare newVUID-messages, and name GPU vendor/model/driver/OS. Existing suite results and listed GPU are useful but do not include this required comparison.Depends onwhen one must land first. The live pairwise conflicts remain: #6682 conflicts inUnitShadow.cpp; #9508 conflicts inCMakeLists.txtandtests/Recorder.cpp. Please coordinate #6682’s order and update the dependency/order note so the affected branch preserves both changes. (The #9508 branch is yours, so please also record its concrete order.)CMakeLists.txt/Texture.cpp; inspect those current open diffs and update the overlap coordination record if any of those edits need ordering.I did not run local GPU tests/builds in this pass.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:42:24Z.
Correction/addendum to my review: I completed the pairwise merge checks with #9674, #9675 and #9676. All three merge cleanly with this head, so their shared
CMakeLists.txt/Texture.cpppaths do not currently establish an ordering dependency. The listed overlap should still be acknowledged in the next overlap report, but I found no added blocker from those three PRs.