refactor(agc): link missing draw pipelines after releasing the GPU mutex #26084
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26084"
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 kripotker on 2026-11-23T08:14:40Z.
What
Driver::commitDrawholdsGuestMemory::GpuMutex()acrossVulkanDevice::Draw, so a draw whose graphics pipeline is not resident linked it under the mutex. #25434 moved the shader library builds in front of the mutex; the final link of a first-visit pipeline still ran under it, and every thread that takes the mutex waited for it (#25352).When
commitDrawholds the mutex at depth one,Graphics::Drawnow asksResidentPipelineOrUnlockedBuildfor the pipeline. A missing one is stashed in a thread-localUnlockedPipelineBuildslot and the draw returns without recording.commitDrawreleases the mutex, builds the pipeline (Vulkan.GraphicsPipelineUnlockedtimer), and commits the draw again, which now finds it resident. The second commit is safe becauserecordLabelsForPacketdrains the deferred labels on the first call andnoteDrawWriterscan repeat; the target and resource steps ofprepareDrawbefore the lookup already had to tolerate an unrecorded draw, because onmainprepareDrawreturns false after them for an indirect draw with no records or only empty records (and, withAPS5_ASYNC_PIPELINE_WORDSset, for a deferred build). WithAPS5_PROFILE_DRAW, the abandoned first commit is counted as a draw in the draw profile, as the deferred build path already is, so cold draws count twice there; the Edith Finch captures in the review thread do not set it. The retried commit skips the recipe attempt, which the first commit already found could not record the draw. Nested callers (mutex depth above one) and the deferred build path keep building under the mutex as before. A failed build falls back to the locked path on the second commit.Draws that issue several sub-draws (mesh layer windows, tessellation followed by a geometry stage) call
UnlockedPipelineBuild::Refuse()and build under the mutex as before, and once a build is stashed every later lookup in the commit skips recording. A stashed build counts indeferredBuilds().runningfrom the stash, under the mutex, until it ends, soClearCachedPipelineswaits for it.GraphicsPipelineOutsideGpuMutex(from #25434) now also requiresGraphicsPipelineLibraryLockedTotals()[4] == 0, so no pipeline is linked while the mutex is held.agc_pipeline_unlocked_buildcovers the stash and build helpers.Related open PRs: #11914 serializes concurrent builds of an identical graphics pipeline, which applies the same way to two draws that now build one outside the mutex; #5925 builds a submission's pipelines ahead on a compile pool instead. #26196 changes
PrebuildGraphicsLibrariesOnFirstVisitnext to the new lookup inPipeline.cpp, and #26197 adds a field to thecommitDrawlines this PR changes; both are textual overlaps only.Paired cold captures of
mainand this head on Edith Finch's Molly scene (#25352) are in the review thread: noGpuMutex.wait.*slice over 100 ms is left (4, 4.4 s onmain) and total mutex wait drops from 15.5 s to 10.7 s over the 90 s window, but the first-visit hitches stay the same length (6 frames over 1 s in each run), because the frame waits for the draw being linked. The repeatedprepareDrawcosts about 0.17 s over that window. This PR makes no speed claim.Tested
Windows 11 Pro 26300, AMD Ryzen AI MAX+ 388 with Radeon 8060S, AMD driver 26.11.2, MinGW build.
mainisd795f93238with only the extendedGraphicsPipelineOutsideGpuMutexapplied; this PR is35b0269caaonb8b8f49250, and the commits between those two bases do not touchlibSceAgcDriver.ctest --test-dir build -R 'agc_driver_pipelined|agc_pipeline|agc_driver_graphics_pipeline_outside_gpu_mutex' -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer, Khronos validation layer 1.4.363.1:main+ the extended test35b0269caa)agc_driver_graphics_pipeline_outside_gpu_mutexa first-visit draw linked 1 graphics pipeline(s) while the GPU mutex was heldInsert instance layer "VK_LAYER_KHRONOS_validation"was not found but was requested by env var VK_INSTANCE_LAYERSVUID-linesThe extra test on this PR is the new
agc_pipeline_unlocked_build. The same set also passed 60 of 60 with 0VUID-on the earlier headse05dbe56baandf1f900c819.python3 tools/check_conventions.py --base origin/mainpasses.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T08:27:32Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
e05dbe56ba00ffff68c737b8ce6953c526e65523. No commands or tests were run in this review; the test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full
core/libs/prx/libSceAgcDriver/tests/Graphics.cppwas not read; only the changed test hunk and surrounding lines were reviewed. No runtime or build checks were run. Read the review description, commits, manifest, diff, and the changed implementation and test ranges inDraw.cpp,Pipeline.hpp,Pipeline.cpp,Graphics.cpp,agc_driver_graphics_tests.cmake, andGraphicsPipelineOutsideGpuMutex.cpp. The manifest lists all seven changed files as included exceptGraphics.cpp, which was excluded because it was too large for the review folder; its relevant lines were read through the pinned reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T10:37:29Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
f1f900c819aa491ba3e32cc75eef4f408f4ce606usingrepo_read.pyfor targeted source inspection. No tests or builds were run. The author reports targeted Vulkan tests and a convention check; those results were not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded from the prepared files because it was too large; I read only the added test range through the pinned reader. Other unchanged callers and runtime behavior on hardware were not exhaustively reviewed. No test command or build was run in this review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T11:11:48Z.
Review: COMMENTED
Reviewed — no blocking findings
Formal approval is not justified because I could not run the checks in this review session; the author reports passing tests and conventions checks.
What I ran
Reviewed head
35b0269caa518f76e9480276f68d69f3f74335bc. No commands or tests were run; I inspected the prepared diff and changed code throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently run the reported CTest or conventions commands. The complete unchanged portions of the large
tests/Graphics.cppfile were not read; its added test function and dispatch changes were inspected. No changed files were excluded from the review: all seven changed files were read at the relevant changed ranges, using the reader for the test file too.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:46:42Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the review found no verified blocking defects, though the full test source was unavailable in the review bundle.
What I ran
Reviewed head
2e4df67a31b9e279a1206ef2722fc4f8ebce22bdusing the prepared review bundle andrepo_read.pyreader. No build or test commands were run.Results
Findings
Blocking
None verified in the code read.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded because it exceeded the review folder limit. Its added test code was inspected indiff.patch, but the full file and surrounding test harness were not read. No build, test, Windows, Vulkan hardware, or console behavior was independently checked. The description reports successful tests and hardware captures; these remain author-reported.Files read at the changed lines:
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp,core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp,core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp,core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmake, andcore/libs/prx/libSceAgcDriver/tests/execution/GraphicsPipelineOutsideGpuMutex.cpp. Also read targeted surrounding ranges inDraw.cppandPipeline.cpp.tests/Graphics.cppwas excluded from full-file review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T07:48:57Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
bfaf0eca-78c3-424f-96c4-0f6584ab769bReviewing files that changed from the base of the PR and between
63ee1c120aand31e0c79cde.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/GraphicsPipelineOutsideGpuMutex.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T07:55:54Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the checks reported by the author passed, and the code reviewed supports the stated behavior.
What I ran
Reviewed head
31e0c79cdecd1b7b8ea908bab4be5fdf122d2246. No commands or tests were run; the PR description reports its test results. Read the prepared description, commit list, manifest, diff, and the relevant source ranges inDraw.cpp,Pipeline.cpp,Driver/Draw/Draw.cpp, and the CMake test registration. The fulltests/Graphics.cppfile was excluded as too large; only its changed test excerpt was read. Other changed-file full texts were not read.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full
tests/Graphics.cppfile and full texts ofPipeline.hppand both execution test files were not read. The report’s test results, hardware measurements, and convention check were not independently verified. The other changed lines inGraphics/src/Draw.cppandPipeline.cppwere not all inspected.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:36:14Z.
Review: COMMENTED
The stencil export budget and scalar-buffer-base CTests passed on main and the change on Linux Mesa lavapipe with Khronos validation 1.4.369. The unlocked-pipeline and out-of-mutex graphics pipeline tests also passed on the change. The logs show the requested validation layer being inserted, with zero missing-layer diagnostics or VUIDs.
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.