Skip to content

fix(agc): serialize pipeline cache snapshots - #4795

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/pipeline-cache-snapshot-lock-4781
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/pipeline-cache-snapshot-lock-4781

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@MarcZX10
MarcZX10 force-pushed the codex/pipeline-cache-snapshot-lock-4781 branch from cecaa48 to dfff45d Compare October 13, 2026 08:11
@MarcZX10

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@MarcZX10
MarcZX10 force-pushed the codex/pipeline-cache-snapshot-lock-4781 branch 2 times, most recently from 51c9e5b to 1eeb2c6 Compare October 13, 2026 08:50
@kq62

kq62 commented Oct 13, 2026

Copy link
Copy Markdown

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

Setup

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

Copy link
Copy Markdown
Contributor

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):

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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 oneandonlydean self-assigned this Oct 14, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@oneandonlydean
oneandonlydean force-pushed the codex/pipeline-cache-snapshot-lock-4781 branch from 87d831f to 4307e3c Compare October 14, 2026 00:46
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown

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

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@oneandonlydean
oneandonlydean merged commit 1f1115d into boykopovar:main Oct 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants