fix(agc): keep a compute data hit's live words with the regions that span them #6911
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6911"
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 EagleBearerYS on 2026-10-16T17:53:16Z.
What
A compute dispatch resolved ahead hands its data hit to the dispatch that adopts it with copies of its regions and words:
(
Execution/src/Driver/Dispatch/Dispatch.cpp:386-387.) The copied regions still point into the localliveWords, which is freed when the resolvingdispatchreturns. The adopting dispatch builds its snapshots from those regions. For an address-based program,ShaderResources::Complete→prepareAddressBindings→GuestBufferMemory::AddSnapshotthen compares freed bytes with the live region. Where no live region owns the snapshot, it uploads them (AddSnapshot's copy).This runs in the default configuration.
executeresolves every compute-queue submission ahead (PacketExecution.cpp:316-319), so any title with an address-based compute shader on an async compute queue, whose scalar-loaded constants change between submissions, reaches it on each such data hit. It came in with #1864's resolve-ahead path.This PR moves the regions and words into the parked entry instead of copying them, so the words travel with the regions that span them. It also captures
liveWordsby move in the pipelined dispatch item. That second change is hardening: a pipelined variant is never address-based today, so that path never reads the words.Related: #5769
The title. Onimusha: Way of the Sword (PPSA27836) prints this warning on plain
main(31cbb55d7, frankea'smain1.errin #5769, 2026-10-16). With #5884 and #5907, which get further into the game, the warning's running count reaches 9 with host imports and 221 without:main17cfb1f4c+ #5915 + #6557 + #6727 + #6762 + this PR, RTX 5070, host imports on.How.
fix(agc): keep a data hit's live words with the regions that span them: the two moves, and the new testagc_driver_dispatch_data_hit_words(tests/execution/DispatchDataHitWords.cpp).s_load_dwordof a constant, aglobal_load_dwordthrough a pointer, and abuffer_store_dword.constant + 1.test(agc): fail the data hit test on the snapshot mismatches it causes:AddSnapshot's mismatch count, a function-local static until now, becomesSnapshotStats::mismatchednext to the existing compare counters, read bySnapshotMismatches(). The test requires the count unchanged across its data hits.Why the moves are enough:
ahead, to the adopting dispatch's locals.return, and nothing readscapturedorliveWordsafter them.ResolvedDispatch.resolveGroupAheadandIndirectDispatch.cppread only addresses and sizes from it.Tested
66e290f1c0:agc_driver_dispatch_data_hit_wordswithDispatch.cppat main's: 0/20, each run printing the line above and "its snapshots differ from the registered memory serving them";-DANYPS5_ENABLE_ASAN=ON): red 0/5, each aheap-use-after-freeinAddSnapshot'smemcmp, freed byresolveGroupAhead→dispatch; green 5/5 with no report;ctest -R '^agc': 625/625, 43 skipped as expected (main: 624/624).Dispatch.cppand the new counter kept, the test failed in each of 3 runs. With the fix it passed 20/20, along withagc_driver_pipelined_dispatchandagc_driver_pipelined_dispatch_item. The libc and libkernel suites show no new failures;precise_waitfails on main on that runner too.libs, ctest on lavapipe andcheck_skips.py, onf5fd23ee3): 1,291 of 1,296 passed. The 5 failures are IPv6 tests the build container always fails, andcheck_skips.pyflags onlyguest_sce_net, which that container always skips.f5fd23ee3(comment):agc_driver_dispatch_data_hit_wordspasses.f5fd23ee3merged ontomain47a266cf9(review):agc_driver_dispatch_data_hit_words,agc_driver_pipelined_dispatchandagc_driver_pipelined_dispatch_itempass 3/3 on the 3070 and pass on lavapipe;agc_driver_dispatch_data_hit_wordspasses--repeat until-fail:20on the 3070. WithDispatch.cppfrommainit fails 10/10 on the 3070 and 3/3 on lavapipe:data hit 1, resolved ahead on the compute queue: its snapshots differ from the registered memory serving them (1 snapshot mismatches).^agcpasses 650 of 650 on both (main: 649 of 649).tools/check_conventions.py: passed.Overlap. The overlap check finds no conflict with the 34 open PRs that touch these files and merge into current main. The other sixteen couldn't be checked until they merge into main again.
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)agc_driver_dispatch_data_hit_wordspasses 5 of 5 with the fix ("4 data hits resolved ahead read their own live words"), onmain66e290f1c0with this PR, #6454 and #6678 merged (the other two don't touch this path); the red is from Linux and ASan, since on Windows a freed word may keep its value; AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11: the new test passes (keravyn-ops); NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04: the new test passes, and fails withmain'sDispatch.cpp(jotitadev)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T18:44:42Z.
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/Execution/src/Driver/Dispatch/Dispatch.cppL454core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppL454core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppL248core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL3074core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppL454Some 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/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppImported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T09:59:33Z.
AMD / Windows run of this PR at
f5fd23ee3: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.Every ctest entry built from the test targets this PR changes passes (1):
agc_driver_dispatch_data_hit_words(0.44 s):369: dispatch data hit words tests passedAI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T15:09:19Z.
Review: COMMENTED
A run on NVIDIA, since the description has lavapipe and the comments add AMD on Windows.
Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged ontomain47a266cf9(clean).ANYPS5_NO_SHADER_CACHE=1,-j1 --timeout 30.agc_driver_dispatch_data_hit_words,agc_driver_pipelined_dispatch,agc_driver_pipelined_dispatch_itemagc_driver_dispatch_data_hit_words,--repeat until-fail:20Dispatch.cppfrommaindata hit 1, resolved ahead on the compute queue: its snapshots differ from the registered memory serving them (1 snapshot mismatches)^agc(650 tests)main: 649/649)main: 649/649)Not run: Windows, AMD, any title.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T15:13:35Z.
Thanks for the NVIDIA and lavapipe runs, and for the check with
main'sDispatch.cpp. I've added them to Tested and the GPU list.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T09:25:07Z.
Re-checked against current
main(after the keys-fill and host-import counter changes): the PR still merges cleanly, the new code inDispatch.cppreads only the packet and snapshot, the moves ofcaptured/liveWordsand theSnapshotStats::mismatchedcounter are untouched, and nothing reads the moved vectors afterwards.agc_driver_dispatch_data_hit_wordspins the mismatch counter, so it fails on main's copy. Relying on the NVIDIA/lavapipe and AMD/Windows runs in the thread; merged.