fix(agc): serialize builds of identical graphics pipelines #11914
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11914"
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 Bram910 on 2026-10-27T12:26:47Z.
What
Concurrent misses for an identical graphics-pipeline key can currently compile the same pipeline or library part multiple times before discarding the raced result. Serialize builds for the same full key, recheck the resident entry after waiting, and release the build marker on Vulkan failures and C++ exceptions. Different keys and resident hits can continue independently. Retain the current LTO key and cache admission policies. A cache hit after waiting also returns its store hash, so the caller can memoize the pipeline for that draw shape.
Tested
Windows 11 Pro 10.0.26200, MinGW GCC 15.2, Release, same NVIDIA GeForce RTX 3080 and driver 610.47 (Windows 32.0.16.1047).
Built
libSceAgcDriver, recorder/graphics/disk-cache/queue-failure test targets and this PR's added fixture target(s). Focused baseline atca0e9557aab1d1496c2c317077dd258f2d16fbf8: 100% tests passed, 0 tests failed out of 22. This branch atda3ca94b1e64663ecbc799f7ddbeba072fbfaafd: 100% tests passed, 0 tests failed out of 32.Both runs used
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_GPU=NVIDIA,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, andVK_LAYER_PATH=C:\VulkanSDK\1.4.363.0\Bin:Neither verbose log reports a missing validation layer, skipped/unrun selected tests, or
VUID-errors. Ten deterministic concurrency/failure/teardown fixture modes, repeated 20 times each (200 executions). Existing real-Vulkan library reuse, LTO, cache, teardown, store and journal tests also run.python tools/check_conventions.py --base origin/mainandgit diff --check origin/main...HEADpass. The project'spr_overlap.pycomparison logic was run against open PRs using a public REST transport adapter because local gh is unauthenticated. Its report warns about older PRs that conflict with main; their shared-file diffs were inspected separately. No equivalent fix was found. Related overlapping files may still need integration rebases as those older branches are refreshed.No full-project suite, Linux/macOS run or new title benchmark is claimed. This submission does not establish a GTA FPS or RAM reduction.
Related stale branches #5925, #7642, #9508 and #10193 change pipeline scheduling or descriptor handling; they do not provide the same per-key build ownership. CMake-only neighbors add different test targets.
Review follow-up (2026-11-03)
Integrated current main
4f41f4c375. Addressed the waited-hitstoreHashissue reported by chitters2004 and oneandonlydean: the successful lookup after acquiring the per-key build mutex now sets*storeHash = hash, matching the other successful shared-cache return paths.The existing concurrent store fixture now captures both threads' returned hashes and requires the waited hit's hash to be nonzero and equal to the builder's. With the new assertions and the previous implementation,
agc_pipeline_store_builds_sharedfails witha completed lookup did not return its store hash; with the fix it passes, including 10 repeated runs.Windows 10.0.26200.9457, WinLibs GCC 15.2 Release, NVIDIA GeForce RTX 3080 / 610.47:
Pipeline.cppandPipelineLibrary.cppwere restored from main4f41f4c375for this baseline; the PR's test registration remained in the build tree.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_GPU=NVIDIA,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LAYER_PATH=C:\VulkanSDK\1.4.363.0\Bin. Neither log contains a missing-requested-layer warning or aVUID-error.check_conventions.py --base origin/mainandgit diff --checkpass.No new full-suite, Linux, macOS or title-performance result is claimed for this push. The older validation below remains pinned to its original revisions.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T12:48:18Z.
Review: APPROVED
Reviewed the per-key build coordination in both
CachedPipelineandLinkPipelineFromLibraries. The key-specific mutex/set is acquired outside the global cache mutex; after waiting, each path rechecks the resident cache, and RAII clears its in-flight marker on Vulkan failures or exceptions. The library store tracks active builds so clear waits for them. The added synthetic tests cover shared keys, distinct keys, cache hits, failure/exception cleanup and clear-time waiting; the PR reports 32/32 focused Windows tests with validation enabled, and its Windows CI plus conventions/intake/labels/report checks pass. Linux product jobs were skipped by path policy; I did not run the GPU suite locally.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T11:20:47Z.
Review: APPROVED
Reviewed — approved
The per-key serialization of identical graphics-pipeline and library-part builds is correct. The new fixtures pass on the merged tree and fail with
main's production files. The two automated flags (agc_map_gate_disjoint, one VUID) also reproduce withmain's production files.What I ran
Head
951b79acc77505d59e4c1c976312b3fff58e5bf7,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree1acd9902125e6099293588bd55055d974c5960f6(Debian 13 VM, GCC 14.2.0, Release, lavapipe / Mesa 26.1.6, LLVM 19).Results
git diff --checkcheck_conventions.pylibs(script)agc_pipeline_store_builds_*(5),agc_pipeline_library_builds_*(5)-j8pass; each run ≤ 0.35 sagc_map_gate_disjoint(script's only new failure)main'sPipeline.cpp/PipelineLibrary.cpp. It comes frommain, not this PRagc_driver_native_depth_uniform_planesnewVUID-vkCmdDispatch-groupCountX-00386(script, "test not run on main")main's production files; the layer loaded in both runs. It comes frommain, not this PRmain; 114 expected skipsagc_map_gate_disjointfailure (same output on the merged tree and with main's production files)Negative control
I restored
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppandPipelineLibrary.cppfrommain, kept the PR's tests and rebuilt. 7 of the 10 new tests failed:Output
The 3 modes that still pass (
store_builds_cached,store_builds_independent,library_builds_independent) check that unrelated work is not blocked, so they should pass onmaintoo. I then restored the merged files and rebuilt;git status --porcelainis empty.Findings
Blocking
None.
Non-blocking
build(see Pipeline.cpp#L1309-L1319) is destroyed only at function return. So threads waiting on the same key also wait forRecordGraphicsPipelineat Pipeline.cpp#L1382, even though the entry is already resident after the store insert. Rendering is still correct; this only adds latency for the waiter. Releasingbuild.lockonce the insert block has finished would let waiters hit straight away.textcode block, which splits the--repeat until-fail:10command line. The real checklist further down is complete (Depends on, Fixes, Unblocks, GPUs tested and AI-assisted are all filled in). Cosmetic only.Code reading, for the record:
store.mutex. Waiters releasestore.mutexbefore taking the per-key mutex, and~PipelineBuildtakesstore.mutexwhile the per-key lock is still held. There is no inversion.use_count() == 1is evaluated understore.mutex, the same mutex under which waiters get theirshared_ptr. An expiredweak_ptris replaced throughinsert_or_assign.LinkPipelineFromLibraries, a thread holds a part marker only while it builds that part, and drops it before the next part. A waiting thread holds no marker, so cross-part waits cannot deadlock.PartBuildre-locks before erasing on both theCheckthrow and the exception path.storeHashfix reported by chitters2004 and oneandonlydean is in Pipeline.cpp#L1320-L1328, andstore_builds_sharedchecks it. I confirm that their finding is resolved.Not verified
VUID-vkCmdCopyBuffer-commonparentreported onagc_driver_depth_clear_hlein the first NVIDIA CI run, at the older headda3ca94, did not reappear in the later run atd64f238. I did not investigate it on lavapipe.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:52:44Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the review points below are optional.
What I ran
Reviewed head
951b79acc77505d59e4c1c976312b3fff58e5bf7usingrepo_read.pyreader tools. I inspected the prepared description, commits, manifest and diff, and read all six changed repository files. No executable checks were run; test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The PR's reported test runs, build, conventions check, and diff check were not independently verified.
review/files.jsonwas not available through the reader; the manifest and file listing show six changed files, all included and read. No changed files were excluded in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:56:36Z.
Review: COMMENTED
The trial merge is clean. The new store and library fixtures cover same-key sharing, independence across keys, and retry after both a Vulkan failure and a C++ exception. Please retain the clear-versus-build fixture as well as the resident lookup control. Together they check that waiters are woken on failure and that clearing cannot destroy a part still being published. I have no paired Vulkan result for this head yet.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.