fix(agc): serialize pipeline cache snapshots #4795

Merged
MarcZX10 merged 1 commit from upstream-pr/4795 into main 2026-10-14 01:00:21 +00:00
MarcZX10 commented 2026-10-12 22:10:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T22:10:49Z.


What

Serialize the periodic persistent pipeline-cache snapshot against pipeline creation that uses that cache. Pipeline creation paths take shared locks, so they can continue concurrently with each other. PipelineCache::save() takes the exclusive lock only around its two vkGetPipelineCacheData calls, then releases it before hashing or writing the cache file.

The guard covers graphics, compute, pipeline-library and asynchronous LTO creation paths using the persistent cache. Capture replay uses a separate temporary cache and remains unchanged. A regression checks that snapshot access cannot acquire while a pipeline-use lock is held and succeeds after that lock is released.

This is an application-side workaround for the Intel driver crash reported in issue #4781. The Vulkan specification describes pipeline-cache use by pipeline creation as internally synchronized across threads; this PR does not claim that the crash is a Vulkan valid-usage violation. See the Vulkan pipeline cache specification and vkGetPipelineCacheData reference.

Tested

  • Before rebase, a Linux Release build of libSceAgcDriver and agc_driver_graphics_tests passed on base d379bfd014193cb3dc7b1e559c374b40a6dcdf48; agc_driver_graphics passed 1/1.
  • Rebased onto upstream main 30f961266ade83b41d5c9de7dec1393e7fcecfb7. On the rebased head, configured Linux Release with BUILD_TESTING=ON and SPIR-V tools disabled; Ninja built agc_driver_graphics_tests successfully (706/706 steps).
  • ctest --test-dir /tmp/AnyPS5-4795-rebased-build -R '^agc_driver_graphics$' --output-on-failure: passed (1/1, 7.99 s).
  • python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main...HEAD passed on the rebased head.
  • No Intel Windows GPU was available; the reported crash was not reproduced locally.

Checklist

  • Based on current main; no open PR implements persistent pipeline-cache snapshot serialization
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unsupported paths throw or use NotImplemented_nid_no_patch
  • No investigation files added to the repository
  • No new third-party code
  • Generic behavior
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835573150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T22:10:49Z. --- ### What Serialize the periodic persistent pipeline-cache snapshot against pipeline creation that uses that cache. Pipeline creation paths take shared locks, so they can continue concurrently with each other. `PipelineCache::save()` takes the exclusive lock only around its two `vkGetPipelineCacheData` calls, then releases it before hashing or writing the cache file. The guard covers graphics, compute, pipeline-library and asynchronous LTO creation paths using the persistent cache. Capture replay uses a separate temporary cache and remains unchanged. A regression checks that snapshot access cannot acquire while a pipeline-use lock is held and succeeds after that lock is released. This is an application-side workaround for the Intel driver crash reported in [issue #4781](https://github.com/boykopovar/AnyPS5/issues/4781). The Vulkan specification describes pipeline-cache use by pipeline creation as internally synchronized across threads; this PR does not claim that the crash is a Vulkan valid-usage violation. See the [Vulkan pipeline cache specification](https://docs.vulkan.org/spec/latest/chapters/pipelines.html#pipeline-cache) and [`vkGetPipelineCacheData` reference](https://docs.vulkan.org/refpages/latest/refpages/source/vkGetPipelineCacheData.html). ### Tested - Before rebase, a Linux Release build of `libSceAgcDriver` and `agc_driver_graphics_tests` passed on base `d379bfd014193cb3dc7b1e559c374b40a6dcdf48`; `agc_driver_graphics` passed 1/1. - Rebased onto upstream `main` `30f961266ade83b41d5c9de7dec1393e7fcecfb7`. On the rebased head, configured Linux Release with `BUILD_TESTING=ON` and SPIR-V tools disabled; Ninja built `agc_driver_graphics_tests` successfully (706/706 steps). - `ctest --test-dir /tmp/AnyPS5-4795-rebased-build -R '^agc_driver_graphics$' --output-on-failure`: passed (1/1, 7.99 s). - `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main...HEAD` passed on the rebased head. - No Intel Windows GPU was available; the reported crash was not reproduced locally. ### Checklist - [x] Based on current `main`; no open PR implements persistent pipeline-cache snapshot serialization - [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] Unsupported paths throw or use `NotImplemented_nid_no_patch` - [x] No investigation files added to the repository - [x] No new third-party code - [x] Generic behavior - [x] Depends on: none - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 03:27:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T03:27:18Z.


Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main 0c3dc9ca2 together with eight other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it:

  • tests/Graphics.cpp (agc_driver_graphics): 10 of 10 runs passed.

