fix(agc): save pending storage results in every 64 KiB block that leaves the write watch #5671
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5671"
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 oneandonlydean on 2026-10-14T05:51:47Z.
What
Follow-up to #5657, for the throw still reported in #361 on Disney Epic Mickey: Rebrushed (PPSA15657) by @johnmaia:
On Windows a range leaves the write watch in whole 64 KiB blocks (
WriteWatchCoverage::Exclude), but the unwatch hook from #5657 got the page range of the import. An image with results pending in the same block as an imported page, but outside that page, lost the watch without its guest bytes being saved. Its next store threw.WriteWatchCoverage::ExcludedSpanreturns the blocksExcludedrops, using the same block math. On Windows the hook gets that span, so every image with results pending in those blocks saves its bytes first. Linux drops the watch per page, so it is unchanged.This covers one of the remaining paths to the throw. The trace requested in #361 will confirm whether it is the one PPSA15657 takes.
Tested
Linux (CachyOS, GCC 16.2.1, RTX 4090), Release,
BUILD_TESTING=ON, onmainf74ec639c:agc_write_watch_coverage: new checks ofExcludedSpanfor a single page, a block boundary, the last partial block and the arena start.agc_driver_store_over_untracked: new case where the page before a linear surface is imported, so the surface's first block leaves the watch. It fails on Windowsmain: the hook range does not overlap the surface. On Linux it passes before and after, because the watch drops only the page there. Windows CI runs it.ctest -R "agc_|guest_memory|write_watch": 500 of 501 pass.agc_driver_bc_block_copyfails the same way onmain.APS5_WRITE_WATCH_IMPORTS=unwatch:store_over_untracked,recorded_kept_bytes,write_watch,guest_memoryall pass.tools/check_conventions.pypasses.Not run on Windows or with the title.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T05:53:38Z.
Validation check: the description says “Windows CI runs it,” but the current PR check list reports the Windows job as skipped. The reproducer is specifically about Windows 64 KiB write-watch blocks, and the local Linux run is expected to pass both before and after the change. Could you run
agc_driver_store_over_untrackedon Windows, or clarify that this Windows-only regression still awaits CI/manual validation?Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:59:27Z.
This covers one of the paths left after #5657: on Windows the write watch is dropped in whole 64 KiB blocks, and now every pending storage image in those blocks has its guest bytes saved. It needs a Windows run before it goes in. @johnmaia could you try Epic Mickey (PPSA15657) on this head with the same steps? @AlxcBTW the same for Sword of the Sea (PPSA25344), since it hit the same throw. Please post where it gets to, and the throw if it still happens (with
APS5_TRACE_FLUSH=1 APS5_TRACE_HOST_IMPORT=1 APS5_TRACE_MEMORY=1if you can).Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-14T06:57:48Z.
PPSA15657 (Epic Mickey: Rebrushed) on this PR: Windows 11, RTX 4080, head
9190e9541merged intomaind8888df9b, game relinked with that build, same steps as on #5657 (title, Continue into Dark Beauty Castle).The storage-results throw from #5657 is gone. At the same point, 17 s after Continue, the game now faults on a null read in its own code:
maind8888df9bmaind8888df9b+ this PRmaina31043146with #5596 revertedOne run each, so I can't rule out the fault being intermittent. The zeroed guest memory at 0x204d700000 might be data the title expected to find stored, but I haven't confirmed which image or buffer covers it.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T08:30:00Z.
Runs for this PR at head
9190e9541. Windows 11, MinGW-w64 GCC 15.2.0 Release, two GPUs in one machine: Intel UHD Graphics 770 (driver 32.0.101.6129, picked withANYPS5_GPU=Intel) and RTX 4090 (NVIDIA 616.92).agc_driver_store_over_untracked,agc_write_watch_coverage) pass on both GPUs.ctest -R "agc_driver|agc_masked|agc_shader" -j4: no failures on either GPU. Intel: 396 tests, 28 skipped. NVIDIA: 396 tests, 1 skipped (agc_driver_stencil_ref_export). The skips are the same as onmainwith each GPU. On the UHD 770 they are features it doesn't support: f64, 64-bit and float atomics, mesh shaders, fp16 interpolation and dot, shader clock.No difference between the two GPUs.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T08:59:23Z.
AMD and NVIDIA runs for this PR at head
9190e9541. Windows 11 Pro 26200, WinLibs GCC 15.2.0 (MinGW-w64), Release, one machine with two GPUs, each picked withANYPS5_GPU:1002:13c0, RDNA 2), driver 32.0.21036.18ctest -R "agc|shader|video_out" -j 8(515 tests, including the ones this PR adds or changes):agc_driver_lds_mixed_width_atomics,agc_driver_pixel_interlockandagc_driver_layered_volume_vertex_no_gpl. These three fail the same way on currentmain(872f52320) on this GPU and pass there on the RTX 5070; they are the three of #5271, so not caused by this PR.No title run. AI-assisted: yes (Claude Code ran the builds and tests).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T19:04:21Z.
The PR description still says “Windows CI runs it,” while the current Windows job is skipped by path eligibility. Two independent Windows reports in this PR thread do validate head
9190e9541on four GPUs, and the Epic Mickey result is also recorded as one run with an unresolved guest null read. Please consider updating the Tested section to reflect those contributor-run results and remove the CI claim; I couldn’t update the description because the PR is authored from your fork.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:03:10Z.
Rebased onto current
main: the only conflict was inStoreOverUntracked.cpp(mainaddedNeighbourCopied,WaitForWorkand thesideparameter). I kept both cases, so the case list is now 9 entries. Rebuilt and re-ranagc_write_watch_coverage,agc_driver_store_over_untrackedandagc_driver_recorded_kept_byteson the result, also withAPS5_WRITE_WATCH_IMPORTS=unwatch: all pass.The Windows runs in this thread (@tibzejoker on Intel UHD 770 and RTX 4090, @simonbronk on RTX 5070 and AMD gfx1036) cover the Windows-only path, and @johnmaia confirms the throw is gone on PPSA15657. The description's "Windows CI runs it" is not accurate, since the Windows job is skipped on PRs; the merge goes through the full Windows build.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:08:32Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cppL213, L421, L429Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppImported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-15T12:55:26Z.
The case this PR added, "a surface whose first block left the write watch with the page before it", fails on Linux:
main3ee537191; Linux 7.2.10 (CachyOS), RTX 3080 with NVIDIA 615.78.08, GCC 16.2.1, Release,BUILD_TESTING=ON. Reproduce:APS5_WRITE_WATCH_IMPORTS=watch ctest -R '^agc_driver_store_over_untracked$' --output-on-failure.APS5_WRITE_WATCH_IMPORTS=watch, and withprobe, it fails in 3 of 3 runs each. On this machine the probe keeps imports watched:[write-watch] host imports resolve write protection: no (...); imported ranges stay watched.watchorprobe, the eight cases before it print nothing. The last surface made is the linear one (tile=0) that only this case uses, and the log has[gpu] storage image <surface> destroyed with GPU results pendingright before the failure.APS5_WRITE_WATCH_IMPORTS=unwatchthe case reports "not run, the surface is not write-watched".beforeUnwatchapplies only on Windows (#ifdef _WIN32); the new case also runs on Linux.unwatch, 2 of 3 runs then fail inRunSecondStoreat "the first result was not stored", the assertion #6347 reports on Windows. Since this PR that surface is linear as well (tile=0in the log):surfaceTileis set only inRun(), and the last case leaves it atTileLinear.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T13:04:40Z.
agc_driver_store_over_untrackedfails onmainon Linux (Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti, NVIDIA 595.99), every run since this merge:Bisecting the first-parent merges between
0afa6a607(passes) and71bd2876e: it passes 2 of 2 atd106eefb8and fails 2 of 2 frome53927780(this merge). It still fails 6 of 6 ate890b4a38, also with nothing else using the GPU.Not checked, from reading the diff: the test now counts the new
neighbourcase as leaving the watch (leaves = ... || neighbour), so the check atStoreOverUntracked.cpp:410expects its result in a block the CPU left alone. On Windows,ExcludedSpandrops the import's whole 64 KiB block. Under#elsethe hook still gets the import's page range, so on Linux the neighbouring page presumably stays watched and never takes that path. If so,neighbourwould only count as leaving on Windows.Update: my guess above was wrong. On Linux the failing case is
NeighbourLeftWatch, and it passes 3/3 whenNeighbourCopiedis skipped. The failure comes fromNeighbourCopied's earlyMissedreturns, and #6385 fixes it (15/15 here,mainfails 5/5). Details are on #6385.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T13:22:43Z.
@SleglJan The
RunSecondStorefirst-result assertion in yourunwatchruns is the one tracked by #6347. #6359 changes its wait to requireFindPending(address, SurfaceBytes)to equal the expected live image. With the old predicate, a diagnostic reports that image is not pending immediately before the assertion; the two-line correction passes100/100 on each of our Windows NVIDIA/AMD GPUs.A tile reset alone was also tested on unchanged main2db: still5/5 first-result failures per GPU. That rules it out as the Windows fix, not as a Linux-specific factor. I have not reproduced your Linux runs. Your earlier neighboring-page
result did not reach a block the CPU left alonefailure occurs before this wait and remains separate; #6359 is not evidence that it fixes that case.If you retest #6359 on Linux, please distinguish those two assertions and the watch/probe/unwatch modes. Exact Windows pins, controls and limits are in #6347. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-15T17:02:16Z.
@oneandonlydean an update for PPSA15657 on Windows, now that this and #5679 #5321 #5522 are on
main: onmain0029e62f9(plus #6236 only to get past the PlayGo stop from #6205), Epic Mickey: Rebrushed loads its level and plays about 5 minutes, through a death and a checkpoint reload, on an RTX 4080. There's no storage-results throw (the log has no "storing storage image results pending ..." line) and no fault, including the null read at eboot 0x1b2fd0d from my earlier run. So the Windows regression from #5596 that I reported on #361 is resolved for this title. In the earlier runs the red-zone fault came about 3 minutes into play; this run reached about 5 minutes without it. That's one run, not a soak test.AI-assisted: yes (Claude Code)