fix(agc): land GPU writes over guest memory before a host write into it #6926

Merged
EagleBearerYS merged 19 commits from upstream-pr/6926 into main 2026-11-08 09:11:02 +00:00
EagleBearerYS commented 2026-10-16 19:28:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T19:28:57Z.


What

A host write into guest memory doesn't wait for the GPU writes recorded or in flight over the same memory, and doesn't store the storage-image results still pending there.

  • Which writes are host writes: every write made through a GuestArena::HostWrite scope. That covers the APR read (libkernel/Apr/src/Apr.cpp:159-170), AIO, read/pread/readv, recv/recvfrom in libkernel and libSceNet, the fcntl/ioctl outputs, libc's file reads and WebKit's mkstemp.
  • What the scope does today: it never reaches the driver. On Linux it does nothing at all, since GuestWriteWatchBeginHostWrite is Apple-only.

Why that loses data: a storage image's write-back into host-imported guest memory is recorded, not made, while a recorder is active.

  • StorageTexture::writeBackLayers (Graphics/src/Texture.cpp) decides which 64 KiB blocks to keep for the CPU, records the retile and the copy into the open batch, and notes a pending write. The bytes land when that batch runs.
  • So a store recorded before a host write can land after it, over the data the host just wrote.
  • A host write that covers only part of a block over pending results loses the other way. The store keeps the whole block for the CPU, so the image's results in the rest of it never land.

Related: #6636, where the crash below was traced; #6234, the read direction (pending GPU results flushed before file writes), whose hook this one pairs with.

The title. Epic Mickey: Rebrushed (PPSA15657, UE 4.27) crashes now and then while it loads its first level. johnmaia ran it on Linux, RX 7600 (RADV, Mesa 25.2.8), on main 5d9dcc42d + #6236 with no other changes (#6636, comment):