Not tested: no game run. The batch was built once, not per PR; it had no failures, so no bisect was needed.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6137530100 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6137530100). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T03:27:18Z. --- Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main `0c3dc9ca2` together with eight other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it: - `tests/Graphics.cpp` (`agc_driver_graphics`): 10 of 10 runs passed. Not tested: no game run. The batch was built once, not per PR; it had no failures, so no bisect was needed. AI-assisted (Claude Code).
MarcZX10 commented 2026-10-13 08:12:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T08:12:22Z.


Rebased onto current main 6e83cad17574960029bdca66626dff57cfb7bb4c and pushed head dfff45d02. The Graphics.cpp conflict was between main’s --sparse-buffer-holes dispatch and this PR’s pipeline-cache synchronization regression; both are retained. git diff --check passes. I have not rebuilt or rerun tests on this rebased head; the PR description now labels the earlier Linux and Windows reports by their bases.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141253086 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6141253086). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T08:12:22Z. --- Rebased onto current `main` `6e83cad17574960029bdca66626dff57cfb7bb4c` and pushed head `dfff45d02`. The `Graphics.cpp` conflict was between main’s `--sparse-buffer-holes` dispatch and this PR’s pipeline-cache synchronization regression; both are retained. `git diff --check` passes. I have not rebuilt or rerun tests on this rebased head; the PR description now labels the earlier Linux and Windows reports by their bases.
kq62 commented 2026-10-13 10:09:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kq62 on 2026-10-13T10:09:21Z.


Tested on an Intel Arc 140T on Windows, where main crashes the same way as #4781.

Setup

  • GPU: Intel(R) Arc(TM) 140T GPU (16GB), 0x8086:0x7d51, driver 32.0.101.8991
  • CPU: Intel Core Ultra 9 285H, Windows 11 Home
  • Toolchain: WinLibs GCC 15.2.0 r7, Release
  • Title: DOOM homebrew PPSA99666 (lowbit/ps5-doom v1.1.1), unpacked from its fake-signed SELF (ELF SHA-256 62d4cfe6..., same as #2475) and relinked with --windows --to-intel

Results

Build Shader cache Result
main cac4e9688 on Crash (1 of 1 run) about 10 s after start: 0xc0000005 in igvk64.dll+0x653291, read of 0x350, on a thread with libSceAgcDriver.prx frames
main cac4e9688 ANYPS5_NO_SHADER_CACHE=1 Runs, gameplay fine
this PR 1eeb2c664 on, warm (925 KiB loaded) No crash, ran past the first save and exited normally
this PR 1eeb2c664 on, cleared before the run No crash, played through E1M1

I did not symbolize the crash frames; the timing and the ANYPS5_NO_SHADER_CACHE=1 result match #4781. So the saver race also reproduces on a second Intel GPU generation and on a newer driver (32.0.101.8991, after the two in #4781), and this PR avoids it there.

AI-assisted: yes (Claude).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6143219539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6143219539). Originally posted by [kq62](https://github.com/kq62) on 2026-10-13T10:09:21Z. --- Tested on an Intel Arc 140T on Windows, where `main` crashes the same way as #4781. **Setup** - GPU: Intel(R) Arc(TM) 140T GPU (16GB), `0x8086:0x7d51`, driver `32.0.101.8991` - CPU: Intel Core Ultra 9 285H, Windows 11 Home - Toolchain: WinLibs GCC 15.2.0 r7, Release - Title: DOOM homebrew PPSA99666 (lowbit/ps5-doom v1.1.1), unpacked from its fake-signed SELF (ELF SHA-256 `62d4cfe6...`, same as #2475) and relinked with `--windows --to-intel` **Results** | Build | Shader cache | Result | |---|---|---| | `main` `cac4e9688` | on | Crash (1 of 1 run) about 10 s after start: `0xc0000005` in `igvk64.dll+0x653291`, read of `0x350`, on a thread with `libSceAgcDriver.prx` frames | | `main` `cac4e9688` | `ANYPS5_NO_SHADER_CACHE=1` | Runs, gameplay fine | | this PR `1eeb2c664` | on, warm (925 KiB loaded) | No crash, ran past the first save and exited normally | | this PR `1eeb2c664` | on, cleared before the run | No crash, played through E1M1 | I did not symbolize the crash frames; the timing and the `ANYPS5_NO_SHADER_CACHE=1` result match #4781. So the saver race also reproduces on a second Intel GPU generation and on a newer driver (32.0.101.8991, after the two in #4781), and this PR avoids it there. AI-assisted: yes (Claude).
blawesom commented 2026-10-13 18:46:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T18:46:02Z.


Rebase handoff — rebased onto current main (staleness only, applied cleanly), authorship unchanged.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 1070/1071 — the only failure is the known main regression (agc_driver_tessellation segfault, #4727). Note this PR's own pipeline-cache tests all pass, including the snapshot serialization round-trips.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4795
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 06804f8a3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152698952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6152698952). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-13T18:46:02Z. --- **Rebase handoff** — rebased onto current `main` (staleness only, applied cleanly), authorship unchanged. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 1070/1071** — the only failure is the known `main` regression (`agc_driver_tessellation` segfault, #4727). Note this PR's own pipeline-cache tests all pass, including the snapshot serialization round-trips. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4795 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `06804f8a3`.
MarcZX10 commented 2026-10-13 19:27:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T19:27:00Z.


I checked the current head 1eeb2c66482f87bfc5832b1664275554f9f57dd6: conventions, eligibility, and report pass; the path-based build jobs (Linux, Windows, relinker, register-context and write-watch) are skipped. gh pr checks shows no current failure, although GitHub still reports UNSTABLE from the check history. No failing current run is available to rerun.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153446659 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6153446659). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T19:27:00Z. --- I checked the current head `1eeb2c66482f87bfc5832b1664275554f9f57dd6`: `conventions`, `eligibility`, and `report` pass; the path-based build jobs (Linux, Windows, relinker, register-context and write-watch) are skipped. `gh pr checks` shows no current failure, although GitHub still reports `UNSTABLE` from the check history. No failing current run is available to rerun.
MarcZX10 commented 2026-10-13 22:48:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T22:48:02Z.


Thanks for preparing and validating the rebase handoff. I picked up the original topic and rebased it directly onto the newer upstream main 30f961266, since the offered head was based on an earlier main. I rebuilt agc_driver_graphics_tests on that head (706/706 Ninja steps), reran agc_driver_graphics (1/1 passed), and reran conventions plus git diff --check; the PR body now distinguishes the old-base results from these current-head results.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156843897 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6156843897). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T22:48:02Z. --- Thanks for preparing and validating the rebase handoff. I picked up the original topic and rebased it directly onto the newer upstream `main` `30f961266`, since the offered head was based on an earlier main. I rebuilt `agc_driver_graphics_tests` on that head (706/706 Ninja steps), reran `agc_driver_graphics` (1/1 passed), and reran conventions plus `git diff --check`; the PR body now distinguishes the old-base results from these current-head results.
oneandonlydean commented 2026-10-14 00:46:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T00:46:23Z.


Rebased onto main to resolve the conflict in core/libs/prx/libSceAgcDriver/tests/Graphics.cpp after #4849 (kept both tests); no other change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158330215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6158330215). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T00:46:23Z. --- Rebased onto main to resolve the conflict in `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` after #4849 (kept both tests); no other change.
MarcZX10 commented 2026-10-14 00:54:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T00:54:30Z.


Fresh Linux validation for the current PR tree: published head 4307e3cb549a5745346b39dbaf4784c4e10002f3 has the exact same tree as the locally tested commit 3e7478b2b43b85b79c45ae47182ae457b045d5b9 (same parent ce5c839). GCC 12.2, CMake/Ninja Release, BUILD_TESTING=ON: agc_driver_graphics_tests built successfully; ctest -R "^(agc_driver_graphics|agc_driver_address_space_teardown)$" --output-on-failure passed 2/2. Conventions and git diff --check pass. The merge with latest upstream main 0dea07ab is also conflict-free. The build emitted GCC -Wstringop-overread warnings from libstdc++ vector comparison in PipelineLibrary.cpp; no errors.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158428720 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6158428720). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T00:54:30Z. --- Fresh Linux validation for the current PR tree: published head `4307e3cb549a5745346b39dbaf4784c4e10002f3` has the exact same tree as the locally tested commit `3e7478b2b43b85b79c45ae47182ae457b045d5b9` (same parent `ce5c839`). GCC 12.2, CMake/Ninja Release, `BUILD_TESTING=ON`: `agc_driver_graphics_tests` built successfully; `ctest -R "^(agc_driver_graphics|agc_driver_address_space_teardown)$" --output-on-failure` passed 2/2. Conventions and `git diff --check` pass. The merge with latest upstream `main` `0dea07ab` is also conflict-free. The build emitted GCC `-Wstringop-overread` warnings from libstdc++ vector comparison in `PipelineLibrary.cpp`; no errors.
github-actions[bot] commented 2026-10-14 00:56:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T00:56:24Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4897 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L4228-4281
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158453152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4795#issuecomment-6158453152). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T00:56:24Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4897 | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` [L4228-4281](https://github.com/boykopovar/AnyPS5/blob/0dea07ab27df5c894fae55b0dbefe2ba20a10482/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp#L4228-L4281) | | |
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!4795
No description provided.