Skip to content

fix(agc): compare pending storage results over a surface whose page walk fails - #12792

Open
EagleBearerYS wants to merge 17 commits into
boykopovar:mainfrom
EagleBearerYS:fix/agc-pending-layer-generation
Open

EagleBearerYS wants to merge 17 commits into
boykopovar:mainfrom
EagleBearerYS:fix/agc-pending-layer-generation

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What

When a page walk over a storage image stops part way, the surface's collect returns 0 while the range stays watched. The walk also reports the rest of its range as written by the CPU. StorageTexture::Refresh then sees the 64 KiB units that hold GPU results as CPU-written newer than their generations. It drops them, re-uploads them from guest memory, and prints guest memory changed while GPU results were pending; keeping the CPU's blocks. The write-back leaves the same blocks to the CPU.

  • The fix: when the surface's own collect fails, the refresh (scanBlocks) and the write-back (writeBackLayers) no longer read the walk's synthetic stamps as CPU stores.
    • On Linux, a PAGEMAP_SCAN that fails has already written out the dirty regions it found before the failure and re-protected those pages. The new GuestWriteWatchCollectReporting_nid_postfix and GuestWriteWatchCollectArmedReporting_nid_postfix report those regions as written, and the range the walk didn't finish as unreached. The old collect calls are unchanged.
    • The tracker keeps, per page, the genuine CPU stamp that a failed walk would otherwise cover with its synthetic one. A new ChangedBlocks overload answers per 64 KiB block: known (today's stamps), CPU-confirmed (a genuine store after the block's generation) or unknown.
    • The refresh and the write-back keep the stamps of known blocks, leave a CPU-confirmed block to the CPU, and compare only the unknown blocks with the guest bytes saved at the upload or the previous store, as they already do for memory outside the watch. Without saved bytes, or when the query can't answer, they compare the whole surface, as before.
    • On the failed-walk path, the write-back also leaves a block the walk saw the CPU write to the CPU whatever its bytes, as the refresh already does.
    • This PR's first version compared the whole surface on a failed walk. As oneandonlydean, XairRrR and mashingaan pointed out, that loses a same-value CPU store in a block the walk did reach (see Tested).
  • What stays open, recorded in docs/dev/debt/libSceAgcDriver.md:
    • a same-value CPU store in a page the walk never reached is still lost, since that block is compared by bytes;
    • a unit with no saved bytes over a failed walk is handled as outside the watch, so storing it throws;
    • a failed walk of a larger range still stamps the blocks of a surface whose own collect succeeds;
    • a kernel that writes out no regions before its PAGEMAP_SCAN error leaves the whole range unreached (Linux 6.18 writes them);
    • on a complete walk, main's write-back leaves a stamped block to the CPU only when its bytes differ, so a same-value store made while results are pending is overwritten there. That's main's existing rule, in its own entry, and isn't changed here;
    • on Windows, a same-value CPU store followed by a direct write-back with no refresh is lost when the walk over a compared shared page is refused ("guest memory holds 8 results and 0 stored words" on an RTX 3070 Laptop GPU), so that case doesn't run on Windows. With a refresh, or with a store of a different value, the store is kept.
  • Credit: reported by @sktharunbalaji13-cmd in Ghost of Tsushima Director's Cut (PPSA02225) (#9742 comment, #5166 comment). They traced it to markLayersPending and Refresh, and they're co-author of the commit.
    • Their first change stamped the layer's generation at markLayersPending. That doesn't reach the loss: the refresh's own failed walk stamps the blocks newer again. It would also hide a CPU store made between a refresh and the pending mark. Case 3 below covers that.
    • This change compares instead.
  • Platforms: in the tests, this PR's effect is shown on Linux, where the walk is made to fail by remapping a watched page. I found no production Linux path that does that. On Windows, the test reaches a refused walk through a compared shared page, but the surface's other blocks are collected one block at a time and keep the CPU stores, so the Windows case passes on main and on this PR alike. On Windows the title run below is the evidence.

