fix(agc): snapshot host shader prologues before frame replay #12871

Merged
JJenkx merged 4 commits from upstream-pr/12871 into main 2026-11-02 07:55:14 +00:00
JJenkx commented 2026-10-29 13:22:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-29T13:22:06Z.


What

Shader registration and ABI calls made before a frame-capture trigger are saved in the replay prologue. Their host-resident headers and code can lie outside registered guest allocations, so the initial snapshot omits them and strict replay cannot read the shaders.

Collect the host pages referenced by those calls while waiting and snapshot the still-readable pages at the capture boundary, before writing the prologue. Reuse the existing shader-page traversal, preserve read-only permissions, skip already-covered pages, and retain in-frame shader deltas.

Three regressions cover separate host code, host-resident header/code, and read-only header/code registered before the trigger. Existing shader controls retain their entry point. Read-only merge previews compose cleanly with the fetched heads of #11435, #11436, #12567 and #12568; their additional controls are retained. This is independent of the unwatched-memory fallback offered on #12568 and does not supply that fallback. Existing stale/freed historical shader-registration limitations remain documented under Frame replay debt.

Tested

Linux Release, GCC 16.2.1, AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.4, kernel 7.2.9-arch1-1. Exact head ca858917b0cb25d494e692d2835b8d21f71f9009, based directly on main 5454cd2e455994d992aca39335ce60507eeda1eb.

Control Result
Unchanged main, existing focused capture/replay/multisample gate 14/14 pass
Test-only 863bda70fe062decbefbd8a1b89efc6dc5ce9321, unchanged recorder implementation Both existing shader controls pass; all three new prologue regressions fail on missing code bytes
This head, CPU serialization controls with invalid Vulkan ICD paths and syscall tracing All five pass; no DRM device opens
This head, complete focused gate 17/17 pass: the 14 common tests plus three new regressions

The main and change focused gates used the same machine/GPU, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and Mesa shader cache disabled. Both confirm the actual RX 6650 XT and validation-layer insertion; zero skips, missing-layer messages or VUIDs. The library stayed byte-identical through each gate. These gates include CPU serialization checks as well as hardware tests; this is not a claim that every group creates a GPU device.

Conventions and whitespace pass. A read-only merge preview against upstream 157b02c4f1803e9d2cd757677b9a805961203fc4 is clean. No new Windows execution, title replay fidelity, lighting or FPS improvement is claimed. The private title capture is separate and does not establish replay fidelity.

Source proof, negative/positive controls, builds, device-access traces and paired focused logs/JUnit, SHA-256 4a207cef8510163045dd48338a6742fc49184141d5aa803e762622fed638ce17 (download verified). No game memory, assets or binaries.

GitHub Windows CI passed for head ca858917b0c merged into main. Its configure and host-only linking workflow steps succeeded; the full library build, CTest execution and test-skip checks were skipped. This is limited CI coverage, not Windows runtime or physical-GPU qualification.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none (capture-tool correctness; no title bring-up claim)
  • GPUs tested: AMD Radeon RX 6650 XT, RADV/Mesa 26.2.4, Linux 7.2.9-arch1-1
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5068789415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12871). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-29T13:22:06Z. --- ### What Shader registration and ABI calls made before a frame-capture trigger are saved in the replay prologue. Their host-resident headers and code can lie outside registered guest allocations, so the initial snapshot omits them and strict replay cannot read the shaders. Collect the host pages referenced by those calls while waiting and snapshot the still-readable pages at the capture boundary, before writing the prologue. Reuse the existing shader-page traversal, preserve read-only permissions, skip already-covered pages, and retain in-frame shader deltas. Three regressions cover separate host code, host-resident header/code, and read-only header/code registered before the trigger. Existing shader controls retain their entry point. Read-only merge previews compose cleanly with the fetched heads of #11435, #11436, #12567 and #12568; their additional controls are retained. This is independent of the unwatched-memory fallback offered on #12568 and does not supply that fallback. Existing stale/freed historical shader-registration limitations remain documented under Frame replay debt. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux Release, GCC 16.2.1, AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.4, kernel 7.2.9-arch1-1. Exact head `ca858917b0cb25d494e692d2835b8d21f71f9009`, based directly on main `5454cd2e455994d992aca39335ce60507eeda1eb`. | Control | Result | |---|---| | Unchanged main, existing focused capture/replay/multisample gate | 14/14 pass | | Test-only `863bda70fe062decbefbd8a1b89efc6dc5ce9321`, unchanged recorder implementation | Both existing shader controls pass; all three new prologue regressions fail on missing code bytes | | This head, CPU serialization controls with invalid Vulkan ICD paths and syscall tracing | All five pass; no DRM device opens | | This head, complete focused gate | 17/17 pass: the 14 common tests plus three new regressions | The main and change focused gates used the same machine/GPU, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, and Mesa shader cache disabled. Both confirm the actual RX 6650 XT and validation-layer insertion; zero skips, missing-layer messages or VUIDs. The library stayed byte-identical through each gate. These gates include CPU serialization checks as well as hardware tests; this is not a claim that every group creates a GPU device. Conventions and whitespace pass. A read-only merge preview against upstream `157b02c4f1803e9d2cd757677b9a805961203fc4` is clean. No new Windows execution, title replay fidelity, lighting or FPS improvement is claimed. The private title capture is separate and does not establish replay fidelity. [Source proof, negative/positive controls, builds, device-access traces and paired focused logs/JUnit](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/host-shader-prologue-main-linux-20261029.tar.gz), SHA-256 `4a207cef8510163045dd48338a6742fc49184141d5aa803e762622fed638ce17` (download verified). No game memory, assets or binaries. <!-- codex-windows-ci-scope-20261029 --> GitHub [Windows CI](https://github.com/boykopovar/AnyPS5/actions/runs/40881284216/job/123476782802) passed for head `ca858917b0c` merged into main. Its configure and host-only linking workflow steps succeeded; the full library build, CTest execution and test-skip checks were skipped. This is limited CI coverage, not Windows runtime or physical-GPU qualification. <!-- /codex-windows-ci-scope-20261029 --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none (capture-tool correctness; no title bring-up claim) - [x] GPUs tested: AMD Radeon RX 6650 XT, RADV/Mesa 26.2.4, Linux 7.2.9-arch1-1 - [x] AI-assisted: yes (Codex)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12871
No description provided.