Runs Failed before reaching the level
APS5_STORE_AT_FLIP=1 16 0
Unset, alternated 8 3
  • The three failures:
    • ObjectSerializationError on SM_MachineSet_01b (UE's "Serial size mismatch");
    • LowLevelFatalError [Line: 1609] right after the title opens /savedata0/ue4savegame.dpx.sav;
    • a SIGSEGV in the title's own code.
  • The trace behind them:
    • On main, about 2 runs in 5 crash this way. In those, a 64 KiB block of file data the title had just read is zeroed about 18 ms after the read, with no CPU write path of the driver involved (#6636, comment).
    • In a traced run, the APR read of a crashing pair landed on a block that a storage-image write-back had covered about 50 ms before it (#6636, comment).
  • How this PR fits it: APS5_STORE_AT_FLIP=1 stores pending results at every flip, which closes that window. This PR closes it at the host write itself.
  • Confirmed in the title: on that base, none of johnmaia's 12 runs with this fix failed, against 6 of 24 without it (#6636, comment; Tested below). No open issue tracks this crash. On main from 2026-10-24 the crash no longer shows without this PR either (johnmaia's follow-up); johnmaia names #8126 and #8751, merged on 10-23, as plausible changes that cover the same path.

The fix:

  • libc: GuestArenaBeginHostWrite_nid_postfix now calls a hook first, on every platform, for every non-empty range. The setter is GuestArenaSetHostWriteHook_nid_no_patch, so every HostWrite user above gets it with no change at the call site.
  • Driver: it registers GuestMemory::PrepareHostWrite in Driver::Driver and clears it in ~Driver. PrepareHostWrite calls FlushGpuWrites under ReadSiteScope(ReadSite::Store), as the driver's own guest stores (GuestMemory::Write, WriteChanged) already do. That call:
    • waits for every open or in-flight batch whose writes overlap the range;
    • stores the results still pending there;
    • waits for that store too.
  • Teardown (2ff4ed6470, from CnRJay's review): the hook is an atomic pointer (GuestArena.cpp). Driver::stop() now clears it first, before the worker joins, then sets a stopped flag and waits up to 1 s for calls already inside the hook to leave. PrepareHostWrite counts itself in flight (seq_cst) before it checks the flag and returns at once if it is set, so either a call sees the flag or stop() sees the call. The wait is bounded because on Windows ExitProcess can end a thread inside the hook before ~Driver runs; if the bound expires, stop() logs it and goes on. ~Driver still clears the hook as before.
  • The macOS import window: it opens its own HostWrite scope under the tracker lock, so it skips the hook through a thread-local guard and can't re-enter the tracker.
  • Locks: no caller holds a mutex when the hook runs.
    • libSceNet releases its g_mutex before its HostWrite.
    • DescriptorControl's lock is the guest record-lock struct, not a mutex.
    • The other sites hold nothing.
    • The GPU waits run with the GPU mutex released when the hook's acquisition is the outermost, as for any CPU access.
    • Checked (c2720073b9, from CnRJay's review): a host write made while the thread holds the GPU mutex is counted (GuestMemory::LockedHostWrites) and logged once with its thread, address and size, then goes on. With APS5_ASSERT_GPU_LOCK=1, the switch AssertGpuLockHeld already reads, it aborts with a [lock] ASSERT: line instead. It doesn't throw in a normal run: with the mutex held, the hook takes FlushForAccess's nested locked wait, which hangs only if completing needs another thread to take the GPU mutex, so a throw would turn a possible hang into a certain crash. The debt file states the rule.
  • The debt entry (docs/dev/debt/libSceAgcDriver.md) narrows main's late-store sentence (#1970) to the title's own CPU stores, which still aren't ordered after a recorded store: they survive only in the 64 KiB blocks the write watch saw written. Its CPU reads after a label still read stale memory.

Cost: the hook adds about 75-90 ns to a 64 KiB host write with nothing to wait for (82.5-97.7 ns against 6.9-7.1 ns, the test's --cost mode). That's the flush hook's fast path, well under the read() it precedes.

  • The slow path (276f67d366, from CnRJay's review): with APS5_PROFILE_DRAW=1, a [hostwrite] line every 10 s counts the host writes, those that waited for GPU work over their range, and the total and longest wait, e.g. [hostwrite] 2 host writes, 1 waited for GPU work over their range: 1.34 ms in total, 1.34 ms at most. Without the switch nothing is counted. The title's numbers aren't measured yet.

How:

  1. fix(agc): land GPU writes over guest memory before a host write into it: the hook, the driver's registration, the debt entry and the new test agc_driver_host_write_pending_storage (tests/execution/HostWritePendingStorage.cpp).
    • The setup: a compute dispatch writes a 128×120 RGBA16F, 64 KiB-tiled storage image over a 128 KiB write-watched guest surface.
    • The host write: a file is read into the surface the way libc's _readFile does it, std::ifstream::read inside a GuestArena::HostWrite scope. A later FlushGpuWrites plays the guest's read.
    • The check: the file's bytes must survive, and the image's texels must be everywhere else.
    • Its four cases:
      • a store recorded before a 64 KiB host write;
      • the same with a 4 KiB host write;
      • a 64 KiB host write over pending results;
      • a 4 KiB host write over pending results.
  2. refactor(agc): name the host write hook as a pair to the host read hook: names the setter and the driver function after #6234's host read hook (GuestArenaSetHostReadHook_nid_no_patch, PrepareHostRead). The _nid_no_patch suffix follows CONTRIBUTING.md for helper symbols that must not become NIDs.

Tested

  • Epic Mickey: Rebrushed (PPSA15657), johnmaia's runs: Linux, RX 7600 (RADV, Mesa 25.2.8), short runs to the first level, APS5_STORE_AT_FLIP unset (#6636, comment). Current main rarely shows the crash, so they ran the fix on the base where it fails:

    Tree Runs Failed before reaching the level
    main 5d9dcc42d + #6236 8 3
    the same + #6364 (unrelated to this case) 16 3
    the same + this PR's first two commits (99af947b18, 082c3268ac) 12 0
    main e751dd205 8 0
    • All 12 runs with the fix reached the level and played to the end of the run. None showed the ObjectSerializationError, the LowLevelFatalError [Line: 1609] or the SIGSEGV.
    • The title's log line: in a traced run with the fix (APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1), 23 APR reads were each followed at once by the hook storing a pending image over their destination, before the read's bytes were written:
      [apr] read …/recolored-ps5.ucas offset=0x10a89ca0 size=0x41338 -> 0x204c540000
      [flush] image 0x204c540000+0x60000 for memory access 0x204c540000+0x41338
      
    • They ran the first two commits. The three after them (the teardown, the lock check and the counters) keep the same flush: PrepareHostWrite still calls FlushGpuWrites over the written range.
  • Alone in the Dark (PPSA08240, v1.00), LeoFeitosa's runs (comment): Windows 11 (26200), RTX 5070 Ti (driver 617.42), WinLibs GCC 15.2.0, Release.

    • Both sides were built from the same tree, with the same shader cache and save state. Every run sets APS5_PLAYGO_UNLISTED_CHUNKS=installed, and has no input until the main menu.
    • Six alternating pairs, each from launch to the main menu or the crash:
    Tree Runs Reached the main menu
    main cd700fe9e 6 1
    this PR (2c5b77231) 6 5
    main + APS5_STORE_AT_FLIP=1 3 3
    • The crashes on main, all while loading:
      • 2 × LowLevelFatalError [Line: 3230], "Serial size mismatch" on UI textures;
      • 1 × 0xc000001d on FAsyncLoadingThread;
      • 2 × 0xc0000005 at Alone in the Dark.exe+0x20ec0bc.
    • The one crash with this PR is the last kind, 0xc0000005 at +0x20ec0bc. Whether it shares the cause isn't traced.
    • Eight more runs with this PR under APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1 all reached the main menu, so this PR (2c5b77231; the head since only merges main) has reached it in 13 of 14 runs (comment). The tracing changes the timing, so those eight runs don't rule the remaining crash out.
  • Linux (lavapipe, Mesa 25.2.8, gcc 13.3, CI's Linux configure), on main 66e290f1c0. Each check ran in all three write-watch modes: userfaultfd user-mode only (unprivileged), full userfaultfd (root), and unwatched (APS5_NO_WRITE_WATCH=1).

    • Red (only the driver's registration reverted, so libc calls nothing, as on main): 0/20 in each mode. Every run fails the same three cases:
      host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
      host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
      host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed
      
      The recorded store zeroes the file's bytes, which is the zeroed block of the title's trace. The case of a whole-block host write over pending results already passes on main.
    • Green: 20/20 in each mode, at both commits.
    • ctest -R '^agc' --parallel 4 --timeout 120: 625/625 at the head, 43 skipped as expected.
    • ctest -R 'guest|libc|kernel': the same as main on that machine. The 5 failures are IPv6 tests the container always fails.
  • GitHub runners (run 38952984815), with only the registration reverted for the red:

    • Linux: red, the test failed in each of 5 runs; green 20/20. The libc and libkernel suites pass both ways.
    • Windows: it builds with MinGW, but the test skips on that runner, which has no Vulkan device. guest_kqueue fails there with and without the change.
  • Merged with #6234 (0f5651f0fb) and with #6184 (4a9640677f), each on its own, on lavapipe. The new test passes 10/10 on both merges.

    • On the #6234 merge, #6234's agc_driver_storage_file_write passes 10/10 and ^agc 626/626.
    • On the #6184 merge, agc_driver_graphics passes 10/10 and ^agc 624/625. The one failure is agc_driver_preparation_scope_settle, which passes 5/5 alone.
  • Windows code: MinGW -fsyntax-only of GuestMemory.cpp, Lifecycle.cpp, GuestArena.cpp and the test: 0 errors.

  • The review follow-ups (Linux, lavapipe, CI's configuration), each with its case in the new agc_driver_host_write_hook, in the same commit as its change:

    • Teardown: after Driver::Shutdown, a host write over a range with a recorded store must not reach the driver's flush hook. Red at the previous head: "a host write over a range with a recorded store reached the driver's flush hook 1 time(s) after Driver::Shutdown".
    • The lock check: a host write made while holding the GPU mutex returns and moves the count by one. Red on a base with only the counter's accessor: "the count moved by 0, not 1". With APS5_ASSERT_GPU_LOCK=1 the test aborts at the [lock] ASSERT: line, as intended.
    • The counters: a host write over a recorded store counts one call that waited; one over an idle surface counts a call that didn't.
    • agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass 20/20 in each of the three write-watch modes, and ^agc passes 626/626.
    • GitHub runners (run, with #6452's MinGW fix for an unrelated test applied for this check only): on Linux both tests pass 10/10; on Windows they skip without a Vulkan device and the build is clean. The ^agc sweeps' only failures are agc_driver_preparation_scope_settle on Linux, a timing check under parallel load, and agc_driver_pm4_replay_tool (0xc0000139) on Windows, which fails on main there too.
  • AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11 (WinLibs GCC 15.2.0, Release), run by keravyn-ops at 276f67d36 (comment): agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass.

  • NVIDIA GeForce RTX 3080 (NVIDIA 617.42), Windows 10 Pro 22H2 (WinLibs GCC 15.2.0, Release), run by TheSovietWaffle at 276f67d36 (comment): agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass 5 of 5 runs each, and the 12 guest_socket_host_write_* tests, which go through the changed GuestArena host-write path, pass.

  • NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 (GCC 15.2, Release), run by jotitadev at 276f67d36 merged onto main 12a71f3f5 (review): both new tests pass, 3/3 on the 3070. ^agc has no new failures against main: 636 of 638 on the 3070, where agc_driver_f16_fma_denormal_modes and agc_driver_fma_mix_f16_denormal_modes fail on main too, and 638 of 638 on lavapipe. With only the hook's registration in Driver::Driver removed, the same three cases fail on both devices as in the red above, and the whole-block case passes.

  • Merged with main cd700fe9e and 86b84244fb (2c5b772311, then 9f5745d7dd, the head). Each conflicted only in the debt file, where both sides' entries are kept. On GitHub's runners at the head (run), agc_driver_host_write_pending_storage, agc_driver_host_write_hook, agc_driver_storage_file_write and agc_driver_graphics pass 3 runs in a row on Linux. On Windows three of the four skip without Vulkan and agc_driver_graphics passes. The libc and libkernel suites pass on both.

  • Merged with main 0d078f75d3 (46d8f39271, no conflicts), on GitHub's runners (run): in one run on Linux the ^agc tests pass, 711 tests: 662 pass, 49 skip, 0 fail. The libc and libkernel suites pass on both runners. On Windows, of 711 ^agc tests 173 pass and 536 skip, since the runner has no Vulkan device; the only failures are agc_driver_pm4_replay_tool and agc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).

  • Merged with main 5949d8bf92 and 5d48c6233e (3080b8f66f, then b7794a5f1c, the head; run). main's #9685 excepts drawn resident linear targets from the pending storage-image results debt entry this PR rewrites, and adds two entries after it; the merge keeps main's opening, this PR's text, main's two entries, then this PR's host-write entry. main's #10369 opens a watched import's host-write window only when the import may write guest memory; the merge keeps this PR's OwnHostWrite mark, then main's optional window. The agc_driver_host_write_ and agc_driver_linear_target_ tests, agc_driver_address_passes_draw_transitions, agc_driver_graphics, agc_driver_preparation_scope_settle, agc_driver_storage_file_write, guest_kqueue and public_headers pass 10 runs in a row. Linux: 18 run, 17 pass, 1 skip (agc_driver_linear_target_direct_write_completion), 0 fail. Windows: 18 run, 3 pass, 15 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

  • LEGO Horizon Adventures (PPSA14632), run by winstrex (comment): Windows 11, NVIDIA GeForce RTX 5070 Ti (NVIDIA 591.86), warm shader cache, the same input script each run.

    • With this PR, the [hostwrite] line shows host writes landing on pending GPU work over their range in every run (4 to 60 per run).
    • The FAsyncLoadingThread crash with ObjectSerializationError ... Serial size mismatch after the graphics quality screen came in 2 of 2 runs on main 7ce3b1df3, 1 of 6 on this PR's base 86b84244f and 0 of 7 with this PR (9f5745d7d). winstrex calls that not conclusive at these counts.
    • One of the 7 runs with this PR crashed later with a different corruption (UObjectHash.cpp line 42).
  • Epic Mickey: Rebrushed (PPSA15657) on newer main, johnmaia's follow-up (comment): the same setup (i3-12100, RX 7600, RADV), where a run fails on ObjectSerializationError / Serial size mismatch, LowLevelFatalError or a crash before the level.

    • main 5d9dcc42d, earlier runs: 5 of 8 reach the level cleanly.
    • main 933c0e4f1 / bfb080619 (10-24), without this PR: 5 of 5.
    • main bfb080619 with #8091 and #10304, at about 7 fps in the level, the speed where the old failure showed: 14 of 14. johnmaia puts the chance of 14 clean runs at about 0.1 % if the old 3 of 8 still held.
    • So on current main this crash no longer shows a failure this PR fixes. The Alone in the Dark (cd700fe9e) and LEGO Horizon Adventures (7ce3b1df3) runs above were also on main from before #8126 and #8751.
  • Alone in the Dark (PPSA08240) on current main, LeoFeitosa's rerun (comment): main b1f023dda3 (10-25) without this PR, the same harness (Windows 11 26200, RTX 5070 Ti, driver 617.42, APS5_PLAYGO_UNLISTED_CHUNKS=installed, the exe and .guest.prx relinked with this build's relinker).

    • 3 of 6 runs fail: one closes before the menu on LowLevelFatalError [Line: 3230] "Serial size mismatch" on a loading-screen texture, and two crash in the async loader right after the menu (0xc0000005 on FAsyncLoadingThread, and LowLevelFatalError [Line: 197] allocating 34043592704 bytes).
    • So this title still fails on current main, unlike Epic Mickey.
    • With this PR (b7794a5f1c merged cleanly onto the same b1f023dda3, the same harness and machine, the installed libSceAgcDriver.prx checked against the package), 6 of 6 runs reach the main menu with no fatal error (menu at 260, 90, 90, 90, 90 and 90 s) (comment).
  • LEGO Horizon Adventures (PPSA14632) on current main, winstrex's pair (comment): Windows 11 (26300), RTX 5070 Ti (driver 621.01). On main abed035468 all 12 runs, with and without this PR, stopped 19 to 40 s in on the refusal from #11425 (a compute shader reading or writing a converted float image with 16-bit data), so both sides had #11580 merged, which fixes it. 240 s per run, alternating, with the saves and a warm shader cache restored before each run.

    • main abed035468 + #11580: 6 of 6 reached the load after the graphics quality screen, with no Serial size mismatch or FAsyncLoadingThread crash.
    • The same + this PR (bc288ffa6d): 5 of 6, with no loader crash; the sixth stopped on VK_ERROR_DEVICE_LOST at 81 s, which winstrex also saw once without this PR, in a warm-up run that isn't counted.
    • Neither side hit the loader crash, so this pair doesn't reproduce in this title what this PR fixes, and it isn't conclusive either way.
  • tools/check_conventions.py: passed.

Overlap. On main 1b1f8483ca, the overlap check finds three open PRs that conflict with this one. 37 others that touch the same files conflict with main themselves, so they couldn't be checked.

  • #6234 (Ondra97) adds the read direction: pending GPU results are flushed before file writes, through a host read hook next to this one.
    • Merging the two gives three conflicts: adjacent additions in GuestArena.hpp and GuestArena.cpp, and the debt entry, which both PRs rewrite. Each resolves by keeping both sides.
    • The two hooks never run for the same call. #6234's runs where the host reads guest memory, this one where the host writes it.
    • Both end in the same FlushGpuWrites.
  • #6184 (MarcZX100) adds an access observer for protection changes, commits and maps.
    • It conflicts in one place, where both setters follow GuestArenaWriteWatched_nid_postfix.
    • Its observer never runs in GuestArenaBeginHostWrite, so the two compose independently.
  • #6641 (ours) edits neighbouring lines of Execution/src/Driver/Lifecycle.cpp. Whichever lands second takes a one-line merge.
  • Stray (PPSA02100) on Windows, by @dantdmdarealguy (comment): Windows 11 Pro, i9-14900K, RTX 5080 (617.42), main 32b7331c44 and main with b7794a5f1c merged (clean), the same app.exe, save state and pad script, runs alternated, 125 s from launch through the New Game load, 6 runs each. On main, 4 stop at the #7048 refusal at about 20 s, 1 on an access violation before the menu, and the one that reached the New Game load crashed there (Serial size mismatch). With this PR, 2 are clean, 2 stop at the #7048 refusal and 1 on an access violation before the menu; of the 3 that reached the load, 1 crashed there (an FAsyncLoadingThread access violation). So the loader crash still occurred once with this PR. He notes that the rate drifts a lot with the state of the machine, so counts this small are only indicative.
  • ASTRONEER (PPSA27623), by @JJenkx (comment): Linux, AMD Radeon RX 6650 XT (RADV, Mesa 26.2.6), Release, APS5_PLAYGO_UNLISTED_CHUNKS=installed, 60 s from boot. The title sometimes crashes during its first load, with a UE4 "Serial size mismatch" LowLevelFatalError or a SIGSEGV in package loading. JJenkx traced it with local read diagnostics that aren't in any PR. The file reads match the pak, but the failing exports are read into memory that held one of the title's colour targets about a second earlier, and the driver's idle store then writes that target's drawn rectangle over the file data (5.6 ms after the read, in the logged crash). This PR's host-write hook stores the pending target before the read.
    • With the diagnostics on, arms interleaved in blocks of 4: main 1e24993fa3 crashed in 5 of 12 runs, and main with this PR at 75ffc81473 in 0 of 12 (one-sided Fisher p ≈ 0.019). The write-backs over the failing buffers within 300 ms of each read were 47 idle stores on main, 26 of them after the read, and with this PR 4 stores by its hook before the read, 1 idle store and none after.
    • Without the diagnostics, earlier series on main crashed in about 1 run in 5, but in this paired series both arms ran 0 of 12, so those runs say nothing either way.
    • JJenkx's #16011 fixes a separate idle-store ordering race found on the way. With the diagnostics, 3 of its 12 runs still crashed.
  • bc288ffa6d, a merge of main 263eee0a77 (run). thuanquang's #9879 adds a "Linear color targets" entry to docs/dev/debt/libSceAgcDriver.md where this PR adds its "Host writes into guest memory" entry; the merge keeps both, and this PR's changed lines are the same. agc_driver_host_write_hook and agc_driver_host_write_pending_storage, with the tests for the files the merge changes, pass 10 runs in a row. Linux: 326 run, 316 pass, 10 skip (seven AGC tests on lavapipe and three video-out tests with no display or Vulkan device), 0 fail. Windows: 344 run, 256 pass, 88 skip (85 AGC tests, this PR's two among them, and the same three video-out tests, no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (145 and 212) and on Windows (174 and 233). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • d0b755a486, a merge of main facac6a4c5 (run). The one conflict was the include block of GuestMemory.cpp, where main now has the <thread> include this PR added and adds <system_error> next to it; the merge keeps main's lines, and this PR's other changed lines are the same. agc_driver_host_write_pending_storage, agc_driver_host_write_hook, agc_driver_graphics, agc_driver_linear_target_direct_write_completion, agc_driver_preparation_scope_settle and agc_driver_storage_file_write ran 10 times in a row with no failure. Linux: 6 run, 5 pass, 1 skip, 0 fail. Windows: 6 run, 1 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194), and libkernel has 4 failures of 286. guest_raise_exception aborted with 0xc0000409 after "address waking round 37: the handler did not run within 5 s". Run again on this commit (run) it aborted the same way at round 7, and so did main 9fc181dde5 in the same verify setup (run, round 5). That is #11813, which traces it to #10666 on main; this PR doesn't touch libkernel. The other three, exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web, fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), and pass in main's own Windows job at 1829def9bf (job). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 11cd12b90b, a merge of main ba627802e2 (run, validation run).
    • The conflict: only docs/dev/debt/libSceAgcDriver.md. Gonic0's #13499 (label read traps, macOS) adds a "Label read traps" entry right after the "Pending storage-image results" entry this PR rewrites, and #13678 has since changed it. The merge keeps this PR's Pending entry, then main's Label read traps entry, each unchanged. The other files merged on their own, and this PR's diff against main is the same as before in every file.
    • #13499's traps and this PR's store-and-wait (read at a merge with main e67cc81869, result): GuestArenaBeginHostWrite calls this PR's host-write hook first, which stores a trapped image whole and releases its trap. Only then does the write watch's BeginHostWrite resolve any trap left on the range and open the pages. On Linux every trap path is under #if defined(__APPLE__), so only this PR's path is compiled there.
    • ×10 on GitHub's runners: this PR's agc_driver_host_write_pending_storage and agc_driver_host_write_hook, with agc_driver_graphics, agc_driver_linear_readback_label_off, agc_driver_linear_target_direct_write_completion, agc_driver_preparation_scope_settle, agc_driver_storage_file_write and agc_recorder_completion_labels. Linux: 8 run, 7 pass, 1 skip, 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 208 and 308 tests on Linux and 235 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Validation (VERIFY_VALIDATION=1 on GitHub's Linux runner, main against this head, the same tests where main has them): both pass. The loader inserted VK_LAYER_KHRONOS_validation 9 times on main and 13 with this head, and neither log has was not found. Both report only VUID-VkDeviceCreateInfo-pNext-pNext, so the change adds none.
  • 3c3c2ca24a, the Pending storage-image results entry cut to the gap still open, for fogydes' review. This PR's rewrite of the entry had grown it from main's 985 characters to 1,396, over check_conventions.py's 1,000-character warning, and described the new ordering. It's now main's entry with only the late-store sentence narrowed to a title's own CPU stores, 993 characters. Docs only: check_conventions.py --base ba627802e2 passes with no warnings.
  • 59a6f5e41e, a merge of main 3c3b3cda73 (run). The one conflict was in docs/dev/debt/libSceAgcDriver.md: this PR's narrowed "Pending storage-image results" entry and its "Host writes into guest memory" entry sit beside main's new active-recorder entry and two write-watch entries, and the merge keeps all of them. This PR's diff over main is unchanged. This PR's agc_driver_host_write_pending_storage and agc_driver_host_write_hook, with agc_driver_graphics, agc_driver_linear_readback_label_off, agc_driver_linear_target_direct_write_completion, agc_driver_preparation_scope_settle, agc_driver_storage_file_write and agc_recorder_completion_labels, ran 10 times with no failure. Linux: 8 run, 7 pass, 1 skip (agc_driver_linear_target_direct_write_completion), 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 75ffc81473, a merge of main b611e634f7 (×10, every agc test), which brings mrfelek's #15783 (moved read-only draw inputs kept within the draw snapshot cap).
    • The conflict: one, in docs/dev/debt/libSceAgcDriver.md, where #15783 extends the "Draw input snapshots" entry next to this PR's narrowed "Pending storage-image results" entry. The merge keeps both. The code merged without conflicts, GuestMemory.cpp and GuestArena.cpp included, which main changed since 3c3b3cda73. This PR's diff over main is unchanged.
    • ×10: agc_driver_host_write_pending_storage and agc_driver_host_write_hook, with agc_driver_graphics, agc_driver_linear_readback_label_off, agc_driver_linear_target_direct_write_completion, agc_driver_preparation_scope_settle, agc_driver_storage_file_write and agc_recorder_completion_labels. Linux: 8 run, 7 pass, 1 skip (agc_driver_linear_target_direct_write_completion), 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail.
    • Suites: libc passes on Linux (303) and on Windows (335), and libkernel on Windows (360). On Linux, libkernel ran 329 tests and guest_kernel_stack_protect failed once (GuestKernelStackProtect failed at line 276, the mprotect of the test's own host pages). This PR changes no libkernel code, and in the agc run the same head's libkernel suite passed all 329. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Every agc test, once: Linux: 1,334 run, 1,247 pass, 85 skip, 2 fail. Windows: 1,373 run, 411 pass, 962 skip (no Vulkan device), 0 fail. Both failures are main's:
      • agc_driver_image_gather_volume ("the vertex shader was not emitted in the device's module form") fails the same way in main's own linux check on 638187daec, the #15855 merge (job). JJenkx's #15875, merged after b611e634f7, updates the test for the specialized vertex form #14265 emits.
      • agc_driver_pipeline_journal's 120-second timeout (778/1334 Test #1431: agc_driver_pipeline_journal ***Timeout 120.06 sec), main's own cold run.
    • AMD Radeon RX 6300 (RADV NAVI24) at this head, from TechLevelZero's AMD bot (report): merged onto main b611e63, Mesa 25.2.8, Ubuntu 26.04.1, 3,899 of 3,946 tests selected. 3,819 passed, 18 failed and 62 skipped. None of the failures is new: 13 also fail on main, and 5 are unstable on main. With VK_LAYER_KHRONOS_validation, there are no new validation IDs against main, over 1,391 tests on the GPU.
    • NVIDIA RTX 2000 Ada Generation at this head, from TechLevelZero's NVIDIA bot (report): merged onto main acac7c8, driver 595.99.02, Ubuntu 26.04.1, 3,913 of 3,960 tests selected. 3,848 passed, 6 failed and 59 skipped. None of the failures is new: 2 also fail on main, and 4 are unstable on main. With VK_LAYER_KHRONOS_validation, there are no new validation IDs against main, over 1,399 tests on the GPU.
    • @BunnyFl's re-review (review, approved; their first approval was at 59a6f5e41e): git range-diff from 59a6f5e41e shows this PR's six commits unchanged. On this head merged onto main 78e4248fea, Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32015.12012), WinLibs GCC 15.2.0, Release, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and the validation layer: agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass, 2 of 2, the hook's GPU path ran ([hostwrite] 2 host writes, 1 waited for GPU work over their range), and there's no VUID- message.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Related: #6636, #6234, #8746 (ASTRONEER (PPSA27623)'s discussion)
  • Unblocks: Alone in the Dark (PPSA08240), its crashes while loading to the main menu, which still happen on current main (LeoFeitosa: on main b1f023dda3, the main menu with no fatal error in 3 of 6 runs without this PR and 6 of 6 with it; earlier, 13 of 14 runs with this PR and 1 of 6 on main cd700fe9e). It has no Game bring-up discussion yet. Epic Mickey: Rebrushed (PPSA15657, #2255) was the first title: its first-level load crash from #6636's thread, on main 5d9dcc42d (johnmaia: 0 of 12 runs failed with the fix, 6 of 24 without), no longer reproduces on main from 10-24 without this PR.
  • GPUs tested: lavapipe (Mesa 25.2.8) on Linux; johnmaia's RX 7600 (RADV, Mesa 25.2.8) in the title; NVIDIA GeForce RTX 5070 Ti (617.42), Windows 11, in Alone in the Dark (LeoFeitosa); AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11: both new tests pass (keravyn-ops); NVIDIA GeForce RTX 3080 (NVIDIA 617.42), Windows 10: both new tests pass 5 of 5 (TheSovietWaffle); NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04: both new tests pass (jotitadev); NVIDIA GeForce RTX 5070 Ti (NVIDIA 591.86), Windows 11, in LEGO Horizon Adventures (winstrex); AMD Radeon RX 9070 XT (driver 32.0.32015.12012), Windows 11: both new tests pass (BunnyFl); AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8) and NVIDIA RTX 2000 Ada Generation (driver 595.99.02), Ubuntu 26.04.1 (TechLevelZero's bots); AMD Radeon RX 6650 XT (RADV, Mesa 26.2.6), Linux, in ASTRONEER (JJenkx); the Windows runner has no Vulkan device
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4893272506 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-16T19:28:57Z. --- ### What A host write into guest memory doesn't wait for the GPU writes recorded or in flight over the same memory, and doesn't store the storage-image results still pending there. - **Which writes are host writes:** every write made through a `GuestArena::HostWrite` scope. That covers the APR read (`libkernel/Apr/src/Apr.cpp:159-170`), AIO, `read`/`pread`/`readv`, `recv`/`recvfrom` in libkernel and libSceNet, the `fcntl`/`ioctl` outputs, libc's file reads and WebKit's `mkstemp`. - **What the scope does today:** it never reaches the driver. On Linux it does nothing at all, since `GuestWriteWatchBeginHostWrite` is Apple-only. **Why that loses data:** a storage image's write-back into host-imported guest memory is recorded, not made, while a recorder is active. - `StorageTexture::writeBackLayers` (`Graphics/src/Texture.cpp`) decides which 64 KiB blocks to keep for the CPU, records the retile and the copy into the open batch, and notes a pending write. The bytes land when that batch runs. - So a store recorded before a host write can land after it, over the data the host just wrote. - A host write that covers only part of a block over pending results loses the other way. The store keeps the whole block for the CPU, so the image's results in the rest of it never land. **Related:** #6636, where the crash below was traced; #6234, the read direction (pending GPU results flushed before file writes), whose hook this one pairs with. **The title.** Epic Mickey: Rebrushed (PPSA15657, UE 4.27) crashes now and then while it loads its first level. johnmaia ran it on Linux, RX 7600 (RADV, Mesa 25.2.8), on `main` 5d9dcc42d + #6236 with no other changes ([#6636, comment](https://github.com/boykopovar/AnyPS5/pull/6636#issuecomment-6221124027)): | | Runs | Failed before reaching the level | |---|---|---| | `APS5_STORE_AT_FLIP=1` | 16 | 0 | | Unset, alternated | 8 | 3 | - **The three failures:** - `ObjectSerializationError` on `SM_MachineSet_01b` (UE's "Serial size mismatch"); - `LowLevelFatalError [Line: 1609]` right after the title opens `/savedata0/ue4savegame.dpx.sav`; - a SIGSEGV in the title's own code. - **The trace behind them:** - On `main`, about 2 runs in 5 crash this way. In those, a 64 KiB block of file data the title had just read is zeroed about 18 ms after the read, with no CPU write path of the driver involved ([#6636, comment](https://github.com/boykopovar/AnyPS5/pull/6636#issuecomment-6206905584)). - In a traced run, the APR read of a crashing pair landed on a block that a storage-image write-back had covered about 50 ms before it ([#6636, comment](https://github.com/boykopovar/AnyPS5/pull/6636#issuecomment-6221124027)). - **How this PR fits it:** `APS5_STORE_AT_FLIP=1` stores pending results at every flip, which closes that window. This PR closes it at the host write itself. - **Confirmed in the title:** on that base, none of johnmaia's 12 runs with this fix failed, against 6 of 24 without it ([#6636, comment](https://github.com/boykopovar/AnyPS5/pull/6636#issuecomment-6228678047); Tested below). No open issue tracks this crash. On `main` from 2026-10-24 the crash no longer shows without this PR either ([johnmaia's follow-up](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6406110608)); johnmaia names #8126 and #8751, merged on 10-23, as plausible changes that cover the same path. **The fix:** - **libc:** `GuestArenaBeginHostWrite_nid_postfix` now calls a hook first, on every platform, for every non-empty range. The setter is `GuestArenaSetHostWriteHook_nid_no_patch`, so every `HostWrite` user above gets it with no change at the call site. - **Driver:** it registers `GuestMemory::PrepareHostWrite` in `Driver::Driver` and clears it in `~Driver`. `PrepareHostWrite` calls `FlushGpuWrites` under `ReadSiteScope(ReadSite::Store)`, as the driver's own guest stores (`GuestMemory::Write`, `WriteChanged`) already do. That call: - waits for every open or in-flight batch whose writes overlap the range; - stores the results still pending there; - waits for that store too. - **Teardown (2ff4ed6470, from CnRJay's review):** the hook is an atomic pointer (`GuestArena.cpp`). `Driver::stop()` now clears it first, before the worker joins, then sets a stopped flag and waits up to 1 s for calls already inside the hook to leave. `PrepareHostWrite` counts itself in flight (seq_cst) before it checks the flag and returns at once if it is set, so either a call sees the flag or `stop()` sees the call. The wait is bounded because on Windows `ExitProcess` can end a thread inside the hook before `~Driver` runs; if the bound expires, `stop()` logs it and goes on. `~Driver` still clears the hook as before. - **The macOS import window:** it opens its own `HostWrite` scope under the tracker lock, so it skips the hook through a thread-local guard and can't re-enter the tracker. - **Locks:** no caller holds a mutex when the hook runs. - libSceNet releases its `g_mutex` before its `HostWrite`. - `DescriptorControl`'s `lock` is the guest record-lock struct, not a mutex. - The other sites hold nothing. - The GPU waits run with the GPU mutex released when the hook's acquisition is the outermost, as for any CPU access. - **Checked (c2720073b9, from CnRJay's review):** a host write made while the thread holds the GPU mutex is counted (`GuestMemory::LockedHostWrites`) and logged once with its thread, address and size, then goes on. With `APS5_ASSERT_GPU_LOCK=1`, the switch `AssertGpuLockHeld` already reads, it aborts with a `[lock] ASSERT:` line instead. It doesn't throw in a normal run: with the mutex held, the hook takes `FlushForAccess`'s nested locked wait, which hangs only if completing needs another thread to take the GPU mutex, so a throw would turn a possible hang into a certain crash. The debt file states the rule. - **The debt entry** (`docs/dev/debt/libSceAgcDriver.md`) narrows `main`'s late-store sentence (#1970) to the title's own CPU stores, which still aren't ordered after a recorded store: they survive only in the 64 KiB blocks the write watch saw written. Its CPU reads after a label still read stale memory. **Cost:** the hook adds about 75-90 ns to a 64 KiB host write with nothing to wait for (82.5-97.7 ns against 6.9-7.1 ns, the test's `--cost` mode). That's the flush hook's fast path, well under the `read()` it precedes. - **The slow path (276f67d366, from CnRJay's review):** with `APS5_PROFILE_DRAW=1`, a `[hostwrite]` line every 10 s counts the host writes, those that waited for GPU work over their range, and the total and longest wait, e.g. `[hostwrite] 2 host writes, 1 waited for GPU work over their range: 1.34 ms in total, 1.34 ms at most`. Without the switch nothing is counted. The title's numbers aren't measured yet. **How:** 1. `fix(agc): land GPU writes over guest memory before a host write into it`: the hook, the driver's registration, the debt entry and the new test `agc_driver_host_write_pending_storage` (`tests/execution/HostWritePendingStorage.cpp`). - **The setup:** a compute dispatch writes a 128×120 RGBA16F, 64 KiB-tiled storage image over a 128 KiB write-watched guest surface. - **The host write:** a file is read into the surface the way libc's `_readFile` does it, `std::ifstream::read` inside a `GuestArena::HostWrite` scope. A later `FlushGpuWrites` plays the guest's read. - **The check:** the file's bytes must survive, and the image's texels must be everywhere else. - **Its four cases:** - a store recorded before a 64 KiB host write; - the same with a 4 KiB host write; - a 64 KiB host write over pending results; - a 4 KiB host write over pending results. 2. `refactor(agc): name the host write hook as a pair to the host read hook`: names the setter and the driver function after #6234's host read hook (`GuestArenaSetHostReadHook_nid_no_patch`, `PrepareHostRead`). The `_nid_no_patch` suffix follows CONTRIBUTING.md for helper symbols that must not become NIDs. ### Tested - **Epic Mickey: Rebrushed (PPSA15657)**, johnmaia's runs: Linux, RX 7600 (RADV, Mesa 25.2.8), short runs to the first level, `APS5_STORE_AT_FLIP` unset ([#6636, comment](https://github.com/boykopovar/AnyPS5/pull/6636#issuecomment-6228678047)). Current `main` rarely shows the crash, so they ran the fix on the base where it fails: | Tree | Runs | Failed before reaching the level | |---|---|---| | `main` 5d9dcc42d + #6236 | 8 | 3 | | the same + #6364 (unrelated to this case) | 16 | 3 | | the same + this PR's first two commits (99af947b18, 082c3268ac) | 12 | **0** | | `main` e751dd205 | 8 | 0 | - All 12 runs with the fix reached the level and played to the end of the run. None showed the `ObjectSerializationError`, the `LowLevelFatalError [Line: 1609]` or the SIGSEGV. - **The title's log line:** in a traced run with the fix (`APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1`), 23 APR reads were each followed at once by the hook storing a pending image over their destination, before the read's bytes were written: ``` [apr] read …/recolored-ps5.ucas offset=0x10a89ca0 size=0x41338 -> 0x204c540000 [flush] image 0x204c540000+0x60000 for memory access 0x204c540000+0x41338 ``` - They ran the first two commits. The three after them (the teardown, the lock check and the counters) keep the same flush: `PrepareHostWrite` still calls `FlushGpuWrites` over the written range. - **Alone in the Dark (PPSA08240, v1.00)**, LeoFeitosa's runs ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6310292794)): Windows 11 (26200), RTX 5070 Ti (driver 617.42), WinLibs GCC 15.2.0, Release. - Both sides were built from the same tree, with the same shader cache and save state. Every run sets `APS5_PLAYGO_UNLISTED_CHUNKS=installed`, and has no input until the main menu. - Six alternating pairs, each from launch to the main menu or the crash: | Tree | Runs | Reached the main menu | |---|---|---| | `main` cd700fe9e | 6 | 1 | | this PR (2c5b77231) | 6 | **5** | | `main` + `APS5_STORE_AT_FLIP=1` | 3 | 3 | - The crashes on `main`, all while loading: - 2 × `LowLevelFatalError [Line: 3230]`, "Serial size mismatch" on UI textures; - 1 × `0xc000001d` on `FAsyncLoadingThread`; - 2 × `0xc0000005` at `Alone in the Dark.exe+0x20ec0bc`. - The one crash with this PR is the last kind, `0xc0000005` at `+0x20ec0bc`. Whether it shares the cause isn't traced. - Eight more runs with this PR under `APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1` all reached the main menu, so this PR (2c5b77231; the head since only merges `main`) has reached it in 13 of 14 runs ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6312086321)). The tracing changes the timing, so those eight runs don't rule the remaining crash out. - **Linux** (lavapipe, Mesa 25.2.8, gcc 13.3, CI's Linux configure), on main 66e290f1c0. Each check ran in all three write-watch modes: userfaultfd user-mode only (unprivileged), full userfaultfd (root), and unwatched (`APS5_NO_WRITE_WATCH=1`). - **Red** (only the driver's registration reverted, so libc calls nothing, as on main): **0/20** in each mode. Every run fails the same three cases: ``` host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed ``` The recorded store zeroes the file's bytes, which is the zeroed block of the title's trace. The case of a whole-block host write over pending results already passes on main. - **Green:** **20/20** in each mode, at both commits. - `ctest -R '^agc' --parallel 4 --timeout 120`: 625/625 at the head, 43 skipped as expected. - `ctest -R 'guest|libc|kernel'`: the same as main on that machine. The 5 failures are IPv6 tests the container always fails. - **GitHub runners** ([run 38952984815](https://github.com/EagleBearerYS/AnyPS5/actions/runs/38952984815)), with only the registration reverted for the red: - **Linux:** red, the test failed in each of 5 runs; green 20/20. The libc and libkernel suites pass both ways. - **Windows:** it builds with MinGW, but the test skips on that runner, which has no Vulkan device. `guest_kqueue` fails there with and without the change. - **Merged with #6234** (0f5651f0fb) **and with #6184** (4a9640677f), each on its own, on lavapipe. The new test passes 10/10 on both merges. - On the #6234 merge, #6234's `agc_driver_storage_file_write` passes 10/10 and `^agc` 626/626. - On the #6184 merge, `agc_driver_graphics` passes 10/10 and `^agc` 624/625. The one failure is `agc_driver_preparation_scope_settle`, which passes 5/5 alone. - **Windows code:** MinGW `-fsyntax-only` of `GuestMemory.cpp`, `Lifecycle.cpp`, `GuestArena.cpp` and the test: 0 errors. - **The review follow-ups** (Linux, lavapipe, CI's configuration), each with its case in the new `agc_driver_host_write_hook`, in the same commit as its change: - **Teardown:** after `Driver::Shutdown`, a host write over a range with a recorded store must not reach the driver's flush hook. Red at the previous head: "a host write over a range with a recorded store reached the driver's flush hook 1 time(s) after Driver::Shutdown". - **The lock check:** a host write made while holding the GPU mutex returns and moves the count by one. Red on a base with only the counter's accessor: "the count moved by 0, not 1". With `APS5_ASSERT_GPU_LOCK=1` the test aborts at the `[lock] ASSERT:` line, as intended. - **The counters:** a host write over a recorded store counts one call that waited; one over an idle surface counts a call that didn't. - `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass 20/20 in each of the three write-watch modes, and `^agc` passes 626/626. - **GitHub runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/38980677558), with #6452's MinGW fix for an unrelated test applied for this check only): on Linux both tests pass 10/10; on Windows they skip without a Vulkan device and the build is clean. The `^agc` sweeps' only failures are `agc_driver_preparation_scope_settle` on Linux, a timing check under parallel load, and `agc_driver_pm4_replay_tool` (0xc0000139) on Windows, which fails on `main` there too. - **AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11** (WinLibs GCC 15.2.0, Release), run by keravyn-ops at 276f67d36 ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6232562536)): `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass. - **NVIDIA GeForce RTX 3080 (NVIDIA 617.42), Windows 10 Pro 22H2** (WinLibs GCC 15.2.0, Release), run by TheSovietWaffle at 276f67d36 ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6233421326)): `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass 5 of 5 runs each, and the 12 `guest_socket_host_write_*` tests, which go through the changed `GuestArena` host-write path, pass. - **NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04** (GCC 15.2, Release), run by jotitadev at 276f67d36 merged onto `main` 12a71f3f5 ([review](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5557981443)): both new tests pass, 3/3 on the 3070. `^agc` has no new failures against `main`: 636 of 638 on the 3070, where `agc_driver_f16_fma_denormal_modes` and `agc_driver_fma_mix_f16_denormal_modes` fail on `main` too, and 638 of 638 on lavapipe. With only the hook's registration in `Driver::Driver` removed, the same three cases fail on both devices as in the red above, and the whole-block case passes. - **Merged with `main` cd700fe9e and 86b84244fb** (2c5b772311, then 9f5745d7dd, the head). Each conflicted only in the debt file, where both sides' entries are kept. On GitHub's runners at the head ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39561419378)), `agc_driver_host_write_pending_storage`, `agc_driver_host_write_hook`, `agc_driver_storage_file_write` and `agc_driver_graphics` pass 3 runs in a row on Linux. On Windows three of the four skip without Vulkan and `agc_driver_graphics` passes. The libc and libkernel suites pass on both. - **Merged with `main` 0d078f75d3** (46d8f39271, no conflicts), on GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39126244697)): in one run on Linux the `^agc` tests pass, 711 tests: 662 pass, 49 skip, 0 fail. The libc and libkernel suites pass on both runners. On Windows, of 711 `^agc` tests 173 pass and 536 skip, since the runner has no Vulkan device; the only failures are `agc_driver_pm4_replay_tool` and `agc_shader_replay_tool`, which fail the same way on that runner for an unrelated branch ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39061670036)). - **Merged with `main` 5949d8bf92 and 5d48c6233e** (3080b8f66f, then b7794a5f1c, the head; [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40220276889)). `main`'s #9685 excepts drawn resident linear targets from the pending storage-image results debt entry this PR rewrites, and adds two entries after it; the merge keeps `main`'s opening, this PR's text, `main`'s two entries, then this PR's host-write entry. `main`'s #10369 opens a watched import's host-write window only when the import may write guest memory; the merge keeps this PR's `OwnHostWrite` mark, then `main`'s optional window. The `agc_driver_host_write_` and `agc_driver_linear_target_` tests, `agc_driver_address_passes_draw_transitions`, `agc_driver_graphics`, `agc_driver_preparation_scope_settle`, `agc_driver_storage_file_write`, `guest_kqueue` and `public_headers` pass 10 runs in a row. Linux: 18 run, 17 pass, 1 skip (`agc_driver_linear_target_direct_write_completion`), 0 fail. Windows: 18 run, 3 pass, 15 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **LEGO Horizon Adventures (PPSA14632)**, run by winstrex ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6333343410)): Windows 11, NVIDIA GeForce RTX 5070 Ti (NVIDIA 591.86), warm shader cache, the same input script each run. - With this PR, the `[hostwrite]` line shows host writes landing on pending GPU work over their range in every run (4 to 60 per run). - The `FAsyncLoadingThread` crash with `ObjectSerializationError ... Serial size mismatch` after the graphics quality screen came in 2 of 2 runs on `main` 7ce3b1df3, 1 of 6 on this PR's base 86b84244f and 0 of 7 with this PR (9f5745d7d). winstrex calls that not conclusive at these counts. - One of the 7 runs with this PR crashed later with a different corruption (`UObjectHash.cpp` line 42). - **Epic Mickey: Rebrushed (PPSA15657) on newer `main`, johnmaia's follow-up** ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6406110608)): the same setup (i3-12100, RX 7600, RADV), where a run fails on `ObjectSerializationError` / Serial size mismatch, `LowLevelFatalError` or a crash before the level. - `main` 5d9dcc42d, earlier runs: 5 of 8 reach the level cleanly. - `main` 933c0e4f1 / bfb080619 (10-24), without this PR: 5 of 5. - `main` bfb080619 with #8091 and #10304, at about 7 fps in the level, the speed where the old failure showed: 14 of 14. johnmaia puts the chance of 14 clean runs at about 0.1 % if the old 3 of 8 still held. - So on current `main` this crash no longer shows a failure this PR fixes. The Alone in the Dark (cd700fe9e) and LEGO Horizon Adventures (7ce3b1df3) runs above were also on `main` from before #8126 and #8751. - **Alone in the Dark (PPSA08240) on current `main`, LeoFeitosa's rerun** ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6407433634)): `main` b1f023dda3 (10-25) without this PR, the same harness (Windows 11 26200, RTX 5070 Ti, driver 617.42, `APS5_PLAYGO_UNLISTED_CHUNKS=installed`, the exe and `.guest.prx` relinked with this build's relinker). - 3 of 6 runs fail: one closes before the menu on `LowLevelFatalError [Line: 3230]` "Serial size mismatch" on a loading-screen texture, and two crash in the async loader right after the menu (`0xc0000005` on `FAsyncLoadingThread`, and `LowLevelFatalError [Line: 197]` allocating 34043592704 bytes). - So this title still fails on current `main`, unlike Epic Mickey. - **With this PR** (b7794a5f1c merged cleanly onto the same b1f023dda3, the same harness and machine, the installed `libSceAgcDriver.prx` checked against the package), 6 of 6 runs reach the main menu with no fatal error (menu at 260, 90, 90, 90, 90 and 90 s) ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6408391791)). - **LEGO Horizon Adventures (PPSA14632) on current `main`, winstrex's pair** ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6434610479)): Windows 11 (26300), RTX 5070 Ti (driver 621.01). On `main` abed035468 all 12 runs, with and without this PR, stopped 19 to 40 s in on the refusal from #11425 (a compute shader reading or writing a converted float image with 16-bit data), so both sides had #11580 merged, which fixes it. 240 s per run, alternating, with the saves and a warm shader cache restored before each run. - `main` abed035468 + #11580: 6 of 6 reached the load after the graphics quality screen, with no `Serial size mismatch` or `FAsyncLoadingThread` crash. - The same + this PR (bc288ffa6d): 5 of 6, with no loader crash; the sixth stopped on `VK_ERROR_DEVICE_LOST` at 81 s, which winstrex also saw once without this PR, in a warm-up run that isn't counted. - Neither side hit the loader crash, so this pair doesn't reproduce in this title what this PR fixes, and it isn't conclusive either way. - `tools/check_conventions.py`: passed. **Overlap.** On main 1b1f8483ca, the overlap check finds three open PRs that conflict with this one. 37 others that touch the same files conflict with main themselves, so they couldn't be checked. - **#6234** (Ondra97) adds the read direction: pending GPU results are flushed before file writes, through a host read hook next to this one. - Merging the two gives three conflicts: adjacent additions in `GuestArena.hpp` and `GuestArena.cpp`, and the debt entry, which both PRs rewrite. Each resolves by keeping both sides. - The two hooks never run for the same call. #6234's runs where the host reads guest memory, this one where the host writes it. - Both end in the same `FlushGpuWrites`. - **#6184** (MarcZX100) adds an access observer for protection changes, commits and maps. - It conflicts in one place, where both setters follow `GuestArenaWriteWatched_nid_postfix`. - Its observer never runs in `GuestArenaBeginHostWrite`, so the two compose independently. - **#6641** (ours) edits neighbouring lines of `Execution/src/Driver/Lifecycle.cpp`. Whichever lands second takes a one-line merge. - **Stray (PPSA02100) on Windows, by @dantdmdarealguy** ([comment](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6425970593)): Windows 11 Pro, i9-14900K, RTX 5080 (617.42), `main` 32b7331c44 and `main` with b7794a5f1c merged (clean), the same `app.exe`, save state and pad script, runs alternated, 125 s from launch through the New Game load, 6 runs each. On `main`, 4 stop at the #7048 refusal at about 20 s, 1 on an access violation before the menu, and the one that reached the New Game load crashed there (`Serial size mismatch`). With this PR, 2 are clean, 2 stop at the #7048 refusal and 1 on an access violation before the menu; of the 3 that reached the load, 1 crashed there (an `FAsyncLoadingThread` access violation). So the loader crash still occurred once with this PR. He notes that the rate drifts a lot with the state of the machine, so counts this small are only indicative. - **ASTRONEER (PPSA27623), by @JJenkx** ([comment](https://github.com/boykopovar/AnyPS5/discussions/8746#discussioncomment-19417856)): Linux, AMD Radeon RX 6650 XT (RADV, Mesa 26.2.6), Release, `APS5_PLAYGO_UNLISTED_CHUNKS=installed`, 60 s from boot. The title sometimes crashes during its first load, with a UE4 "Serial size mismatch" LowLevelFatalError or a SIGSEGV in package loading. JJenkx traced it with local read diagnostics that aren't in any PR. The file reads match the pak, but the failing exports are read into memory that held one of the title's colour targets about a second earlier, and the driver's idle store then writes that target's drawn rectangle over the file data (5.6 ms after the read, in the logged crash). This PR's host-write hook stores the pending target before the read. - **With the diagnostics on,** arms interleaved in blocks of 4: `main` 1e24993fa3 crashed in 5 of 12 runs, and `main` with this PR at 75ffc81473 in 0 of 12 (one-sided Fisher p ≈ 0.019). The write-backs over the failing buffers within 300 ms of each read were 47 idle stores on `main`, 26 of them after the read, and with this PR 4 stores by its hook before the read, 1 idle store and none after. - **Without the diagnostics,** earlier series on `main` crashed in about 1 run in 5, but in this paired series both arms ran 0 of 12, so those runs say nothing either way. - JJenkx's #16011 fixes a separate idle-store ordering race found on the way. With the diagnostics, 3 of its 12 runs still crashed. - **bc288ffa6d, a merge of `main` 263eee0a77** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40386068439)). thuanquang's #9879 adds a "Linear color targets" entry to `docs/dev/debt/libSceAgcDriver.md` where this PR adds its "Host writes into guest memory" entry; the merge keeps both, and this PR's changed lines are the same. `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage`, with the tests for the files the merge changes, pass 10 runs in a row. Linux: 326 run, 316 pass, 10 skip (seven AGC tests on lavapipe and three video-out tests with no display or Vulkan device), 0 fail. Windows: 344 run, 256 pass, 88 skip (85 AGC tests, this PR's two among them, and the same three video-out tests, no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (145 and 212) and on Windows (174 and 233). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **d0b755a486, a merge of `main` facac6a4c5** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40627274402)). The one conflict was the include block of `GuestMemory.cpp`, where `main` now has the `<thread>` include this PR added and adds `<system_error>` next to it; the merge keeps `main`'s lines, and this PR's other changed lines are the same. `agc_driver_host_write_pending_storage`, `agc_driver_host_write_hook`, `agc_driver_graphics`, `agc_driver_linear_target_direct_write_completion`, `agc_driver_preparation_scope_settle` and `agc_driver_storage_file_write` ran 10 times in a row with no failure. Linux: 6 run, 5 pass, 1 skip, 0 fail. Windows: 6 run, 1 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194), and libkernel has 4 failures of 286. `guest_raise_exception` aborted with 0xc0000409 after "address waking round 37: the handler did not run within 5 s". Run again on this commit ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40631473291)) it aborted the same way at round 7, and so did `main` 9fc181dde5 in the same verify setup ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40631927722), round 5). That is #11813, which traces it to #10666 on `main`; this PR doesn't touch libkernel. The other three, `exec_arguments`, `guest_timed_join_import_libkernel_sys` and `guest_timed_join_import_libkernel_web`, fail at their setup in the verify's Windows build (`FileNotFoundError` starting the title, or copying the libraries they load), and pass in `main`'s own Windows job at 1829def9bf ([job](https://github.com/boykopovar/AnyPS5/actions/runs/40627345977/job/122615375186)). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **11cd12b90b, a merge of `main` ba627802e2** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41303522635), [validation run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41303529763)). - **The conflict:** only `docs/dev/debt/libSceAgcDriver.md`. Gonic0's #13499 (label read traps, macOS) adds a "Label read traps" entry right after the "Pending storage-image results" entry this PR rewrites, and #13678 has since changed it. The merge keeps this PR's Pending entry, then `main`'s Label read traps entry, each unchanged. The other files merged on their own, and this PR's diff against `main` is the same as before in every file. - **#13499's traps and this PR's store-and-wait** (read at a merge with `main` e67cc81869, [result](https://github.com/EagleBearerYS/AnyPS5/blob/cloud-results/results/cloud-1/BF-356.md)): `GuestArenaBeginHostWrite` calls this PR's host-write hook first, which stores a trapped image whole and releases its trap. Only then does the write watch's `BeginHostWrite` resolve any trap left on the range and open the pages. On Linux every trap path is under `#if defined(__APPLE__)`, so only this PR's path is compiled there. - **×10 on GitHub's runners:** this PR's `agc_driver_host_write_pending_storage` and `agc_driver_host_write_hook`, with `agc_driver_graphics`, `agc_driver_linear_readback_label_off`, `agc_driver_linear_target_direct_write_completion`, `agc_driver_preparation_scope_settle`, `agc_driver_storage_file_write` and `agc_recorder_completion_labels`. Linux: 8 run, 7 pass, 1 skip, 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 208 and 308 tests on Linux and 235 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Validation** (`VERIFY_VALIDATION=1` on GitHub's Linux runner, `main` against this head, the same tests where `main` has them): both pass. The loader inserted `VK_LAYER_KHRONOS_validation` 9 times on `main` and 13 with this head, and neither log has `was not found`. Both report only `VUID-VkDeviceCreateInfo-pNext-pNext`, so the change adds none. - **3c3c2ca24a, the Pending storage-image results entry cut to the gap still open,** for fogydes' [review](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6558176580). This PR's rewrite of the entry had grown it from `main`'s 985 characters to 1,396, over `check_conventions.py`'s 1,000-character warning, and described the new ordering. It's now `main`'s entry with only the late-store sentence narrowed to a title's own CPU stores, 993 characters. Docs only: `check_conventions.py --base ba627802e2` passes with no warnings. - **59a6f5e41e, a merge of `main` 3c3b3cda73** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41434087606)). The one conflict was in `docs/dev/debt/libSceAgcDriver.md`: this PR's narrowed "Pending storage-image results" entry and its "Host writes into guest memory" entry sit beside `main`'s new active-recorder entry and two write-watch entries, and the merge keeps all of them. This PR's diff over `main` is unchanged. This PR's `agc_driver_host_write_pending_storage` and `agc_driver_host_write_hook`, with `agc_driver_graphics`, `agc_driver_linear_readback_label_off`, `agc_driver_linear_target_direct_write_completion`, `agc_driver_preparation_scope_settle`, `agc_driver_storage_file_write` and `agc_recorder_completion_labels`, ran 10 times with no failure. Linux: 8 run, 7 pass, 1 skip (`agc_driver_linear_target_direct_write_completion`), 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **75ffc81473, a merge of `main` b611e634f7** ([×10](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41909217579), [every `agc` test](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41909390697)), which brings mrfelek's #15783 (moved read-only draw inputs kept within the draw snapshot cap). - **The conflict:** one, in `docs/dev/debt/libSceAgcDriver.md`, where #15783 extends the "Draw input snapshots" entry next to this PR's narrowed "Pending storage-image results" entry. The merge keeps both. The code merged without conflicts, `GuestMemory.cpp` and `GuestArena.cpp` included, which `main` changed since 3c3b3cda73. This PR's diff over `main` is unchanged. - **×10:** `agc_driver_host_write_pending_storage` and `agc_driver_host_write_hook`, with `agc_driver_graphics`, `agc_driver_linear_readback_label_off`, `agc_driver_linear_target_direct_write_completion`, `agc_driver_preparation_scope_settle`, `agc_driver_storage_file_write` and `agc_recorder_completion_labels`. Linux: 8 run, 7 pass, 1 skip (`agc_driver_linear_target_direct_write_completion`), 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. - **Suites:** libc passes on Linux (303) and on Windows (335), and libkernel on Windows (360). On Linux, libkernel ran 329 tests and `guest_kernel_stack_protect` failed once (`GuestKernelStackProtect failed at line 276`, the `mprotect` of the test's own host pages). This PR changes no libkernel code, and in the `agc` run the same head's libkernel suite passed all 329. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Every `agc` test, once:** Linux: 1,334 run, 1,247 pass, 85 skip, 2 fail. Windows: 1,373 run, 411 pass, 962 skip (no Vulkan device), 0 fail. Both failures are `main`'s: - `agc_driver_image_gather_volume` ("the vertex shader was not emitted in the device's module form") fails the same way in `main`'s own `linux` check on 638187daec, the #15855 merge ([job](https://github.com/boykopovar/AnyPS5/actions/runs/41906999149/job/126869200694)). JJenkx's #15875, merged after b611e634f7, updates the test for the specialized vertex form #14265 emits. - `agc_driver_pipeline_journal`'s 120-second timeout (`778/1334 Test #1431: agc_driver_pipeline_journal ***Timeout 120.06 sec`), `main`'s own cold run. - **AMD Radeon RX 6300 (RADV NAVI24)** at this head, from TechLevelZero's AMD bot ([report](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6645002822)): merged onto `main` b611e63, Mesa 25.2.8, Ubuntu 26.04.1, 3,899 of 3,946 tests selected. 3,819 passed, 18 failed and 62 skipped. None of the failures is new: 13 also fail on `main`, and 5 are unstable on `main`. With `VK_LAYER_KHRONOS_validation`, there are no new validation IDs against `main`, over 1,391 tests on the GPU. - **NVIDIA RTX 2000 Ada Generation** at this head, from TechLevelZero's NVIDIA bot ([report](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6648432053)): merged onto `main` acac7c8, driver 595.99.02, Ubuntu 26.04.1, 3,913 of 3,960 tests selected. 3,848 passed, 6 failed and 59 skipped. None of the failures is new: 2 also fail on `main`, and 4 are unstable on `main`. With `VK_LAYER_KHRONOS_validation`, there are no new validation IDs against `main`, over 1,399 tests on the GPU. - **@BunnyFl's re-review** ([review](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5787748378), approved; their first [approval](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5744777419) was at 59a6f5e41e): `git range-diff` from 59a6f5e41e shows this PR's six commits unchanged. On this head merged onto `main` 78e4248fea, Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32015.12012), WinLibs GCC 15.2.0, Release, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and the validation layer: `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass, 2 of 2, the hook's GPU path ran (`[hostwrite] 2 host writes, 1 waited for GPU work over their range`), and there's no `VUID-` message. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Related: #6636, #6234, #8746 (ASTRONEER (PPSA27623)'s discussion) - [x] Unblocks: Alone in the Dark (PPSA08240), its crashes while loading to the main menu, which still happen on current `main` (LeoFeitosa: on `main` b1f023dda3, the main menu with no fatal error in 3 of 6 runs without this PR and 6 of 6 with it; earlier, 13 of 14 runs with this PR and 1 of 6 on `main` cd700fe9e). It has no Game bring-up discussion yet. Epic Mickey: Rebrushed (PPSA15657, #2255) was the first title: its first-level load crash from #6636's thread, on `main` 5d9dcc42d (johnmaia: 0 of 12 runs failed with the fix, 6 of 24 without), no longer reproduces on `main` from 10-24 without this PR. - [x] GPUs tested: lavapipe (Mesa 25.2.8) on Linux; johnmaia's RX 7600 (RADV, Mesa 25.2.8) in the title; NVIDIA GeForce RTX 5070 Ti (617.42), Windows 11, in Alone in the Dark (LeoFeitosa); AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11: both new tests pass (keravyn-ops); NVIDIA GeForce RTX 3080 (NVIDIA 617.42), Windows 10: both new tests pass 5 of 5 (TheSovietWaffle); NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04: both new tests pass (jotitadev); NVIDIA GeForce RTX 5070 Ti (NVIDIA 591.86), Windows 11, in LEGO Horizon Adventures (winstrex); AMD Radeon RX 9070 XT (driver 32.0.32015.12012), Windows 11: both new tests pass (BunnyFl); AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8) and NVIDIA RTX 2000 Ada Generation (driver 595.99.02), Ubuntu 26.04.1 (TechLevelZero's bots); AMD Radeon RX 6650 XT (RADV, Mesa 26.2.6), Linux, in ASTRONEER (JJenkx); the Windows runner has no Vulkan device - [x] AI-assisted: yes
CnRJay commented 2026-10-16 22:07:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-16T22:07:30Z.

Review: COMMENTED


The right place to fix this (the host write itself, rather than a store at every flip), and the fast path is cheap (82-98 ns against 7 ns for a 64 KiB write with nothing to wait for). Three questions on the slow path and on teardown.

  • When a host write does overlap pending results, PrepareHostWrite waits for the in-flight batches and the store. The call comes from whatever thread did the read()/recv()/APR read: file I/O threads, the network thread, and the title's own loader threads. A loader that streams into a buffer the GPU is still writing now stalls on a GPU round trip per read, which is the stall the description describes as the cost of the flip-time store, only moved. The PR measures the empty case only. Please add counters (hook calls, calls that waited, time waited) to the [rescache]-style profile line and post them for Epic Mickey's first-level load, so the cost of the slow path is seen on a real title, not only in the test.
  • GuestArenaSetHostWriteHook_nid_no_patch(&PrepareHostWrite) is registered in Driver::Driver and cleared in ~Driver. A thread inside a HostWrite scope when the driver is destroyed can call the hook after the clear started, or while Driver members it uses are gone. State that the hook is an atomic pointer and what makes PrepareHostWrite safe once the driver is stopping (it should do nothing after stop()).
  • The lock audit is in the description, but nothing enforces it. A future HostWrite call under a mutex the GPU wait needs (the GPU mutex, a libSceNet lock) deadlocks. Add a check in the hook that throws when the thread holds the GPU mutex outside the supported case, the way DrawPipeline::Drain does, so a violation is an error and not a hang.

Also: the description says the title has not run the fix yet ("Related", not "Fixes"). A log line from Epic Mickey (PPSA15657) on this branch reaching the first level is what the maintainers will ask for; it is worth getting from the reporter before this is looked at in detail.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5554223599 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5554223599). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-16T22:07:30Z. **Review:** COMMENTED --- The right place to fix this (the host write itself, rather than a store at every flip), and the fast path is cheap (82-98 ns against 7 ns for a 64 KiB write with nothing to wait for). Three questions on the slow path and on teardown. - When a host write does overlap pending results, `PrepareHostWrite` waits for the in-flight batches and the store. The call comes from whatever thread did the `read()`/`recv()`/APR read: file I/O threads, the network thread, and the title's own loader threads. A loader that streams into a buffer the GPU is still writing now stalls on a GPU round trip per read, which is the stall the description describes as the cost of the flip-time store, only moved. The PR measures the empty case only. Please add counters (hook calls, calls that waited, time waited) to the `[rescache]`-style profile line and post them for Epic Mickey's first-level load, so the cost of the slow path is seen on a real title, not only in the test. - `GuestArenaSetHostWriteHook_nid_no_patch(&PrepareHostWrite)` is registered in `Driver::Driver` and cleared in `~Driver`. A thread inside a `HostWrite` scope when the driver is destroyed can call the hook after the clear started, or while `Driver` members it uses are gone. State that the hook is an atomic pointer and what makes `PrepareHostWrite` safe once the driver is stopping (it should do nothing after `stop()`). - The lock audit is in the description, but nothing enforces it. A future `HostWrite` call under a mutex the GPU wait needs (the GPU mutex, a libSceNet lock) deadlocks. Add a check in the hook that throws when the thread holds the GPU mutex outside the supported case, the way `DrawPipeline::Drain` does, so a violation is an error and not a hang. Also: the description says the title has not run the fix yet ("Related", not "Fixes"). A log line from Epic Mickey (PPSA15657) on this branch reaching the first level is what the maintainers will ask for; it is worth getting from the reporter before this is looked at in detail.
EagleBearerYS commented 2026-10-17 00:43:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T00:43:16Z.


@CnRJay Thanks. All three are in, each with its test in the same commit:

  • The slow path (276f67d366): with APS5_PROFILE_DRAW=1, a [hostwrite] line every 10 s gives the host writes, those that waited for GPU work over their range, and the total and longest wait. For example, from the test: [hostwrite] 2 host writes, 1 waited for GPU work over their range: 1.34 ms in total, 1.34 ms at most. @johnmaia, when you next run Epic Mickey: Rebrushed (PPSA15657) on this branch, could you add APS5_PROFILE_DRAW=1 and post the [hostwrite] lines from the first-level load? That run would also give the log line for "Fixes".
  • Teardown (2ff4ed6470): the hook is an atomic pointer. Driver::stop() now clears it first, then sets a stopped flag and waits up to 1 s for calls already inside the hook. PrepareHostWrite counts itself in flight before it checks the flag and returns immediately once it's set, so it does nothing after stop(). The wait is bounded because on Windows ExitProcess can end a thread inside the hook before ~Driver runs. The new test shuts the driver down and checks that a host write over a recorded store no longer reaches it; it reached it once at the previous head.
  • The lock check (c2720073b9): a host write made while the thread holds the GPU mutex is counted and logged once, with its thread, address and size. Under APS5_ASSERT_GPU_LOCK=1 (the switch AssertGpuLockHeld reads) it aborts instead. I didn't make it throw in a normal run. With the mutex held, the hook takes FlushForAccess's nested locked wait, which only hangs if completing needs another thread to take the GPU mutex, so a throw would turn a possible hang into a certain crash. The debt file now states the rule.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227492033 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6227492033). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-17T00:43:16Z. --- @CnRJay Thanks. All three are in, each with its test in the same commit: - **The slow path (276f67d366):** with `APS5_PROFILE_DRAW=1`, a `[hostwrite]` line every 10 s gives the host writes, those that waited for GPU work over their range, and the total and longest wait. For example, from the test: `[hostwrite] 2 host writes, 1 waited for GPU work over their range: 1.34 ms in total, 1.34 ms at most`. @johnmaia, when you next run Epic Mickey: Rebrushed (PPSA15657) on this branch, could you add `APS5_PROFILE_DRAW=1` and post the `[hostwrite]` lines from the first-level load? That run would also give the log line for "Fixes". - **Teardown (2ff4ed6470):** the hook is an atomic pointer. `Driver::stop()` now clears it first, then sets a stopped flag and waits up to 1 s for calls already inside the hook. `PrepareHostWrite` counts itself in flight before it checks the flag and returns immediately once it's set, so it does nothing after `stop()`. The wait is bounded because on Windows `ExitProcess` can end a thread inside the hook before `~Driver` runs. The new test shuts the driver down and checks that a host write over a recorded store no longer reaches it; it reached it once at the previous head. - **The lock check (c2720073b9):** a host write made while the thread holds the GPU mutex is counted and logged once, with its thread, address and size. Under `APS5_ASSERT_GPU_LOCK=1` (the switch `AssertGpuLockHeld` reads) it aborts instead. I didn't make it throw in a normal run. With the mutex held, the hook takes `FlushForAccess`'s nested locked wait, which only hangs if completing needs another thread to take the GPU mutex, so a throw would turn a possible hang into a certain crash. The debt file now states the rule.
keravyn-ops commented 2026-10-17 09:59:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T09:59:31Z.


AMD / Windows run of this PR at 276f67d36: 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 (2):

  • agc_driver_host_write_hook (0.37 s): 463: host write hook tests passed
  • agc_driver_host_write_pending_storage (0.40 s): 464: host write pending storage tests passed

AI-assisted: yes (runs made on the device above).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232562536 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6232562536). Originally posted by [keravyn-ops](https://github.com/keravyn-ops) on 2026-10-17T09:59:31Z. --- AMD / Windows run of this PR at 276f67d36: 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 (2): - `agc_driver_host_write_hook` (0.37 s): `463: host write hook tests passed` - `agc_driver_host_write_pending_storage` (0.40 s): `464: host write pending storage tests passed` AI-assisted: yes (runs made on the device above).
EagleBearerYS commented 2026-10-17 10:09:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T10:09:11Z.


Thanks @keravyn-ops for the AMD runs here, on #6911 and on #6944; they're in each PR's Tested and GPUs-tested lines now.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232655974 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6232655974). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-17T10:09:11Z. --- Thanks @keravyn-ops for the AMD runs here, on #6911 and on #6944; they're in each PR's Tested and GPUs-tested lines now.
TheSovietWaffle commented 2026-10-17 11:36:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-17T11:36:24Z.


NVIDIA data point for this PR: head 276f67d36, RTX 3080 (NVIDIA 617.42), Ryzen 7 7800X3D, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, Release, libraries rebuilt from the head.

  • agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass 5 of 5 runs each on the RTX 3080 (device selected in the log, not skipped).
  • The 12 guest_socket_host_write_* tests, which go through the changed GuestArena host-write path, pass.

Not checked: whether the new tests fail on main without the change on this GPU, and titles (I don't have Epic Mickey: Rebrushed).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233421326 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6233421326). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-17T11:36:24Z. --- NVIDIA data point for this PR: head `276f67d36`, RTX 3080 (NVIDIA 617.42), Ryzen 7 7800X3D, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, Release, libraries rebuilt from the head. - `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass 5 of 5 runs each on the RTX 3080 (device selected in the log, not skipped). - The 12 `guest_socket_host_write_*` tests, which go through the changed `GuestArena` host-write path, pass. Not checked: whether the new tests fail on `main` without the change on this GPU, and titles (I don't have Epic Mickey: Rebrushed). AI-assisted: yes (Claude Code).
EagleBearerYS commented 2026-10-17 11:39:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T11:39:08Z.


Thanks @TheSovietWaffle for the RTX 3080 runs; they're in the Tested and GPUs-tested lines now.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233444487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6233444487). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-17T11:39:08Z. --- Thanks @TheSovietWaffle for the RTX 3080 runs; they're in the Tested and GPUs-tested lines now.
jotitadev commented 2026-10-17 13:35:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T13:35:51Z.

Review: COMMENTED


A Linux run on NVIDIA and lavapipe, with the hook taken out to see what the new tests catch.

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 onto main 12a71f3f5 (clean). ANYPS5_NO_SHADER_CACHE=1, -j1 --timeout 30.

Run RTX 3070 lavapipe
agc_driver_host_write_hook, agc_driver_host_write_pending_storage pass 3/3 pass
^agc (638 tests), PR vs main no new failures (636/638; agc_driver_f16_fma_denormal_modes and agc_driver_fma_mix_f16_denormal_modes fail on main on this GPU too) 638/638 on both

The tests don't build on main (they use HostWritesCounted), so as the negative control I removed only the GuestArenaSetHostWriteHook_nid_no_patch(&GuestMemory::PrepareHostWrite) line from Driver::Driver. Both tests fail on both devices, 3/3 on the 3070:

host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed

So on Linux the file-read path reaches the driver only through this hook, and three of the four cases catch it missing. The third case, a 64 KiB host write over pending results, passes without the hook on both devices, so it does not cover the fix on this platform.

Run on 276f67d36; the current head be2be36b5 only merges main, the PR's five commits are unchanged.

Not run: Windows, AMD, Epic Mickey or 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5557981443 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5557981443). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-17T13:35:51Z. **Review:** COMMENTED --- A Linux run on NVIDIA and lavapipe, with the hook taken out to see what the new tests catch. **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 onto `main` `12a71f3f5` (clean). `ANYPS5_NO_SHADER_CACHE=1`, `-j1 --timeout 30`. | Run | RTX 3070 | lavapipe | |---|---|---| | `agc_driver_host_write_hook`, `agc_driver_host_write_pending_storage` | pass 3/3 | pass | | `^agc` (638 tests), PR vs `main` | no new failures (636/638; `agc_driver_f16_fma_denormal_modes` and `agc_driver_fma_mix_f16_denormal_modes` fail on `main` on this GPU too) | 638/638 on both | The tests don't build on `main` (they use `HostWritesCounted`), so as the negative control I removed only the `GuestArenaSetHostWriteHook_nid_no_patch(&GuestMemory::PrepareHostWrite)` line from `Driver::Driver`. Both tests fail on both devices, 3/3 on the 3070: ``` host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed ``` So on Linux the file-read path reaches the driver only through this hook, and three of the four cases catch it missing. The third case, a 64 KiB host write over pending results, passes without the hook on both devices, so it does not cover the fix on this platform. Run on `276f67d36`; the current head `be2be36b5` only merges `main`, the PR's five commits are unchanged. Not run: Windows, AMD, Epic Mickey or 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.
EagleBearerYS commented 2026-10-17 13:44:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T13:44:37Z.


Thanks for the Linux runs and the negative control. Your three failures are the same ones the red in Tested shows, and the whole-block case passes on main there too, as Tested says. That case isn't a red/green case: it checks that after a whole-block host write over pending results, the file's bytes survive and the image's texels land around them, which main already gets right. I've added your runs to Tested and the GPU list.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234607575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6234607575). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-17T13:44:37Z. --- Thanks for the Linux runs and the negative control. Your three failures are the same ones the red in Tested shows, and the whole-block case passes on `main` there too, as Tested says. That case isn't a red/green case: it checks that after a whole-block host write over pending results, the file's bytes survive and the image's texels land around them, which `main` already gets right. I've added your runs to Tested and the GPU list.
LeoFeitosa commented 2026-10-21 07:13:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeoFeitosa on 2026-10-21T07:13:07Z.


Windows / NVIDIA data point, another UE4 title: Alone in the Dark (PPSA08240, v1.00).

Windows 11 (build 26200), RTX 5070 Ti, driver 617.42, WinLibs GCC 15.2.0 r7, Release. Both sides built from the same tree: main cd700fe9e (the main this PR last merged) and this PR's head 2c5b77231. Same converted title, shader cache directory and save state for every run. The dump has no PlayGo files, so every run sets APS5_PLAYGO_UNLISTED_CHUNKS=installed. No input until the main menu is up.

Six alternating pairs, each run from launch to the main menu or the crash (anyps5.log of every run kept):

Reached the main menu Crashed while loading
main cd700fe9e 1 of 6 5 of 6
this PR 5 of 6 1 of 6
main + APS5_STORE_AT_FLIP=1 3 of 3 0 of 3

The main crashes, all during the boot to the menu:

  • 2 × LowLevelFatalError [Line: 3230] with "Serial size mismatch" on UI textures (T_img_loading_french_quarter, T_Gfx_Derceto_Map_Background);
  • 1 × 0xc000001d on FAsyncLoadingThread at Alone in the Dark.exe+0x21925a0;
  • 2 × 0xc0000005 at Alone in the Dark.exe+0x20ec0bc (Windows event 1000; nothing in anyps5.log).

The one crash with this PR is the last kind: 0xc0000005 at Alone in the Dark.exe+0x20ec0bc. I have not traced whether that one shares the cause.

Earlier, not alternated, on main 559f35d685: 2 of 4 runs crashed with these signatures (one of them with APS5_TRACE_LABEL set), and the one run with APS5_STORE_AT_FLIP=1 reached the menu.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310292794 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6310292794). Originally posted by [LeoFeitosa](https://github.com/LeoFeitosa) on 2026-10-21T07:13:07Z. --- Windows / NVIDIA data point, another UE4 title: Alone in the Dark (PPSA08240, v1.00). Windows 11 (build 26200), RTX 5070 Ti, driver 617.42, WinLibs GCC 15.2.0 r7, Release. Both sides built from the same tree: `main` cd700fe9e (the main this PR last merged) and this PR's head 2c5b77231. Same converted title, shader cache directory and save state for every run. The dump has no PlayGo files, so every run sets `APS5_PLAYGO_UNLISTED_CHUNKS=installed`. No input until the main menu is up. Six alternating pairs, each run from launch to the main menu or the crash (`anyps5.log` of every run kept): | | Reached the main menu | Crashed while loading | |---|---|---| | `main` cd700fe9e | 1 of 6 | 5 of 6 | | this PR | 5 of 6 | 1 of 6 | | `main` + `APS5_STORE_AT_FLIP=1` | 3 of 3 | 0 of 3 | The `main` crashes, all during the boot to the menu: - 2 × `LowLevelFatalError [Line: 3230]` with "Serial size mismatch" on UI textures (`T_img_loading_french_quarter`, `T_Gfx_Derceto_Map_Background`); - 1 × `0xc000001d` on `FAsyncLoadingThread` at `Alone in the Dark.exe+0x21925a0`; - 2 × `0xc0000005` at `Alone in the Dark.exe+0x20ec0bc` (Windows event 1000; nothing in `anyps5.log`). The one crash with this PR is the last kind: `0xc0000005` at `Alone in the Dark.exe+0x20ec0bc`. I have not traced whether that one shares the cause. Earlier, not alternated, on `main` 559f35d685: 2 of 4 runs crashed with these signatures (one of them with `APS5_TRACE_LABEL` set), and the one run with `APS5_STORE_AT_FLIP=1` reached the menu.
EagleBearerYS commented 2026-10-21 07:49:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T07:49:43Z.


@LeoFeitosa, thank you, that's a clear pair: the main menu in 1 of 6 runs on main and in 5 of 6 with this PR, and in 3 of 3 with APS5_STORE_AT_FLIP=1. That main's crashes also go away when pending results are stored at every flip points at the window this PR closes at the host write: a file or APR read landing in memory that a pending GPU store then overwrites.

The remaining 0xc0000005 at +0x20ec0bc may have another cause. This PR orders only host writes (file, AIO and APR reads, socket receives) after pending stores. The title's own CPU stores and reads aren't ordered (the debt entry says so), while APS5_STORE_AT_FLIP=1 stores everything pending at each flip, whoever touches the memory next. If you have time for more runs, the anyps5.log of a crash with this PR under APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1 would show which reads met pending images before it: each one prints a [flush] image … for memory access … line right after its [apr] read.

I've added your runs to the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310890572 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6310890572). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T07:49:43Z. --- @LeoFeitosa, thank you, that's a clear pair: the main menu in 1 of 6 runs on `main` and in 5 of 6 with this PR, and in 3 of 3 with `APS5_STORE_AT_FLIP=1`. That `main`'s crashes also go away when pending results are stored at every flip points at the window this PR closes at the host write: a file or APR read landing in memory that a pending GPU store then overwrites. The remaining `0xc0000005` at `+0x20ec0bc` may have another cause. This PR orders only host writes (file, AIO and APR reads, socket receives) after pending stores. The title's own CPU stores and reads aren't ordered (the debt entry says so), while `APS5_STORE_AT_FLIP=1` stores everything pending at each flip, whoever touches the memory next. If you have time for more runs, the `anyps5.log` of a crash with this PR under `APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1` would show which reads met pending images before it: each one prints a `[flush] image … for memory access …` line right after its `[apr] read`. I've added your runs to the description.
LeoFeitosa commented 2026-10-21 08:57:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeoFeitosa on 2026-10-21T08:57:31Z.


@EagleBearerYS I ran it with APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1 on the same head (2c5b77231), same setup as before: 8 runs, all 8 reached the main menu, so there is no crash log to show yet. Each log has about 26,000 [apr] lines and about 110,000 [flush] lines, so the tracing was active.

With the untraced runs, this head has now reached the menu in 13 of 14 runs. The tracing changes the timing, so it may be hiding the remaining +0x20ec0bc crash; if it shows up in later runs I'll post its log here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312086321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6312086321). Originally posted by [LeoFeitosa](https://github.com/LeoFeitosa) on 2026-10-21T08:57:31Z. --- @EagleBearerYS I ran it with `APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1` on the same head (2c5b77231), same setup as before: 8 runs, all 8 reached the main menu, so there is no crash log to show yet. Each log has about 26,000 `[apr]` lines and about 110,000 `[flush]` lines, so the tracing was active. With the untraced runs, this head has now reached the menu in 13 of 14 runs. The tracing changes the timing, so it may be hiding the remaining `+0x20ec0bc` crash; if it shows up in later runs I'll post its log here.
EagleBearerYS commented 2026-10-21 09:37:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T09:37:33Z.


@LeoFeitosa, thanks for the eight traced runs. 13 of 14 with this PR against 1 of 6 on main is now in the description. If the +0x20ec0bc crash comes back in a later run, its log is welcome, but there's no need to run more for it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312822177 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6312822177). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T09:37:33Z. --- @LeoFeitosa, thanks for the eight traced runs. 13 of 14 with this PR against 1 of 6 on `main` is now in the description. If the `+0x20ec0bc` crash comes back in a later run, its log is welcome, but there's no need to run more for it.
JJenkx commented 2026-10-21 13:16:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T13:16:11Z.


Second title with the same failure signature, for the record (not a test of this PR).

Setup: Code Violet (PPSA26528) 01.000.028 on Linux, RX 6650 XT, RADV (Mesa 26.2.4). main b5d763770a with #4449 merged locally, APS5_UNIT_SHADOW_MIB=4096, and APS5_STORE_AT_FLIP unset.

Failure: 1 of 8 cold starts ended 8 s after launch with:

LowLevelFatalError [File:.\Runtime/CoreUObject/Private/Serialization/AsyncLoading2.cpp] [Line: 8281]
ObjectSerializationError: /Game/Sci_Fi_Cargo_Hub/Meshes/SM_terminal_1 (0xC47F387B039AAFC) ... StaticMesh ... Serial size mismatch

It was followed by a segmentation fault. The other 7 starts loaded past it to the menus.

I have not run this PR or APS5_STORE_AT_FLIP=1 on this title, so this only adds a second Unreal title where an asset read during async loading sees a wrong size early in startup.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317015025 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6317015025). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T13:16:11Z. --- Second title with the same failure signature, for the record (not a test of this PR). **Setup:** Code Violet (PPSA26528) 01.000.028 on Linux, RX 6650 XT, RADV (Mesa 26.2.4). `main` b5d763770a with #4449 merged locally, `APS5_UNIT_SHADOW_MIB=4096`, and `APS5_STORE_AT_FLIP` unset. **Failure:** 1 of 8 cold starts ended 8 s after launch with: ``` LowLevelFatalError [File:.\Runtime/CoreUObject/Private/Serialization/AsyncLoading2.cpp] [Line: 8281] ObjectSerializationError: /Game/Sci_Fi_Cargo_Hub/Meshes/SM_terminal_1 (0xC47F387B039AAFC) ... StaticMesh ... Serial size mismatch ``` It was followed by a segmentation fault. The other 7 starts loaded past it to the menus. I have not run this PR or `APS5_STORE_AT_FLIP=1` on this title, so this only adds a second Unreal title where an asset read during async loading sees a wrong size early in startup. AI-assisted: yes (Claude Code); results above were run on this machine.
EagleBearerYS commented 2026-10-21 13:23:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T13:23:19Z.


@JJenkx, thank you for the Code Violet (PPSA26528) data point. It's the same signature this PR fixed in Epic Mickey: Rebrushed (PPSA15657), where a storage image's write-back landed after an APR read into the same memory.

If you have time, could you merge this PR (9f5745d7dd; it merges cleanly with main) onto the same tree, main b5d763770a with #4449, and run Code Violet the same way: cold starts on RADV with APS5_STORE_AT_FLIP unset, alternated with that tree without it? At 1 failure in 8, a clean run with the PR only means something over enough starts: 16 per side is a start, and 24 or more would make it clear. A run with APS5_STORE_AT_FLIP=1 and no PR would also show whether it's the same late store.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317170830 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6317170830). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T13:23:19Z. --- @JJenkx, thank you for the Code Violet (PPSA26528) data point. It's the same signature this PR fixed in Epic Mickey: Rebrushed (PPSA15657), where a storage image's write-back landed after an APR read into the same memory. If you have time, could you merge this PR (9f5745d7dd; it merges cleanly with `main`) onto the same tree, `main` b5d763770a with #4449, and run Code Violet the same way: cold starts on RADV with `APS5_STORE_AT_FLIP` unset, alternated with that tree without it? At 1 failure in 8, a clean run with the PR only means something over enough starts: 16 per side is a start, and 24 or more would make it clear. A run with `APS5_STORE_AT_FLIP=1` and no PR would also show whether it's the same late store.
winstrex commented 2026-10-22 05:17:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by winstrex on 2026-10-22T05:17:45Z.


Another data point, LEGO Horizon Adventures (PPSA14632), Windows 11, RTX 5070 Ti (NVIDIA 591.86), warm shader cache, same input script each run:

  • With this PR, the [hostwrite] line shows host writes landing on pending GPU work over their range in every run (4 to 60 per run).
  • The FAsyncLoadingThread crash with ObjectSerializationError ... Serial size mismatch after the graphics quality screen: 2/2 runs on main 7ce3b1df3, 1/6 on this PR's base 86b84244f, 0/7 with this PR (9f5745d7d). Not conclusive at these counts.
  • One of the 7 runs with this PR crashed later with a different corruption: UObjectHash.cpp [Line: 42] ... hash itself may be corrupted.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333343410 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6333343410). Originally posted by [winstrex](https://github.com/winstrex) on 2026-10-22T05:17:45Z. --- Another data point, LEGO Horizon Adventures (PPSA14632), Windows 11, RTX 5070 Ti (NVIDIA 591.86), warm shader cache, same input script each run: - With this PR, the `[hostwrite]` line shows host writes landing on pending GPU work over their range in every run (4 to 60 per run). - The `FAsyncLoadingThread` crash with `ObjectSerializationError ... Serial size mismatch` after the graphics quality screen: 2/2 runs on `main` 7ce3b1df3, 1/6 on this PR's base 86b84244f, 0/7 with this PR (9f5745d7d). Not conclusive at these counts. - One of the 7 runs with this PR crashed later with a different corruption: `UObjectHash.cpp [Line: 42] ... hash itself may be corrupted`.
EagleBearerYS commented 2026-10-22 05:40:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T05:40:22Z.


@winstrex thanks for the LEGO Horizon Adventures (PPSA14632) runs, and for keeping the input script the same across them. The [hostwrite] counts show this PR's path taken in every run, and the crash counts are in Tested now, with your note that they aren't conclusive yet.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333645746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#issuecomment-6333645746). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T05:40:22Z. --- @winstrex thanks for the LEGO Horizon Adventures (PPSA14632) runs, and for keeping the input script the same across them. The `[hostwrite]` counts show this PR's path taken in every run, and the crash counts are in Tested now, with your note that they aren't conclusive yet.
BunnyFl commented 2026-11-02 23:14:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T23:14:38Z.

Review: APPROVED


Here's the Windows/AMD run this PR didn't have yet. Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, with this head merged onto current main: agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass, nothing skipped. The hook's path ran on the GPU, not just the fast path: the log shows [hostwrite] 2 host writes, 1 waited for GPU work over their range: 0.08 ms in total, 0.08 ms at most and host write waits: the write over the recorded store waited, the one over the idle range did not. With main's GuestMemory, Lifecycle.cpp and GuestArena sources the tests don't build (HostWritesCounted is new), so a runtime negative control isn't possible here. jotitadev's run without the hook covers that.

CnRJay's slow-path and teardown questions are answered in 276f67d366 (the [hostwrite] accounting) and 2ff4ed6470 (clearing the hook and waiting for calls in flight at stop), and the paired Alone in the Dark runs on current main (3 of 6 without, 6 of 6 with) back the Unblocks line.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5744777419 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5744777419). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T23:14:38Z. **Review:** APPROVED --- Here's the Windows/AMD run this PR didn't have yet. Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, with this head merged onto current `main`: `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass, nothing skipped. The hook's path ran on the GPU, not just the fast path: the log shows `[hostwrite] 2 host writes, 1 waited for GPU work over their range: 0.08 ms in total, 0.08 ms at most` and `host write waits: the write over the recorded store waited, the one over the idle range did not`. With `main`'s `GuestMemory`, `Lifecycle.cpp` and `GuestArena` sources the tests don't build (`HostWritesCounted` is new), so a runtime negative control isn't possible here. jotitadev's run without the hook covers that. CnRJay's slow-path and teardown questions are answered in 276f67d366 (the `[hostwrite]` accounting) and 2ff4ed6470 (clearing the hook and waiting for calls in flight at stop), and the paired Alone in the Dark runs on current `main` (3 of 6 without, 6 of 6 with) back the Unblocks line.
XairRrR commented 2026-11-03 09:01:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T09:01:46Z.

Review: APPROVED


Reviewed — approved

The host-write hook (libc → GuestMemory::PrepareHostWrite → FlushGpuWrites) builds and both new tests pass on lavapipe with no new VUIDs. Removing the hook's registration or the teardown in stop() makes the tests fail exactly as the description says. I found nothing blocking.

What I ran

  • PR head 59a6f5e41e82a2a7049715f0844da5ffb24a45f4
  • main 4f41f4c375f5abb487dbd184fbc150f31994d762
  • Merged tree d1a8dc054612ad49da165b21bf50e32b6d0a6f79
  • Machine: Debian 13 VM (32 vCPU, Xeon Gold 6136), GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19)
git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...59a6f5e41e82a2a7049715f0844da5ffb24a45f4
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R '^agc_driver_host_write_(hook|pending_storage)$'
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R '^agc_driver_native_depth_uniform_planes$'   # merged tree, then main's production files
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R '^agc_driver_(host_write_(hook|pending_storage)|storage_file_write|graphics|linear_target_direct_write_completion|preparation_scope_settle)$'
# negative controls (see below), each followed by
ninja -C build -j32 -l32 agc_driver_host_write_hook_tests agc_driver_host_write_pending_storage_tests
ctest --test-dir build --output-on-failure -R '^agc_driver_host_write_(hook|pending_storage)$'

Results

Check Result
git diff --check clean
check_conventions.py passed
Configure, build, libs (script) ok
Selected tests (script, 3702 run) no new failures, no timeouts; the 9 known failures also fail on main
check_skips.py guest_net_ctl skipped, which also happens on main (not this PR)
agc_driver_host_write_hook with the validation layer passed in 0.46 s, layer inserted, no VUID-
agc_driver_host_write_pending_storage with the validation layer passed in 0.47 s, all 4 cases, write watch "userfaultfd, user mode only", no VUID-
Script's validation comparison one test flagged: agc_driver_native_depth_uniform_planes, VUID-vkCmdDispatch-groupCountX-00386, "test not run on main". The test was added to main after the baseline d1ae628bc2. With main's production files restored it reports the same VUID 4 times, as on the merged tree, so it comes from main.
Related tests: storage_file_write, graphics, preparation_scope_settle, linear_target_direct_write_completion 5 passed, 1 skipped (linear_target_direct_write_completion, as in the description's runs)
New tests, merged tree
[hostwrite] 2 host writes, 1 waited for GPU work over their range: 5.85 ms in total, 5.85 ms at most
[lock] a host write of 0x10000 bytes at 0x7faba6c80000 was made under GuestMemory::GpuMutex on thread tagged 0xffffffff; it waits for GPU work with the mutex held (counted, logged once)
host write waits: the write over the recorded store waited, the one over the idle range did not
host write under the GPU mutex: it returned and was counted once
host write after shutdown: the host write did not reach the stopped driver
host write hook tests passed
host write over pending storage, a store recorded before a 64 KiB host write: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a store recorded before a 4 KiB host write: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a 4 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
host write pending storage tests passed

Negative control

Both new tests call new API (HostWritesCounted, GuestArenaSetHostWriteHook_nid_no_patch), so they can't build against main's production files. I ran two narrower controls instead.

  1. Only the GuestArenaSetHostWriteHook_nid_no_patch(&GuestMemory::PrepareHostWrite) line removed from Driver::Driver: both tests fail.

    • agc_driver_host_write_hook: "a host write over a recorded store counted 0 call(s), 0 that waited".
    • agc_driver_host_write_pending_storage: the same three cases fail as in the description and jotitadev's review. The whole-block case over pending results passes, as already noted there.
    Output
    host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
    host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
    host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
    host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed
    
  2. Only the two teardown lines in Driver::stop() removed (the hook clear and StopHostWrites(1000)): agc_driver_host_write_hook fails with "a host write over a range with a recorded store reached the driver's flush hook 1 time(s) after Driver::Shutdown".

After the controls I restored the merged files and rebuilt. git status --porcelain is empty, and the tests above pass again.

Findings

Blocking

None.

Non-blocking

  • Duplicate include (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp:16): the PR adds #include "prx/libc/include/GuestArena.hpp", but main already includes it two lines below (line 18). The duplicate is left over from the merge with #6641's ShaderDiskCache.hpp include. It does no harm, but the PR's line can be dropped.
  • The "Unblocks" line has no Game bring-up discussion: CONTRIBUTING asks for the title ID and its Game bring-up discussion. The line gives PPSA15657 and PPSA08240, but no discussion numbers. Separately, the description itself says the Epic Mickey crash no longer reproduces on current main. Only the Alone in the Dark pair on main b1f023dda3 (3 of 6 without, 6 of 6 with) is current evidence, so the Unblocks claim rests on that title.
  • hostWritesStopped is never reset (core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp, StopHostWrites): this is correct today, since Driver::Get() is a function-local static and stop() is final. If the driver ever restarts after Shutdown, though, the hook would be registered again but return at once. Worth keeping in mind if restart support is added.

Not verified

  • Hardware GPUs (only lavapipe here), Windows and macOS (the OwnHostWrite import window is __APPLE__-only), and any title. The title results are the reporters' runs, quoted in the description and discussion.
  • Only the default write-watch mode on this machine (userfaultfd, user mode only). I did not run the root or APS5_NO_WRITE_WATCH=1 modes.
  • The --cost timing claim (75–90 ns on the fast path).
  • agc_driver_graphics took 36 s here, under parallel load. This PR doesn't change that test, and I didn't compare its time with main.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5749433065 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5749433065). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T09:01:46Z. **Review:** APPROVED --- # Reviewed — approved The host-write hook (libc → `GuestMemory::PrepareHostWrite` → `FlushGpuWrites`) builds and both new tests pass on lavapipe with no new VUIDs. Removing the hook's registration or the teardown in `stop()` makes the tests fail exactly as the description says. I found nothing blocking. ## What I ran - PR head `59a6f5e41e82a2a7049715f0844da5ffb24a45f4` - `main` `4f41f4c375f5abb487dbd184fbc150f31994d762` - Merged tree `d1a8dc054612ad49da165b21bf50e32b6d0a6f79` - Machine: Debian 13 VM (32 vCPU, Xeon Gold 6136), GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19) ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...59a6f5e41e82a2a7049715f0844da5ffb24a45f4 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R '^agc_driver_host_write_(hook|pending_storage)$' env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R '^agc_driver_native_depth_uniform_planes$' # merged tree, then main's production files ctest --test-dir build -j8 --test-load 32 --output-on-failure -R '^agc_driver_(host_write_(hook|pending_storage)|storage_file_write|graphics|linear_target_direct_write_completion|preparation_scope_settle)$' # negative controls (see below), each followed by ninja -C build -j32 -l32 agc_driver_host_write_hook_tests agc_driver_host_write_pending_storage_tests ctest --test-dir build --output-on-failure -R '^agc_driver_host_write_(hook|pending_storage)$' ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | passed | | Configure, build, `libs` (script) | ok | | Selected tests (script, 3702 run) | no new failures, no timeouts; the 9 known failures also fail on `main` | | `check_skips.py` | `guest_net_ctl` skipped, which also happens on `main` (not this PR) | | `agc_driver_host_write_hook` with the validation layer | passed in 0.46 s, layer inserted, no `VUID-` | | `agc_driver_host_write_pending_storage` with the validation layer | passed in 0.47 s, all 4 cases, write watch "userfaultfd, user mode only", no `VUID-` | | Script's validation comparison | one test flagged: `agc_driver_native_depth_uniform_planes`, `VUID-vkCmdDispatch-groupCountX-00386`, "test not run on main". The test was added to `main` after the baseline `d1ae628bc2`. With `main`'s production files restored it reports the same VUID 4 times, as on the merged tree, so it comes from `main`. | | Related tests: `storage_file_write`, `graphics`, `preparation_scope_settle`, `linear_target_direct_write_completion` | 5 passed, 1 skipped (`linear_target_direct_write_completion`, as in the description's runs) | <details><summary>New tests, merged tree</summary> ``` [hostwrite] 2 host writes, 1 waited for GPU work over their range: 5.85 ms in total, 5.85 ms at most [lock] a host write of 0x10000 bytes at 0x7faba6c80000 was made under GuestMemory::GpuMutex on thread tagged 0xffffffff; it waits for GPU work with the mutex held (counted, logged once) host write waits: the write over the recorded store waited, the one over the idle range did not host write under the GPU mutex: it returned and was counted once host write after shutdown: the host write did not reach the stopped driver host write hook tests passed host write over pending storage, a store recorded before a 64 KiB host write: the file's bytes survived the image's store and its texels landed around them host write over pending storage, a store recorded before a 4 KiB host write: the file's bytes survived the image's store and its texels landed around them host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them host write over pending storage, a 4 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them host write pending storage tests passed ``` </details> ## Negative control Both new tests call new API (`HostWritesCounted`, `GuestArenaSetHostWriteHook_nid_no_patch`), so they can't build against `main`'s production files. I ran two narrower controls instead. 1. **Only the `GuestArenaSetHostWriteHook_nid_no_patch(&GuestMemory::PrepareHostWrite)` line removed from `Driver::Driver`:** both tests fail. - `agc_driver_host_write_hook`: "a host write over a recorded store counted 0 call(s), 0 that waited". - `agc_driver_host_write_pending_storage`: the same three cases fail as in the description and jotitadev's review. The whole-block case over pending results passes, as already noted there. <details><summary>Output</summary> ``` host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed ``` </details> 2. **Only the two teardown lines in `Driver::stop()` removed** (the hook clear and `StopHostWrites(1000)`): `agc_driver_host_write_hook` fails with "a host write over a range with a recorded store reached the driver's flush hook 1 time(s) after Driver::Shutdown". After the controls I restored the merged files and rebuilt. `git status --porcelain` is empty, and the tests above pass again. ## Findings ### Blocking None. ### Non-blocking - **Duplicate include** (`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp:16`): the PR adds `#include "prx/libc/include/GuestArena.hpp"`, but `main` already includes it two lines below (line 18). The duplicate is left over from the merge with #6641's `ShaderDiskCache.hpp` include. It does no harm, but the PR's line can be dropped. - **The "Unblocks" line has no Game bring-up discussion:** CONTRIBUTING asks for the title ID and its Game bring-up discussion. The line gives PPSA15657 and PPSA08240, but no discussion numbers. Separately, the description itself says the Epic Mickey crash no longer reproduces on current `main`. Only the Alone in the Dark pair on `main` b1f023dda3 (3 of 6 without, 6 of 6 with) is current evidence, so the Unblocks claim rests on that title. - **`hostWritesStopped` is never reset** (`core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp`, `StopHostWrites`): this is correct today, since `Driver::Get()` is a function-local static and `stop()` is final. If the driver ever restarts after `Shutdown`, though, the hook would be registered again but return at once. Worth keeping in mind if restart support is added. ## Not verified - Hardware GPUs (only lavapipe here), Windows and macOS (the `OwnHostWrite` import window is `__APPLE__`-only), and any title. The title results are the reporters' runs, quoted in the description and discussion. - Only the default write-watch mode on this machine (userfaultfd, user mode only). I did not run the root or `APS5_NO_WRITE_WATCH=1` modes. - The `--cost` timing claim (75–90 ns on the fast path). - `agc_driver_graphics` took 36 s here, under parallel load. This PR doesn't change that test, and I didn't compare its time with `main`. <!-- anyps5-bots job=2328 head=59a6f5e41e82a2a7049715f0844da5ffb24a45f4 -->
BunnyFl commented 2026-11-05 15:46:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T15:46:47Z.

Review: APPROVED


@EagleBearerYS re-checked at 75ffc81473. The only new commits are merges of main. git range-diff from 59a6f5e41e, the head I approved, shows all six of your commits unchanged.

On 75ffc81473 merged onto main 78e4248fea (Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, driver 32.0.32015.12012), ctest -V with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass, 2 of 2, and the hook's GPU path ran again ([hostwrite] 2 host writes, 1 waited for GPU work over their range). No missing-layer line and no VUID- message. As in my first review, a runtime negative control can't be built here: the tests use HostWritesCounted, which main doesn't have.

check_conventions.py passes. pr_overlap.py --branch finds no shared exports; #8707 shares lines in docs/dev/debt/libSceAgcDriver.md, and 60 PRs that conflict with main couldn't be compared.

Approving again at 75ffc81473.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5787748378 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6926#pullrequestreview-5787748378). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-05T15:46:47Z. **Review:** APPROVED --- @EagleBearerYS re-checked at `75ffc81473`. The only new commits are merges of `main`. `git range-diff` from `59a6f5e41e`, the head I approved, shows all six of your commits unchanged. On `75ffc81473` merged onto `main` `78e4248fea` (Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, driver 32.0.32015.12012), `ctest -V` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: `agc_driver_host_write_hook` and `agc_driver_host_write_pending_storage` pass, 2 of 2, and the hook's GPU path ran again (`[hostwrite] 2 host writes, 1 waited for GPU work over their range`). No missing-layer line and no `VUID-` message. As in my first review, a runtime negative control can't be built here: the tests use `HostWritesCounted`, which `main` doesn't have. `check_conventions.py` passes. `pr_overlap.py --branch` finds no shared exports; #8707 shares lines in `docs/dev/debt/libSceAgcDriver.md`, and 60 PRs that conflict with `main` couldn't be compared. Approving again at `75ffc81473`. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6926
No description provided.