Tested

  • agc_driver_pending_untracked_layer (new):
    • Setup: a watched surface, real image_store dispatches, then a readback through image_load. It sets APS5_NO_HOST_IMPORT=1 itself, so lavapipe doesn't take the range off the watch with an import, and it skips (77) on Windows.

      case main this change
      1. results over a surface whose walk fails red: 0 of 8 results survive, line printed green
      2. the same, with a CPU store to another block while pending red: 0 of 8 results, the CPU word kept green
      3. a CPU store over a result word between a refresh and the pending mark, with the walk complete green green: the image sees the CPU word
      4. the same as 3, with the walk failing green green
    • Red/green on Linux (Ubuntu 24.04, GCC 13.3, lavapipe, Release): red at run 1 of --repeat until-fail:10 on main's Texture.cpp, and 10 of 10 direct runs fail. Green, 10 of 10.

  • ctest -R '^agc' on this change: 1,118 tests, 1,045 passed, 73 skipped, 0 failed.
  • Ghost of Tsushima Director's Cut (PPSA02225, v02.024.000), @sktharunbalaji13-cmd's run (comment). Windows 11, RTX 4060 Laptop, 240 s.
  • GitHub, ×10 on both runners, with the Khronos validation comparison on Linux (run 40868832489):
    • Linux: agc_driver_pending_untracked_layer passed 10 of 10 under validation. With it, the ^agc_storage and ^agc_driver_storage tests ran 21 tests: 20 passed and 1 skipped, agc_storage_clear_hand_over, since lavapipe makes no watched host import.
    • Validation: the layer loaded on both sides, and the only VUID on main and with this change is VUID-VkDeviceCreateInfo-pNext-pNext, for an extension structure the layer predates. The change adds none.
    • Windows runner: 22 tests built and ran, and all skip, since the runner has no Vulkan device.
    • Suites: the libc and libkernel suites, run with APS5_SKIP_TIMING_TESTS=1, pass: 191 and 291 tests on Linux, 220 and 314 on Windows.
    • The new test doesn't exist on main, so the runner's comparison arm has no red. The red is the Linux one above.
  • Checks: MinGW-w64 -fsyntax-only on Texture.cpp and the test gives no warning on the changed lines. check_conventions.py passes, with no comment lines added.
  • 5e106c5, oneandonlydean's merge of main 88e804b. The one conflict was in docs/dev/debt/libSceAgcDriver.md, where this PR's page-walk entry sits among main's new write-watch entries; both sides are kept. This PR's diff over main is unchanged. On GitHub's runners (run, on 7ed1db8, the same merge with that entry one line higher), agc_driver_pending_untracked_layer and the ^agc_storage and ^agc_driver_storage tests ran 10 times with no failure. Linux: 24 run, 23 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. Windows: 25 run, 0 pass, 25 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 81ad915: a case that can't run no longer hides a failure, oneandonlydean's second point (comment). main() runs every case, requires that none came back Lost, and only then returns 77 if a case couldn't run. On GitHub's runners (run), agc_driver_pending_untracked_layer and the ^agc_driver_pending, ^agc_storage and ^agc_driver_storage tests ran 10 times with no failure. Linux: 25 run, 24 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. Windows: 26 run, 0 pass, 26 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • AMD Radeon RX 6700 XT (RADV, Mesa 26.2.5), by @crastinator (comment): 5e106c5 merged onto main a4eca2a, Linux, with the Khronos validation layer. The new test is red on main 3 of 3 and green on the merge 3 of 3. 22 tests under the layer give no new VUID; the gate's exit 1 comes only from agc_storage_clear_hand_over skipping on both sides.
  • NVIDIA RTX 2000 Ada Generation, TechLevelZero's NVIDIA bot (report): 81ad915 merged onto main 1d91f29, driver 595.99.02, Ubuntu 26.04.1. 2,621 passed, 3 failed (none new: all 3 fail on main) and 44 skipped, with no new validation IDs over 983 tests on the GPU.
  • 89c782b and 37a0eb9: the CPU stores a failed walk saw are kept, oneandonlydean's first point and the blocking finding in XairRrR's and mashingaan's reviews, on @sktharunbalaji13-cmd's plan, with them as co-author.
    • New cases in agc_driver_pending_untracked_layer: 5, a same-value CPU store in a block the walk reached before it failed on a later block, then a refresh; 6, the same, then a direct write-back (FlushAllPending) with no refresh. Each requires guest memory and the image to hold the 8 stored words and no results, and guest memory still to hold them after a last flush.
    • Red/green on GitHub's Linux runner (run): with 81ad915's code, cases 5 and 6 fail ("guest memory holds 8 results and 0 stored words, the image 8 results and 0 stored words"); with the change, the test passes 10 of 10.
    • ×10 on both runners (the same run): that test, the ^agc_driver_pending, ^agc_storage, ^agc_driver_storage and ^guest_memory tests, agc_collect_memo_generation, agc_import_watch and agc_write_watch_coverage. Linux: 32 run, 31 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. Windows: 31 run, 4 pass, 27 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Every agc and guest_memory test, once (run): Linux: 1,223 run, 1,145 pass, 77 skip, 1 fail. Windows: 1,258 run, 382 pass, 876 skip (no Vulkan device), 0 fail. The Linux failure is agc_driver_pipeline_journal's 120-second timeout, which main 7feb37e's own run of that test hits too (run).
    • Validation (run, Khronos layer on GitHub's Linux runner): agc_driver_pending_untracked_layer, agc_import_watch and the ^agc_storage and ^agc_driver_storage tests pass on both arms, and the change adds no VUID.
    • The kernel's behaviour, from a standalone probe on Linux 6.18: a PAGEMAP_SCAN that fails on a remapped page returns -1, but it has already written out the dirty regions before that page and re-protected them. Its walk_end gives the range end, so the whole unfinished range is reported unreached.
    • A complete-walk control (not committed): a same-value store, then a direct write-back, is lost with and without this change. That's main's rule, in its own debt entry.
    • Checks: each commit builds and passes its own tests. check_conventions.py passes, with no comment lines added. On a cloud Linux machine (lavapipe), ctest -R '^agc' runs 1,219 tests on both trees: 1,142 pass, 77 skip, 0 fail.
  • AMD Radeon RX 6300, TechLevelZero's AMD bot (report): 37a0eb9 merged onto main 7feb37e, RADV NAVI24, Mesa 25.2.8. 3,621 passed, 14 failed (none new: 12 fail on main too, 2 are unstable there) and 59 skipped, with no new validation IDs over 1,309 tests on the GPU.
  • NVIDIA RTX 2000 Ada Generation, TechLevelZero's NVIDIA bot (report): 37a0eb9 merged onto main 9090972, driver 595.99.02. 3,502 passed, 5 failed (none new: 3 fail on main too, 2 are unstable there) and 51 skipped, with no new validation IDs over 1,307 tests on the GPU.
  • 51249fe, test(agc): the walk-failure cases on Windows. The test no longer skips on Windows. There the surface is one section mapped into the guest arena, and the first page of block 3 is mapped a second time and compared when shared (GuestArenaCompareWhenShared), so a walk over the surface is refused, as on the production path.
    • A new case stores a CPU word of a different value in another block while results are pending, then takes a direct write-back with no refresh.
    • On an NVIDIA GeForce RTX 3070 Laptop GPU (Windows 11, WinLibs GCC 15.2.0, Release), with this PR's code: 3 of 3 runs pass. The same-value store followed by a refresh is kept, and so is the new case's store. The same-value store followed by a direct write-back is lost ("guest memory holds 8 results and 0 stored words, the image 8 results and 0 stored words"), so that one case doesn't run on Windows, and the debt entry records it.
    • The earlier cases on main's code: on the same GPU, before the same-value and new cases ran on Windows, the four earlier cases passed 3 of 3 with main 88e804b's code as well as with this PR's, also with the shared page moved under the results' block or the CPU word's block. So on Windows this case covers the refused-walk path without showing a loss.
    • ×10 on GitHub's runners (run), the set of the 37a0eb9 run. Linux: 32 run, 31 pass, 1 skip (agc_storage_clear_hand_over), 0 fail, with agc_driver_pending_untracked_layer passing 10 of 10. Windows: 31 run, 4 pass, 27 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Checks: check_test_registration.py and check_skips.py pass. Only the test and the debt file change, with no comment lines added.
  • NVIDIA RTX 2000 Ada Generation, TechLevelZero's NVIDIA bot (report): 51249fe merged onto main f6232fc, driver 595.99.02. 3,636 passed, 6 failed (none new: 3 fail on main too, 3 are unstable there) and 52 skipped, with no new validation IDs over 1,309 tests on the GPU.
  • 4e4cba9, oneandonlydean's merge of main d1ae628. The one conflict was in Execution/src/GuestMemory.cpp, where fix(agc): keep write-tracker generations 64-bit so they cannot wrap #14899 made the write-tracker generations 64-bit. The merge widens this PR's unreached-page tracker (UnreachedPage, noteUnreached, newestUnknownMark, provenCpuStore) to std::uint64_t with them, and agc_driver_pending_untracked_layer runs its cases a second time with the generation past 2^32 (AdvanceTrackerGenerationForTest). Apart from those types and that pass, this PR's diff over main is unchanged.
    • On an NVIDIA GeForce RTX 3070 Laptop GPU (Windows 11, WinLibs GCC 15.2.0, Release): agc_driver_pending_untracked_layer and main's five agc_write_tracking tests pass 3 of 3.
    • ×10 on GitHub's runners (run): the set of the 51249fe run, with main's agc_write_tracking tests and the compared-shared tests added. Linux: 34 run, 33 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. With main's implementation only agc_driver_pending_untracked_layer fails there, in cases 1 and 2 and in the same-value direct write-back case, in both generation passes. Windows: 40 run, 13 pass, 27 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (297 and 321) and on Windows (324 and 342). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • Debian 13, Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6), by @XairRrR (review): 4e4cba9 merged onto main d1ae628. agc_driver_pending_untracked_layer passes 3 of 3, with all 7 cases run in both generation passes, and 30 of 31 related tests pass, with 1 skip (agc_storage_clear_hand_over). There are no new VUIDs over 768 tests. With main's five production files, the test fails 3 of 3, in cases 1 and 2 and in the same-value direct write-back case, in both passes.
  • 26ed2ae, a merge of main 4f41f4c, which brings hugodearaujo's fix(agc): keep a CPU store that rewrote a pending block with its baseline bytes #14302 (a CPU store that rewrote a pending block with its baseline bytes is kept).
    • The one conflict: Graphics/src/Texture.cpp, in StorageTexture::writeBackLayers, on the line that decides whether a block was written. fix(agc): keep a CPU store that rewrote a pending block with its baseline bytes #14302 replaced its !unchangedSinceBaseline(from, to) with !cpuLeftUnchanged(layer, from, to, edge), and this PR had put cpuSeen (a CPU store that a failed walk saw) in front of that check. The merge keeps both: (cpuSeen || !cpuLeftUnchanged(layer, from, to, edge)), with this PR's byBytes where main has compared[layer], and in the skip condition below it, as before.
    • This PR's diff over main stays +723 −32 in 8 files; that line is the only one that changes.
    • ×10 (run): agc_driver_pending_untracked_layer, agc_collect_memo_generation, agc_import_watch, agc_write_watch_coverage and every test matching ^agc_driver_pending, ^agc_storage, ^agc_driver_storage, ^guest_memory or ^agc_write_tracking, with the compared-shared tests (agc_compared_shared_generations, agc_import_alias_shared, agc_resident_direct_remap, agc_rewatched_direct_shared) on Windows, the only runner that has them. Linux: 36 run, 35 pass, 1 skip (agc_storage_clear_hand_over), 0 fail; with main's implementation only agc_driver_pending_untracked_layer fails there. Windows: 42 run, 13 pass, 29 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 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.
    • Every agc and guest_memory test, once (run): Linux: 1,277 run, 1,193 pass, 83 skip, 1 fail. Windows: 1,313 run, 402 pass, 911 skip (no Vulkan device), 0 fail. The Linux failure is 751/1277 Test #1389: agc_driver_pipeline_journal ...........................................***Timeout 120.06 sec, the 120-second limit that main's own run of that test reaches too (see the 37a0eb9 sweep above); this PR doesn't touch the journal.
  • 4f13bb4, a debt note (docs only), for XairRrR's review: since fix(agc): keep a CPU store that rewrote a pending block with its baseline bytes #14302, the cpuSeen term is untested for a block the layer covers only in part and for a layer with no pending stamp, which this PR's fixture doesn't reach.
  • e14b677 and a3bb73f, debt notes (docs only), for XairRrR's review: the same-value write-back entry is narrowed to the cases fix(agc): keep a CPU store that rewrote a pending block with its baseline bytes #14302 left open, a block the layer covers only in part and a layer with no pending stamp. The Windows refused-walk entry and its skip stay: with the skip lifted on the merged code, the same-value direct write-back case still fails 3 of 3 on an RTX 3070 Laptop GPU (driver 617.42, Windows 11, WinLibs GCC 15.2.0, Release) with "guest memory holds 8 results and 0 stored words", in both generation passes, and the other six cases pass.
  • 3317dcb, a merge of main b5a9a47, which brings Tehshortbus's perf(libc, libkernel): keep aliased direct memory on the Linux write watch and collect stores through every alias #12452 (aliased direct memory stays on the Linux write watch, and a collect takes stores through every alias).
    • The one conflict: libc/src/GuestWriteWatch.cpp. perf(libc, libkernel): keep aliased direct memory on the Linux write watch and collect stores through every alias #12452 rebuilt Collect, CollectFresh and CollectArmed around a Fanout, which reports a written range at its own address and at every alias in an alias plan. This PR had given Collect and CollectArmed an unreached callback for the pages a failed walk couldn't read. The merge keeps both. Fanout carries unreached beside written, and Fanout::ReportUnreached reports an unreached range at every alias address, the same way Report does for a written range. When a step of Collect or CollectArmed fails, the aliases it hasn't reached yet are reported unreached too, and so are their armed parts for CollectArmed. CollectFresh keeps perf(libc, libkernel): keep aliased direct memory on the Linux write watch and collect stores through every alias #12452's loop and reports nothing unreached, as before. This PR's takeFresh and scanWritten merged without a conflict.
    • Not covered by a test: reporting an unreached range at every alias address, and marking the remaining aliases unreached when a step fails. agc_driver_pending_untracked_layer makes a walk fail with no alias. perf(libc, libkernel): keep aliased direct memory on the Linux write watch and collect stores through every alias #12452's alias tests collect through aliases, but no walk fails in them. So no test runs an unreached report over an aliased range.
    • Diff: the other 7 files' changed lines are unchanged. This PR's diff over main goes from +724 −32 to +776 −46 in 8 files, all of the change in GuestWriteWatch.cpp.
    • ×10 (run): agc_driver_pending_untracked_layer, agc_collect_memo_generation, and every test matching ^agc_driver_pending, ^agc_storage, ^agc_driver_storage, ^agc_write_tracking, ^agc_write_watch, ^write_watch, ^windows_write_watch or ^guest_memory.
      • Linux: 43 run, 42 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. agc_driver_pending_untracked_layer passes 10 of 10.
      • Windows: 48 run, 13 pass, 35 skip (no Vulkan device), 0 fail. agc_driver_pending_untracked_layer is among the skips, as on every earlier Windows-runner run of this PR.
      • Suites: libc and libkernel run 344 and 346 tests on Linux and 375 and 373 on Windows, with 0 failed. They ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners. main's Windows guest_standard_streams failure (libc: guest_standard_streams aborts on Windows because a second ungetc on an unbuffered stream fails #17423) didn't show up in these runs.
    • Every agc test, once (run): Linux: 1,453 run, 1,361 pass, 92 skip, 0 fail. Windows: 1,493 run, 445 pass, 1,048 skip (no Vulkan device), 0 fail.
    • GPU runs on 3317dcb: Lucke0051's two Linux GPUs (below). The RTX 3070 Laptop runs and TechLevelZero's bot reports above are on the heads they name. The Windows unreached path, the refused walk over a compared shared page, has had no GPU run since this merge.
  • NVIDIA GeForce RTX 3070 Ti and Intel UHD Graphics 630 (CML GT2), by @Lucke0051 (comment): 3317dcb merged onto main 0245231, CachyOS (Linux 7.3.1), GCC 16.2.1, Release, ctest -R '^(agc|video_out|shader)', against main on the same machine. Both GPUs (NVIDIA 615.78.08; Mesa 26.2.6) show no difference from main, and agc_driver_pending_untracked_layer passes on both. No validation layer was installed there.
  • 7219255, a merge of main ea32608 (×10, every agc test), which brings JJenkx's perf(agc): scope pending texture snapshots to unwatched units #18940 (a pending texture's snapshot at an unwatch covers only the units the unwatched range meets, and when the write-watch query over the whole range fails, each unit is queried on its own).
  • a124bdd, a merge of main 790e9a3 (×10, ×10 with the Windows test fix, every agc test), which brings Ducengarth's fix(agc): renew a storage image's upload copy when its range leaves the watch #17788 (a storage image's upload copy is renewed when its range leaves the write watch).
    • The conflict: docs/dev/debt/libSceAgcDriver.md only. fix(agc): renew a storage image's upload copy when its range leaves the watch #17788 rewrote the "Units without a baseline outside the write watch" entry, right before this PR's four entries. The file merges with merge=union, which would keep the old copy of that entry next to the new one, so the merge takes fix(agc): renew a storage image's upload copy when its range leaves the watch #17788's entry and keeps this PR's four after it.
    • Diff: this PR's changed lines are the same in all 8 files, and its diff over main stays +776 −46. Only context lines moved: that debt entry, and chitters2004's perf(agc): answer a write-watch collect from a per-block observation table #17766 lines next to this PR's in tests/CollectMemoGeneration.cpp. Texture.cpp, where fix(agc): renew a storage image's upload copy when its range leaves the watch #17788 also changes StorageTexture, merged without a conflict.
    • ×10: the set of the 7219255 run. Linux: 54 run, 53 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. Windows: 64 run, 19 pass, 45 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 388 and 384 tests on Linux and 418 and 412 on Windows, with 0 failed. They ran with APS5_SKIP_TIMING_TESTS=1, which relaxes only precise_wait's median bounds on GitHub's hosted runners.
    • Every agc test, once, on Linux: 1,801 run, 1,677 pass, 114 skip, 10 fail.
      • Seven also fail in main's own Linux job at 3e1b183 (job): agc_driver_global_atomic_csub, agc_driver_stencil_copy_draw, agc_driver_coherent_atomic_loads_enabled, agc_driver_image_table_packed_guards, agc_driver_recorder, agc_draw_input_mirrors and agc_draw_input_reuse.
      • The other three passed there: agc_driver_frame_replay_rewind_copy ("FAILED: no memory delta was read while 1 submissions waited for the CPU") and the agc_driver_runtime_buffer_spans_x3_spans and _x4_spans timeouts. Over 10 runs of main 790e9a3 with fix(tests): set the upload cache test's environment with _putenv_s on Windows #19899's test-only commit on top (run), all three fail too, frame_replay_rewind_copy with the same message. Over 10 runs of this merge (run), frame_replay_rewind_copy passes 10 of 10, and the span tests fail as on main.
    • The Windows tree: as for 7219255, the Windows runs had Sankalp7317's #19899 on top, since main's Windows test build still stops at "'setenv' was not declared" in UploadCacheReadOnlyFlush.cpp (from perf(agc): reuse read-only guest buffer uploads #18037). It isn't on this branch. The Windows builds of the first ×10 and of the agc run, on this head alone, stopped at that error.
    • No GPU run on a124bdd.
  • 095d749, a merge of main 0694c4c (×10, every agc test), which brings klosixgaming-arch's perf(agc): return settled imports under live storage images to the write watch #19071 (settled imports under live storage images go back to the write watch).
    • The conflict: the four hunks in Graphics/src/Texture.cpp planned under Overlap, resolved as described there. The declarations keep this PR's unknownBlocks and perf(agc): return settled imports under live storage images to the write watch #19071's rewatchCompared. scanBlocks keeps this PR's ChangedBlocks read, taken only when the surface's own collect succeeded, with perf(agc): return settled imports under live storage images to the write watch #19071's confirmRewatched call after it. droppable keeps both cases in one condition. writeBackLayers keeps this PR's unknownBlocks, and perf(agc): return settled imports under live storage images to the write watch #19071's confirmRewatched call now follows this PR's walked && ChangedBlocks line.
    • Diff: over main it is +777 −47 in the same 8 files, against +776 −46 before. The changed lines are the same, apart from where perf(agc): return settled imports under live storage images to the write watch #19071's code meets this PR's: the droppable condition this PR extends now also holds perf(agc): return settled imports under live storage images to the write watch #19071's rewatched-unit case, and perf(agc): return settled imports under live storage images to the write watch #19071's confirmRewatched call in writeBackLayers moves after this PR's ChangedBlocks line.
    • ×10: the set of the a124bdd run. Linux: 55 run, 54 pass, 1 skip (agc_storage_clear_hand_over), 0 fail. Windows: 66 run, 19 pass, 47 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 391 and 390 tests on Linux and 421 and 417 on Windows. On Windows, 0 failed. On Linux, libkernel's guest_thermal_sensors reached its 20 s timeout. It times out in every run I have on GitHub's Intel Xeon 6975P-C runners, main 0694c4c alone included (run), and passes on GitHub's other runners and in main's own job. This PR changes no libkernel file. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes only precise_wait's median bounds on GitHub's hosted runners.
    • Every agc test, once: Linux: 1,867 run, 1,739 pass, 116 skip, 12 fail. Windows: 1,909 run, 558 pass, 1,351 skip (no Vulkan device), 0 fail.
      • Eight also fail in main's own Linux job at 0694c4c (job): agc_driver_global_atomic_csub, agc_driver_stencil_copy_draw, agc_driver_coherent_atomic_loads_enabled, agc_hook_clear_access, agc_hook_clear_access_off, agc_driver_recorder, agc_draw_input_mirrors and agc_draw_input_reuse.
      • agc_driver_image_table_packed_guards fails the same way in main's own Linux job at e249fc4 (job): three identical "stage 4 pc 0x68" records, then "unrecoverable packed table format was not poisoned". fernandomcrsilva's open test(agc): keep the packed image table guard programs at different addresses #21255 changes that test.
      • The agc_driver_runtime_buffer_spans_x2_spans, _x3_spans and _x4_spans timeouts: main's own Linux job passes them at 0694c4c, in 3.09, 3.79 and 4.16 s, and times them out at dcf3d15 (job), together with _x4_reference. On GitHub's runners, ×10 of the span tests with this PR's set in both arms, main 0694c4c (run, Intel Xeon 6975P-C) and this merge (run, AMD EPYC 9V74) differ by little. The merge's passing medians are 0.99 to 1.12 of main's: runtime_buffer_spans 3.92 and 3.90 s, _x2_reference 1.55 and 1.66 s, _x3_reference 1.89 and 2.08 s, _fault_stop 0.205 and 0.230 s, _fault_barrier 0.210 and 0.230 s. Its timeouts are the four main's own job shows at dcf3d15. The two arms ran on different CPUs. For scale, main's own code takes 0.68 to 0.78 of the time on the Xeon that it takes on an AMD EPYC 7763 (run), and two runs of this merge on the same EPYC 9V74 differ from each other by up to 20% (run).
    • The Windows tree: as before, the Windows runs had Sankalp7317's #19899 on top; it isn't on this branch.
    • A GPU run on 095d749: @domx4q's RTX 4090 run with the validation layer (below).
  • NVIDIA GeForce RTX 4090, by @domx4q, with the Khronos validation layer (comment): Arch Linux (kernel 7.3.4), GCC 16.2.1 Release, driver 620.70.06, Vulkan 1.4.357, validation layer 1.4.363.1, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1. This head 095d749 merged onto main e4caa07 (a clean merge), against main e4caa07 alone, ctest -R '^agc_(driver_pending|collect_memo_generation|storage|driver_storage|write_tracking|write_watch_coverage|import_watch)'. main: 45 of 45 pass. This PR: 46 of 46 pass, including agc_driver_pending_untracked_layer, which main doesn't have, run on the RTX 4090 (no skip). No VUID- line on either side, and every device test selected the RTX 4090.
  • Ghost of Tsushima Director's Cut (PPSA02225) on plain main, by @milescoviello (comment): Ubuntu 26.04.1, NVIDIA GeForce RTX 4070 Ti (driver 615.71.09), Release libraries, main eb20410 against its merge with 095d749, 3 runs per arm of up to 600 s from a pinned save with a cold shader cache.
    • The line: every run logs keeping the CPU's blocks 8 times, all during setup. Without the stack above, this title doesn't reach the per-frame case, so the run can't show the fix, as expected.
    • The rest: after Continue the screen stays black in both arms. A phase of 1-2 presents per 10 s, at 1-4 s of GPU per present, came in one main run and two of this PR's runs; they read it as varying from run to run rather than following the change. The two PR runs with the most of it also had the highest RSS (25.0 and 24.1 GB, one killed at the 22G cap at 393 s, against 19.2 to 20.3 GB for main). main's third run entered the same phase and was killed at 237 s, so they don't read the memory difference as coming from this PR.

Overlap

Checklist

…alk fails

A page walk that stops part way reports the rest of its range as written
by the CPU and leaves the range watched, so the collect of the surface
returns 0 while every block reads as a CPU store newer than the units'
generations. The refresh then dropped the pending 64 KiB units holding
GPU results, re-uploaded them from guest memory and printed "guest memory
changed while GPU results were pending"; the write-back left the same
blocks to the CPU.

When the surface's own collect fails, the refresh and the write-back now
take the untracked path and compare the guest bytes with the ones saved
at the upload or the previous store, as for memory outside the watch.

Co-authored-by: Tharun Balaji K <239791575+sktharunbalaji13-cmd@users.noreply.github.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@EagleBearerYS thanks, the change is narrow: only a watched surface whose own walk fails now takes the existing compare path. Two independent reviews; one correctness point and one test point.

  1. The fallback can hide a real same-value CPU store in a successfully walked part of the surface when a later unrelated page makes the collect fail. For example: saved guest word A, pending GPU result B, CPU stores A again to that result word, then the surface walk fails on a later page. The new whole-surface comparison sees A == saved A and marks the block unchanged, discarding the watch evidence of the real CPU store; B then survives over the CPU value. This differs from the existing rule that CPU-written blocks win while results are pending.

Please retain confirmed CPU-write provenance from successfully walked pages/blocks while separating synthetic failure stamps, or use an equivalently sound rule. Add the same-value-store case with an unrelated later failed page. Please cover both Refresh and direct write-back without a preceding Refresh resolving the state. The current distinct-value CPU edit in another block does not discriminate this case. Windows production-path coverage is also needed; the new executable currently skips there.

  1. In PendingUntrackedLayer.cpp, main() returns VulkanTestSkipped as soon as any case reports NotRun, even when an earlier case already came back Lost. If only a later case can't run somewhere, a real failure would show up as a skip. Could it fail when kept is already false before returning 77, or skip only the cases that couldn't run?

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 862 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6186 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7668 docs/dev/debt/libSceAgcDriver.md
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9289 docs/dev/debt/libSceAgcDriver.md
PR 9356 docs/dev/debt/libSceAgcDriver.md
PR 9387 docs/dev/debt/libSceAgcDriver.md
PR 9508 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/CollectMemoGeneration.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9748 docs/dev/debt/libSceAgcDriver.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9915 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11551 docs/dev/debt/libSceAgcDriver.md
PR 11587 docs/dev/debt/libSceAgcDriver.md
PR 11825 docs/dev/debt/libSceAgcDriver.md
PR 12568 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 12746 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 12904 docs/dev/debt/libSceAgcDriver.md
PR 13147 docs/dev/debt/libSceAgcDriver.md
PR 13809 docs/dev/debt/libSceAgcDriver.md
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13928 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13929 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 14473 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 14944 docs/dev/debt/libSceAgcDriver.md
PR 14964 docs/dev/debt/libSceAgcDriver.md
PR 15058 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15456 docs/dev/debt/libSceAgcDriver.md
PR 15529 docs/dev/debt/libSceAgcDriver.md
PR 16260 docs/dev/debt/libSceAgcDriver.md
PR 16372 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 16427 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 16879 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 16953 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 18082 docs/dev/debt/libSceAgcDriver.md
PR 18173 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 18177 docs/dev/debt/libSceAgcDriver.md
PR 18293 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 18956 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 19610 docs/dev/debt/libSceAgcDriver.md
PR 19821 docs/dev/debt/libSceAgcDriver.md
PR 20010 docs/dev/debt/libSceAgcDriver.md
PR 20041 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 20153 docs/dev/debt/libSceAgcDriver.md
PR 20183 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 20580 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libc/include/GuestWriteWatch.hpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 20728 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 21155 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 21669 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 22029 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 22062 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 22156 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 22190 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 22434 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 22531 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 22731 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 23234 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 23739 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 23976 core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 24060 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 24444 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 24445 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 26069 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libc/include/GuestWriteWatch.hpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 26646 core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 26819 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 27133 docs/dev/debt/libSceAgcDriver.md
PR 27984 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28090 docs/dev/debt/libSceAgcDriver.md
PR 28118 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28119 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28164 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28169 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28176 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28193 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28198 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28214 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28238 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28240 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28264 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28268 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28291 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28292 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28293 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28304 core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 28319 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 28333 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28411 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 28470 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libc/include/GuestWriteWatch.hpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 28559 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 28583 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28681 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28765 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28793 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28808 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 28894 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28908 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28937 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28945 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28952 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28953 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/tests/CollectMemoGeneration.cpp
core/libs/prx/libc/include/GuestWriteWatch.hpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 28957 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28958 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28963 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28966 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28970 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28975 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28980 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28983 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28984 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 28985 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28986 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 28995 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 29012 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 29013 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 29070 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/tests/CollectMemoGeneration.cpp
core/libs/prx/libc/include/GuestWriteWatch.hpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 29072 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/tests/CollectMemoGeneration.cpp
core/libs/prx/libc/include/GuestWriteWatch.hpp
core/libs/prx/libc/src/GuestWriteWatch.cpp
PR 29074 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 29082 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 29083 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 29084 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 29085 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 29089 core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
PR 29095 docs/dev/debt/libSceAgcDriver.md
PR 29218 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp

@sktharunbalaji13-cmd

Copy link
Copy Markdown
Contributor

@oneandonlydean Thank you for the insightful and precise review! Both points are spot-on.

Here is the architectural breakdown and the concrete plan to address both points cleanly:

1. Retaining Confirmed CPU-Write Provenance vs. Synthetic Failure Stamps

The Root Cause of the Inversion

In GuestWriteWatch.cpp (scanWritten), when ioctl(_pagemap, PAGEMAP_SCAN, ...) returns < 0 at cursor < end:
cpp if (count < 0) { written(context, cursor, end); return false; }
Calling written(context, cursor, end) invokes stampWrittenRun, applying StampKind::Cpu across [cursor, end). These synthetic stamps were indistinguishable from genuine CPU dirty pages reported by
egions[i] earlier in [begin, cursor).

Because commit 7664a30 treated the entire surface as untracked whenever current == 0 (or !walked), falling back to compareUntracked against original caused a same-value CPU store ( \to A$) in a successfully walked block ($[begin, cursor)$) to evaluate as BlockUnchanged. The watch evidence was discarded, allowing pending GPU result $ to survive over the CPU store.

Proposed Resolution

  1. Separate Synthetic Failure Stamps from Confirmed Stores:
    • In scanWritten, do not pass unreached range [cursor, end) to written with StampKind::Cpu. Instead, record unreached blocks into racker.refused (matching Windows
      oteRefusedWalk behavior) or report them via a dedicated failure callback.
    • Consequently, racker.cpuStampOf(block) > generation strictly represents confirmed CPU stores from successfully scanned pages.
  2. Selective Untracked Fallback (Block-Level Rather Than Whole-Surface):
    • In both StorageTexture::refresh() and StorageTexture::writeBackLayers():
      • For blocks that walked successfully: if cpuBlocks[k] != 0 (or cpuStampOf > generation), the CPU write wins unconditionally (even if same-value). GPU pending results in those blocks are dropped. If cpuBlocks[k] == 0, the block is confirmed clean; GPU results are kept without comparing.
      • For blocks whose walk failed (tracked via racker.refusedSince): write-watch evidence is unavailable. Only for those failed blocks do we invoke compareUntracked against original. If unchanged, GPU results survive; if changed, CPU wins.
    • This covers both Refresh() and direct writeBackLayers() without a preceding refresh.

2. Windows Coverage & Test Harness

  1. Test Skipping Logic:
    • In PendingUntrackedLayer.cpp, record �ool anySkipped = false;. If outcome == Outcome::NotRun, verify Require(kept, ...) before skipping, ensuring an earlier failure (Outcome::Lost) is never swallowed by a later skipped case.
  2. Windows Walk-Failure Coverage:
    • On Windows, a walk failure can be cleanly produced on the production path via GuestArenaCompareWhenShared_nid_no_patch(address, bytes) over a secondary shared mapping (matching the production mechanism for compared shared host imports and WindowsWriteWatch.cpp), allowing the entire test suite to execute on Windows without skipping.

@oneandonlydean oneandonlydean self-assigned this Oct 29, 2026
@TechLevelZero

TechLevelZero commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 87b51a6 merged onto main 0836dfd · tested 2026-11-01 00:56 UTC · 22 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,396 passed · 6 failed (0 new, 4 also fail on main, 2 unstable on main) · 44 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,446 of 3,087 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (925 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_lookup_log_fits_build 71.9 s, ⚠️ agc_driver_pipeline_journal 40.7 s, ⚠️ agc_driver_graphics_maps_fallback 30.2 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_submit_progress: failed in 7 of the last 10 main runs
agc_submit_progress_no_timeline: failed in 9 of the last 10 main runs
Failing on main too (4, not counted against this PR)
agc_driver_idle_store_yields
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_driver_pending_untracked_layer
Validation IDs already present on main (4 IDs in 475 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (475 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 467 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkShaderModuleCreateInfo-pCode-08737 (1 test): agc_driver_image_sample_derivatives
Skipped (44)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fresh: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_f
Reproduce
git fetch origin 87b51a63b991a0f3b9ee51a6039566c0e64abb35 0836dfdf4fecb1e0326100c490476e15d3a74da5
git checkout 0836dfdf4fecb1e0326100c490476e15d3a74da5 && git merge --no-ff 87b51a63b991a0f3b9ee51a6039566c0e64abb35
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

# Conflicts:
#	docs/dev/debt/libSceAgcDriver.md
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed labels Nov 2, 2026
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 5e106c5 merged onto main 88e804b · tested 2026-11-02 11:11 UTC · 23 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,498 passed · 5 failed (0 new, 3 also fail on main, 2 unstable on main) · 45 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,548 of 3,234 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (971 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s, ⚠️ agc_driver_graphics_maps_fallback 32.2 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 2 of the last 10 main runs
agc_submit_progress_no_timeline: failed in 8 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_driver_pending_untracked_layer
Validation IDs already present on main (4 IDs in 497 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (497 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 489 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkShaderModuleCreateInfo-pCode-08737 (1 test): agc_driver_image_sample_derivatives
Skipped (45)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fps_limit: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_o
Reproduce
git fetch origin 5e106c566dda63169ca2accc08b7b0008994918d 88e804b0a7df1f1ac373a9e2f72fb378d925fdd4
git checkout 88e804b0a7df1f1ac373a9e2f72fb378d925fdd4 && git merge --no-ff 5e106c566dda63169ca2accc08b7b0008994918d
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 2, 2026
@crastinator

Copy link
Copy Markdown

AMD RDNA 2 on RADV, which the Tested section and the later runs here don't cover (lavapipe and NVIDIA). No regression, and the new test goes from red to green on this GPU. This run doesn't bear on the open points from the 2026-10-29 review; details below.

Setup: RX 6700 XT (1002:73df, NAVI22), Mesa 26.2.5 (RADV), Linux 7.3.1 (CachyOS), GCC 16.2.1, Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, VK_LAYER_KHRONOS_validation 1.4.363. VK_LOADER_DEBUG=layer shows the layer inserted on a run of agc_driver_pending_untracked_layer, and the log shows this GPU selected.

Commits: head 5e106c566d merged locally onto main a4eca2a056 (merge 29f4fb30de, clean), against main a4eca2a056.

tools/vulkan_validation_gate.py, exit 1, 3 iterations per side, 22 tests: those matching ^agc_storage|^agc_driver_storage|^agc_driver_pending, except the ones below. No new VUID or sync-hazard IDs, and neither side reported any.

  • The exit 1 comes only from agc_storage_clear_hand_over, which the gate counts as a problem because it skips. It skips on both sides in all 3 iterations: host imports are compared on this device: clear-key hand-over (watched) not tested. The other 21 pass on both sides.
  • agc_storage_idle_writeback_race and agc_storage_write_back declare timeouts longer than the gate allows. Run separately, 2 of 2 on each side.

New test: agc_driver_pending_untracked_layer isn't on main, so the gate can't compare it. It ran separately with the same environment.

  • At the merge it passes 3 of 3, with no VUID- lines. No case printed not run, so all four ran rather than one being hidden by the early skip.
  • main with only this PR's PendingUntrackedLayer.cpp fails 3 of 3:
AGC graphics: pending storage results or a CPU store over a write-watched surface were lost

keeping the CPU's blocks prints 4 times per run on that control and 3 times per run at the merge. The test doesn't report per case, so this run doesn't show which case each print belongs to.

What this doesn't cover:

  • The 2026-10-29 review: the test has no same-value CPU store case, so this says nothing about that point. The Linux walk failure here comes from the test remapping a watched page, not from a production path.
  • The test's own setup: it sets APS5_NO_HOST_IMPORT=1, so RADV's host-import behaviour isn't exercised. This device compares host imports by default.
  • Also not tested: Ghost of Tsushima or any other title, and Windows. Synchronization validation wasn't turned on, so these runs can't rule out sync hazards.

Same on both sides, unrelated to this PR: agc_driver_storage_flush_ordering prints the write-back did not retile both units into the unit shadow: the shadowed-unit case is skipped.

AI-assisted: yes

@mashingaan mashingaan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current head still has the same-value CPU-store loss described in the earlier issue review. The new test only writes a distinct value in another block, so it does not exercise the case where the guest bytes equal the saved baseline but a real CPU store must still win. Please preserve successful CPU-write provenance across a later failed page walk, or otherwise distinguish confirmed writes from synthetic failure stamps, and cover both Refresh and direct write-back.

if (!tracked) awaitStoredSave(nullptr);
tracked = current != 0 && GuestMemory::ChangedBlocks(descriptor.baseAddress, static_cast<std::size_t>(guestBytes), generations, stampedBlocks, cpuBlocks);
if (!tracked) {
std::fill(stampedBlocks.begin(), stampedBlocks.end(), GuestMemory::BlockWritten);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a partial walk failure, this marks every block as written. compareUntracked then has to infer CPU writes from byte differences against the saved snapshot. If the CPU really stores the same value as the snapshot to a block with a pending GPU result, that comparison cannot see the store, and the GPU result can overwrite it. Please retain the confirmed write-watch stamps for the successfully walked part and distinguish them from the synthetic stamps for the failed part.

@XairRrR XairRrR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

The fix builds, the new test passes and fails on main's Texture.cpp, but I reproduced the open same-value-store point. When the walk fails on a later page, GPU results overwrite a CPU store that the successful part of the walk had recorded. The path that walks the whole surface keeps that store.

What I ran

Head 5e106c566dda63169ca2accc08b7b0008994918d, main 9090972b7e91fd266819cbd77a8b058e177b5682, merged tree d50c2a238617b5054bb243dbd17474bd57ec10db. Debian 13 VM, Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19), Release.

git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...5e106c566dda63169ca2accc08b7b0008994918d
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682
ctest --test-dir build -R '^agc_driver_pending_untracked_layer$' --repeat until-fail:3 --output-on-failure
build/tests/agc_driver_pending_untracked_layer_tests
# negative control
git show 9090972b7e91fd266819cbd77a8b058e177b5682:core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
ninja -C build agc_driver_pending_untracked_layer_tests
build/tests/agc_driver_pending_untracked_layer_tests   # x3
# same-value probe (temporary local edit of the test, merged Texture.cpp)
ninja -C build agc_driver_pending_untracked_layer_tests
build/tests/agc_driver_pending_untracked_layer_tests   # x3
# restore merged files, rebuild, rerun, git status --porcelain (clean)

Results

Check Result
git diff --check clean
check_conventions.py passed
Build (script) and the tests it selected 2033 ran, 0 new failures, 0 timeouts; the 7 known failures also fail on main
Vulkan validation comparison (script) 758 tests, layer loaded in 757 and missing in none, 0 new VUIDs
agc_driver_pending_untracked_layer (merged) passed 3/3, about 0.6 s; all four cases ran (no not run line)
Negative control (main's Texture.cpp) failed 3/3
Same-value CPU store probe the CPU store is lost when the walk fails (see below)
Negative control output (each of 3 runs)
[pending untracked layer] results over a surface whose walk fails: the image holds 0 of 8 results, guest memory 0, CPU words 0, CPU write reported 1
[pending untracked layer] results and a CPU store over a surface whose walk fails: the image holds 0 of 8 results, guest memory 0, CPU words 1, CPU write reported 1
AGC graphics: pending storage results or a CPU store over a write-watched surface were lost
exit=1
Same-value probe output (identical in 3 of 3 runs)

What the probe does: after the first store (guest holds Stored, which is also the saved baseline), the StoreAgainCode result is held pending. The CPU then stores Stored again to the first result word, in block 0, and Refresh runs. One case remaps the block 3 page (LoseWalk), so the walk succeeds over block 0 and fails later. The other case keeps the walk complete.

[probe] same-value store, walk fails: image 8 StoredAgain, guest 8 StoredAgain, 0 Stored
[probe] same-value store, walk complete: image 0 StoredAgain, guest 0 StoredAgain, 8 Stored
  • Walk complete: the existing tracked path sees the CPU store in block 0 and leaves the block to the CPU.
  • Walk fails on block 3: the same store, in a block the walk reached, is discarded and the GPU results overwrite it.

The probe's non-zero exit came only from the probe case's own pass condition. It was a local edit and is not part of the PR.

Negative control

I restored core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp from main and rebuilt the test executable:

  • On main's code: the new test failed 3 of 3 runs, in cases 1 and 2, matching the description's main column.
  • After restoring the merged file: it passes.

git status --porcelain was empty afterwards.

Findings

Blocking

  1. A failed walk on a later page discards confirmed CPU stores from the part the walk reached. This is at core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2355-2363 for the refresh, and at Texture.cpp:6490 and Texture.cpp:6500 for the write-back.
    • What the code does: when current == 0 or walked is false, both paths drop every stamp from ChangedBlocks and decide only by comparing bytes with the saved baseline.
    • Why it matters: a CPU store that writes back the baseline value, in a block whose pages were walked and stamped, now reads as unchanged. The pending GPU results then win over it. Normally the CPU wins whenever the watch saw it write while results were pending.
    • Status: oneandonlydean raised this in the 2026-10-29 review and mashingaan in the change request on this head. The reply describes a plan, but no change has been pushed. The probe above is new evidence that it happens on the merged tree.
    • Debt entry: docs/dev/debt/libSceAgcDriver.md:193 does not record this loss.
    • Suggested fix: keep the stamps for the pages the walk reached, and treat only the unreached part as unknown. For example, stop scanWritten from stamping [cursor, end) as CPU writes, or report that part separately. Compare bytes only for blocks in the unreached part.
    • Test: add a same-value store case with the failure on an unrelated later page, for Refresh and for a direct write-back with no Refresh first.

Non-blocking

  1. A later skipped case can hide an earlier failure. At core/libs/prx/libSceAgcDriver/tests/execution/PendingUntrackedLayer.cpp:372, main() returns VulkanTestSkipped on the first NotRun, even when an earlier case already came back Lost. oneandonlydean raised this on 2026-10-29 and it is still there. Fail when kept is already false before returning 77, or skip only the cases that cannot run.
  2. The Windows path has no test. The new executable always skips on Windows, so the production path the description names for Windows (collectWindowsWrites failing, then noteRefusedWalk) is not tested. The debt entry should at least say so if no test can reach it.

Not verified

  • Windows: not built or run here, including the noteRefusedWalk path.
  • Hardware GPUs: only lavapipe here. The RADV and NVIDIA runs in the discussion were not repeated.
  • The title: Ghost of Tsushima (PPSA02225) was not launched, so the title evidence was not checked.
  • Probe coverage: the probe covers only Refresh on Linux, with a page remapped by the test. I did not build a direct write-back variant.

To get this to a good state

  • Keep the stamps: keep the walk's CPU stamps for the pages it reached, and limit the byte comparison to the part it did not reach. Cover this with a same-value store test, for Refresh and for a direct write-back.
  • Fix the skip: make the test fail rather than skip when an earlier case was lost.
  • Update the debt entry: have it state what is still open after the fix, including the missing Windows coverage.
  • Ask for re-review: re-request review from mashingaan once it is pushed.

@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 2, 2026
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@oneandonlydean sorry for leaving this four days without an answer. Both points are fair.

2. The skip. Fixed in 81ad915. A case that can't run no longer returns 77 before the other cases are checked: main() runs every case, requires that none came back Lost, and only then reports a skip. A real failure now fails even when a later case can't run.

1. The same-value store. You're right that the whole-surface compare throws away the watch evidence of a store in a walked block. I'm building the fix on @sktharunbalaji13-cmd's plan above:

  • the walk reports the range it never reached apart from the pages it did reach, so a confirmed CPU stamp keeps winning;
  • only the blocks the walk never reached are compared with the saved words.

It comes with the cases you asked for:

  • a same-value store with an unrelated later failed page, through Refresh and through a direct write-back with no Refresh before it, each shown failing without the fix and passing with it;
  • a Windows walk failure on the production path, through GuestArenaCompareWhenShared_nid_no_patch over a shared view. GitHub's Windows runner has no Vulkan device, so that case runs on a GPU machine.

@sktharunbalaji13-cmd, it's your plan. If you'd like to push it yourself, say so and I'll leave it to you. Otherwise it goes in with you as co-author.

Thanks also to @mashingaan and @XairRrR for their reviews, and to XairRrR for the probe that reproduces the Refresh case.

@XairRrR XairRrR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — changes still requested

The one new commit, 81ad915, changes how the test handles a skipped case: an earlier failure now fails the test instead of being reported as a skip. Texture.cpp did not change, so the blocking same-value CPU-store loss from my last review is still open.

What changed since my last review

  • New commit 81ad915d78: it changes only PendingUntrackedLayer.cpp. A case that cannot run (NotRun) is now noted and skipped over. main() checks that no case was Lost before it returns 77.
  • Same production code: git diff 5e106c566d 81ad915d78 touches no other file. Texture.cpp and the debt entry are the same as in the head I reviewed last time.
  • Author reply (2026-11-02): EagleBearerYS agrees with the same-value-store point. They describe a fix: keep the confirmed stamps and compare only the blocks the walk never reached, with tests for Refresh, a direct write-back, and Windows. None of it has been pushed yet.

What I ran

Head 81ad915d786415669b61143d7bb202272ab521a2, main 9090972b7e91fd266819cbd77a8b058e177b5682, merged tree 0036d44d39bfe7ff176afa824122aca64a268a47. Debian 13 VM, Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19), Release.

git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...81ad915d786415669b61143d7bb202272ab521a2
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682
git diff 5e106c566dda63169ca2accc08b7b0008994918d 81ad915d786415669b61143d7bb202272ab521a2
ctest --test-dir build -R '^agc_driver_pending_untracked_layer$' --repeat until-fail:3 --output-on-failure
# negative control
git show 9090972b7e91fd266819cbd77a8b058e177b5682:core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
ninja -C build -j32 -l32 agc_driver_pending_untracked_layer_tests
ctest --test-dir build -R '^agc_driver_pending_untracked_layer$' --output-on-failure   # x3
# restore
git show 0036d44d39bfe7ff176afa824122aca64a268a47:core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
ninja -C build -j32 -l32 agc_driver_pending_untracked_layer_tests
ctest --test-dir build -R '^agc_driver_pending_untracked_layer$'
git status --porcelain
Check Result
git diff --check clean
check_conventions.py passed
Build and selected tests (script) 2033 tests ran, with 0 new failures and 0 timeouts. The 7 known failures also fail on main.
Vulkan validation comparison (script) 758 tests ran. The layer loaded in 757, with no test reported missing it, and there were 0 new VUIDs.
agc_driver_pending_untracked_layer (merged tree) passed 3/3, about 0.5 s per run
Negative control (main's Texture.cpp) failed 3/3, in cases 1 and 2; passes again once the merged file is restored
git status --porcelain after the restore empty
Negative control output (identical in all 3 runs)
[pending untracked layer] results over a surface whose walk fails: the image holds 0 of 8 results, guest memory 0, CPU words 0, CPU write reported 1
[pending untracked layer] results and a CPU store over a surface whose walk fails: the image holds 0 of 8 results, guest memory 0, CPU words 1, CPU write reported 1
AGC graphics: pending storage results or a CPU store over a write-watched surface were lost

Previous findings

  • Blocking 1, a failed walk on a later page discards confirmed CPU stores: still open.
    • Evidence: Texture.cpp is the same as in the head I reviewed last time. On a failed walk, core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2355-2360 still overwrites every stamp. The write-back does the same at Texture.cpp:6490 and Texture.cpp:6500.
    • Effect: my same-value probe from the last review still applies. When the walk fails on a later page, the GPU results overwrite a CPU store in a block the walk did reach.
    • Debt entry: docs/dev/debt/libSceAgcDriver.md:193 still does not record this loss.
    • Author's position: the author agrees, and the plan in their reply would address it once it is pushed.
  • Non-blocking 1, a later skipped case can hide an earlier failure: resolved.
    • Evidence: PendingUntrackedLayer.cpp:368-380 now sets notRun, finishes the loop, calls Require(kept, ...), and only then returns VulkanTestSkipped. A Lost outcome therefore fails the test even when a later case cannot run.
    • How I checked: by reading the code. On this machine all four cases run, so the skip branch was not exercised.
  • Non-blocking 2, no test reaches the Windows path: still open. The executable still returns 77 on _WIN32. The author's reply plans a Windows case through GuestArenaCompareWhenShared_nid_no_patch, but none has been pushed.

New findings

Blocking

None beyond the open finding above.

Non-blocking

None.

Not verified

  • Windows: not built or run here.
  • Hardware GPUs: only lavapipe here. The RADV and NVIDIA runs in the discussion were not repeated.
  • The skip branch: it never ran here, because all four cases ran.
  • The title: Ghost of Tsushima (PPSA02225) was not launched.

To get this to a good state

  • Keep the stamps: push the planned fix. Keep the confirmed CPU stamps for the pages the walk reached, and compare bytes only for the blocks it never reached.
  • Add the same-value test: cover a same-value CPU store with a failed walk on an unrelated later page, through Refresh and through a direct write-back with no Refresh before it. Each should fail without the fix and pass with it.
  • Update the debt entry: have it state what is still open after the fix, including Windows coverage if no Windows test lands.
  • Ask for re-review: re-request review from the reviewers who asked for changes.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 81ad915 merged onto main 1d91f29 · tested 2026-11-02 22:28 UTC · 11 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,621 passed · 3 failed (0 new, 3 also fail on main) · 44 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,668 of 3,544 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (983 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 106.6 s
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_driver_pending_untracked_layer
Validation IDs already present on main (4 IDs in 512 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (512 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 504 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_prepared_exports
Skipped (44)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fps_limit: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fresh: skipped, no display or Vulkan device: 
Reproduce
git fetch origin 81ad915d786415669b61143d7bb202272ab521a2 1d91f2966d0eef82a021628a7aa8e78e615ac807
git checkout 1d91f2966d0eef82a021628a7aa8e78e615ac807 && git merge --no-ff 81ad915d786415669b61143d7bb202272ab521a2
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

EagleBearerYS and others added 2 commits November 3, 2026 01:05
A walk that fails part way stamped its whole remaining range as CPU
writes, and the refresh and the write-back of a storage image over it
then compared every block with the saved bytes, so a CPU store of the
saved value in a block the walk had reached lost to pending results.

On Linux the collect now reports the regions PAGEMAP_SCAN wrote out
before its error and names the part it did not reach through new
reporting exports, which agc records per page with the page's genuine
CPU stamp. ChangedBlocks gains an unknown flag. After a failed walk the
refresh and the write-back keep the stamps of the blocks the walk
reached, leave a block the walk saw the CPU write to the CPU whatever
its bytes, and compare only the unknown blocks.

Co-authored-by: Tharun Balaji K <239791575+sktharunbalaji13-cmd@users.noreply.github.com>
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@oneandonlydean, point 1 is in. 89c782b keeps the CPU stores a failed walk saw before it stopped, and 37a0eb9 adds the two cases you asked for. It's built on sktharunbalaji13-cmd's plan, with them as co-author.

The change

  • On Linux, a PAGEMAP_SCAN that fails has already written out the dirty regions it found before the failure. The walk now reports those as written, and the range it didn't finish as unreached, through two new libc exports. The old collect calls are unchanged.
  • The tracker keeps each page's genuine CPU stamp under the failed walk's synthetic one. A new ChangedBlocks overload answers per 64 KiB block: known, CPU-confirmed or unknown.
  • Refresh and the write-back keep the stamps of known blocks, leave a CPU-confirmed block to the CPU, and compare only the unknown blocks with the saved bytes. Without saved bytes they compare the whole surface, as before.
  • The direct write-back needed one more rule, on the failed-walk path only: a block the walk saw the CPU write is left to the CPU whatever its bytes, as Refresh already does.

The cases: a same-value CPU store in a block the walk reached before failing on a later page, then a Refresh; and the same with a direct write-back and no Refresh before it. On GitHub's Linux runner (run), both fail with 81ad915's code: "guest memory holds 8 results and 0 stored words, the image 8 results and 0 stored words". With the change, the test passes 10 of 10. The agc sweep and the validation comparison are in the description.

What it doesn't change

  • A same-value store in a page the walk never reached is still lost, since that block is compared by bytes. The debt entry says so.
  • On a complete walk, main's write-back already leaves a stamped block to the CPU only when its bytes differ, so a same-value store made while results are pending is overwritten there too. That's main's existing behaviour, now in its own debt entry. Changing it would let stamps that come from no store, such as a range returning to the watch, drop results, so it isn't in this PR.
  • The Windows walk-failure case, through GuestArenaCompareWhenShared_nid_no_patch over a shared view, follows in its own commit on this PR.

@XairRrR and @mashingaan, this addresses the blocking point of your reviews. GitHub doesn't let my account re-request reviews here, so could you take another look?

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

A correction before the second look: please hold it for now. While designing the Windows case, I found from reading the code (not yet confirmed by a run) that 37a0eb9 likely makes Windows worse.

  • On Windows, a walk over a range that holds a compared shared page is refused up front and reports no pages at all.
  • Only the blocks holding those shared pages get marked. The new per-block query then reads the surface's other blocks as known, from stamps that missed the CPU store, so pending results can overwrite a CPU store there whatever its value.
  • With 81ad915's code, a failed walk on Windows compared the whole surface by bytes, which still caught a store of a different value.

Linux isn't affected: there the failed walk reports the regions it reached and marks the rest unreached. The fix compares a refused range by bytes again on Windows. It will come in this PR together with the Windows case, which should show the problem on 37a0eb9 and its absence with the fix. I'll post here when both are up.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 16, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 16, 2026
@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

NVIDIA Linux run with the Khronos validation layer of the pending storage result comparison over a surface whose page walk fails, on the storage, pending, write tracking and collect memo tests the Tested section names.

Setup: Arch Linux, kernel 7.3.4, GCC 16.2.1, Release. NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 095d749357 merged onto main e4caa07950 (clean merge); main is a separate Release build of e4caa07950 on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_(driver_pending|collect_memo_generation|storage|driver_storage|write_tracking|write_watch_coverage|import_watch)' -V
main e4caa07950 this PR
Result 45/45 passed 46/46 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 44 (in 39 tests) 46 (in 40 tests)
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

Every device test selected the RTX 4090 (Selected GPU name=NVIDIA GeForce RTX 4090 / loader Using "NVIDIA GeForce RTX 4090"), none fell back to llvmpipe.

agc_driver_pending_untracked_layer is new in this PR and does not exist on main (hence 45 vs 46); it runs on the RTX 4090 (no skip) and ends with pending untracked layer tests passed. The other 45 tests have the same names on both sides and all pass.

No new VUID- errors; all 46 focused tests pass on Ada, including the new one.

AI-assisted: yes (Claude Code)

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@domx4q thanks for the RTX 4090 pair with the validation layer, and for checking that agc_driver_pending_untracked_layer ran on the 4090 rather than skipping. It's in the description under Tested, and in the GPUs tested line.

@milescoviello

Copy link
Copy Markdown
Contributor

Linux A/B on Ghost of Tsushima (PPSA02225), plain main without the stack. Base main eb20410673. PR is 9e03b21a9f, which is eb20410673 with this head 095d749357 merged. Release libs, Ubuntu 26.04.1, RTX 4070 Ti (NVIDIA 615.71.09), pinned save, cold shader cache per run, 22G cap, scripted presses, 600 s, 3 runs per arm (the last pair with frame dumps).

run end keeping the CPU's blocks max RSS presents 10 s windows over 500 ms GPU per present
base 1 ran 605 s 8 20.3 GB 1122 1
base 2 ran 607 s 8 19.9 GB 966 1
base 3 (frames) killed at 237 s (exit 137) 8 19.2 GB 1192 6
PR 1 killed at 393 s (exit 137, at the cap) 8 25.0 GB 1211 10
PR 2 ran 602 s 8 24.1 GB 1191 22
PR 3 (frames) ran 602 s 8 19.7 GB 937 1
  • All 8 lines in every run come during setup, matching your note that the per-frame case only shows up with the stack. So this can't show the fix on plain main.
  • The frames show the logos and then the main menu with Continue selected. After Continue, the screen stays black in both arms. Some runs then go into a phase of 1-2 presents per 10 s at 1-4 s of GPU per present (the last column). That phase happened in one base run and two PR runs, so it varies from run to run rather than following the change.
  • The two PR runs with the most heavy windows also had the highest RSS, but base 3 was also in that phase and was killed before it got far, so I don't read the memory difference as coming from this PR.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@milescoviello thanks for the A/B on Ghost of Tsushima. It matches what the description says for plain main: all 8 keeping the CPU's blocks lines come during setup, and the per-frame case needs the stack listed under Tested. It's in the description under Tested, with your reading of the slow-GPU phase and the memory, and in the GPUs tested line.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

No verified defect blocks this change; the prepared evidence includes targeted regression runs and a GPU validation run at this head, while I did not run checks myself.

What I ran

Reviewed head 095d74935785c1090069e4b427f2388f52120b32. I did not run tests or build commands. Read description.md, commits.md, manifest.json, diff.patch, and all included changed files except only portions of long files; read Texture.cpp through repo_read.py for the changed refresh block. The full text of Texture.cpp was excluded from the review folder as too large, and I read only its relevant range through the reader. files.json was not present; the review folder listing served to identify included and excluded changed files.

Results

Check Result Note
Prepared regression evidence not run Reported by author; not independently run
Changed-code review passed No concrete blocking defect verified
Full-file review not run Texture.cpp was read only in the relevant range

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run tests, builds, or GPU checks. I did not read the entire Texture.cpp file or all unchanged repository context. The prepared description reports several known limitations and an untested alias failure-reporting path; I did not verify those behaviors independently.

To get this to a good state

Nothing is required.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

This passed review on 095d749, but it now conflicts with main in Texture.cpp. Please merge main into the branch and push; it goes back to the merge queue on the new head.

Keeps both sides where boykopovar#16753 meets this branch: the record keeps this branch's unknownBlocks and takes boykopovar#16753's rewatchCompared, which confirmRewatched now sizes on first use.
An unwatched range leaves compareUnknown at ChangedBlocks' early return, so nothing is sized for it; the write-back keeps marking its blocks written.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

A complete approval is not justified because I could not run checks or read every changed file in full.

What I ran

Reviewed head 38516b5e639672419eed45fae5ede9caef11c917 against main using the prepared review bundle and repo_read.py targeted reads. No commands or tests were run.

Results

Check Result Note
Prepared diff review passed 8 changed files listed
Tests and prechecks not run No execution environment available
Full changed-file review not run Some files were read only in relevant ranges

Negative control

Not run; no tests were executed.

Findings

Blocking

None identified in the code ranges reviewed.

Non-blocking

None.

Sources

Reviewed description.md, commits.md, manifest.json, and diff.patch, plus targeted ranges in GuestMemory.hpp, GuestMemory.cpp, Texture.cpp, PendingUntrackedLayer.cpp, and GuestWriteWatch.cpp at the pinned head.

Not verified

Did not run tests or prechecks. Did not read all lines of the changed files; in particular, the full text of Texture.cpp was excluded from the review folder as too large, and only relevant ranges were read through repo_read.py. The full test and documentation files were not read. The file listing shows eight changed files; Texture.cpp is the only one excluded from the prepared full-text bundle.

To get this to a good state

Nothing is required. Optional: run the relevant AGC tests and review the remaining changed-file content before treating this as a complete approval.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trial merge conflicts in GuestWriteWatch.cpp. The new behavior depends on an unavailable page walk triggering byte comparison instead of discarding pending GPU results. Please keep a case where only part of the range can be collected, with a CPU update in that range and unchanged bytes beside it. That can verify that the fallback preserves the GPU result while still detecting CPU edits. Please move the direct debt update to a fragment. I have no paired Vulkan result for this head.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs libc needs rebase Conflicts with main, rebase needed unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.