fix(agc): relaunch the frame replay when a host region blocks a captured GPU range #12696
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12696"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by chitters2004 on 2026-10-29T02:50:09Z.
What
Review only
df74f29c46,89db2b5ae2,93123ef32cand9a2b40f233. The rest is #11436 (at752958c135), merged in because it lands first, as agreed with Sam-mon7. Whichever of the two lands first, the other needs a merge ofmain.On Windows,
agc_frame_replayfails about 1 run in 30 at startup withfixed guest mapping 0x2324a0000+0x133d80000 overlaps a host region in the guest arena. #3371 diagnosed the cause: the main thread's stack and the loader's thread stacks exist before libc reserves the guest arena, and withHIGH_ENTROPY_VAWindows places them anywhere in the first TiB, so the arena keeps them as host holes. A title can avoid them. #3683 moved the AMM ranges to the highest free window for that reason. A replay can't, because it has to map each captured range at its captured address. A host hole inside a GPU-visible range is fatal, while other ranges are skipped.relaunchIfHostRegionBlockschecks the GPU-visible captured ranges withGuestArenaHostRegionOverlaps_nid_postfix. If one overlaps a host region, the replay prints the range, starts its own command line again (the new process gets a fresh ASLR layout), waits for it and exits with its exit code.APS5_FRAME_REPLAY_ATTEMPTcounts the attempts; after 8 the replay continues as it does today and reports the overlap. The count must be a whole number from 0 to 8, otherwise the replay stops with an error, and a relaunch stops if the count cannot be passed to the next process.run(), and the logic doesn't overlap. This branch now includes #11436, with that conflict resolved by keeping both insertions.93123ef32cis part of this PR:SKIP_RETURN_CODE 77onagc_driver_frame_replay,_cold_pipelines,_reservation_errorand_concurrent, so they skip on a runner with no Vulkan driver.0x7f…, and #3371 saw no collisions there.HIGH_ENTROPY_VAfor the replay, as #679 did for relinked titles, doesn't help: it moves the stacks to about 0x5ff000-0x1c6f000, inside the title image range at 0x400000 (#9332) that every capture maps. That range is not GPU-visible, so the replay then skipped 51.7 MiB of it on every run, where it normally skips none.Tested
Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0, Release, RTX 3080, GTA V (PPSA04263) frame capture.
skipped_mib0.0, exit 0. Run 16 hit the same range, 0x2324a0000+0x133d80000, relaunched once and finished normally.--disable-high-entropy-va, every attempt overlaps the 0x400000 range. It relaunched 8 times, then continued down the normal path and exited 0. All 9 processes wrote to the same redirected log, and none was left running.python3 tools/check_conventions.py --base origin/mainpasses.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R '^agc_(frame_capture|driver_frame_capture_eop|driver_frame_replay)' -V:mainat466bf10f7f: 11 tests, all passed, 0VUID-lines; this branch at501b4fdf2dmerged into it (e022558084): 18 tests, all passed, 0VUID-lines. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS.4c144e8108(merged withmain5bae1a4bc2), RTX 3080, with the command above: 19 of 19 tests passed, 0VUID-lines, no missing-layer message. Without the layer, 18 of 19:agc_driver_frame_replay_reservation_errortimes out, which is the Windows exit hang #14100 fixes.agc_driver_frame_replay_relaunch: linked with--disable-high-entropy-va, so its stack is an arena host region in every process. It relaunches eight times and then continues, with the count seen by each process checked; passes a failing exit code (42) back through all nine processes; relaunches once from 7 and not at all from 8; and exits 2 without relaunching for-1,-2147483648,9,99999999999,abc,1x,1and+1. It passed 5 of 5 runs. Negative control: with the oldatoiline restored it fails with-1: exited with 0. It skips with 77 if the stack is not a host region. A failed_putenv_sis not covered.93123ef32c: on the previous headf2ba0a7c78, with the RTX 3080 they ran and passed; withVK_DRIVER_FILESandVK_ICD_FILENAMESpointing at a missing file, all four reportedSkipped. That no-Vulkan run was not repeated on9a2b40f233or4c144e8108, which do not touch them._WIN32).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code