fix(agc): build the store-pages compute variant before taking the GPU mutex #28001
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28001"
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 muhmuhkuh on 2026-11-28T02:57:30Z.
What
PrepareDispatchbuilds a dispatch's{0, 0, 0}zero-base compute pipeline before the GPU mutex is taken (computePipeline), so recording finds it. A module that stores through store pages also needs its store-pages variant, though, andrecordDispatchbuilt that variant on first use (specializedComputePipeline(..., {0, 0, 0}, true)), with the GPU mutex held. For a large module that is a full second pipeline build, several seconds long, and every other queue waits on the mutex meanwhile.Change:
PrepareDispatchbuilds the store-pages variant right after the pipeline when the module has one (objects->storePages), through the samespecializedComputePipelinecall and key the recording path uses. Recording then finds it insplitPipelines.Tested
Built and run on
main4814cae8551and on this branch on the same machine and GPU.agc_driver_bda_store_heap_mirror_store_pages_outside_mutex(BdaStoreHeapMirror --store-pages-outside-mutex): compiles a store into a heap mirror, prepares it withPrepareDispatchoutside the GPU mutex, records it withDispatchwhile the test holds the GPU mutex, and checks that every thread's store reached guest memory, that the pipeline and its store-pages variant were built, and thatComputePipelineCounts().underGpuMutexdid not change.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest --test-dir build -R 'agc_driver_bda_store_heap_mirror|agc_driver_compute_pipeline_outside_gpu_mutex' -V:main: 6/6 passed;mainwith only the new test: it fails with "recording a prepared store into a heap mirror created 1 compute pipeline(s) under the GPU mutex";was not found but was requested by env var VK_INSTANCE_LAYERS;VUID-lines: 0 onmain, 0 on this branch.VUID-lines.tools/check_conventions.py --base origin/main:All conventions checks passed.tools/pr_overlap.py --branch fix/agc-store-pages-before-gpu-mutex: no overlap with the pull requests it could compare. It cannot compare 63 open pull requests that touchVulkanDevice.cppand conflict withmainthemselves. Checked by hand withgit diffagainst their merge bases: none adds aspecializedComputePipelinecall or this test; #7642, #9508, #10193, #13928, #13929, #22692 and #26197 change other lines inPrepareDispatch, none of its pipeline building.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 Plyxen on 2026-11-28T07:01:35Z.
Review: APPROVED
Checked head
8d27fcfebe. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #28006, #27985, #28002, #27991, #27987, #28007, #27994.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded. In the full CPU suite (5,135 tests) the only failure iswindows_read_trap_unknown, which fails onmaintoo (fixed in #28028). The full GPU suite (2,249 tests) on both GPUs, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layerand the 1.4.363 layer inserted, matchesmainon the same machine. The GPUs were an NVIDIA RTX 5080 (621.24) and an AMD Radeon gfx1036 iGPU (26.11.2). Onlyagc_driver_linear_target_import_creationfails, as onmain(fixed in #28029), and neither log has aVUID-orSYNC-HAZARDline.agc_driver_bda_store_heap_mirror_store_pages_outside_mutexpasses. The GPU suite list above predates the new tests, so I applied this PR again with #27987 and #28007 and ran the new tests 3 times on each GPU with the same environment: all pass, with the layer inserted and noVUID-orSYNC-HAZARDline.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T07:30:27Z.
Review: APPROVED
Reviewed — looks good
The change at head
8d27fcfebe4e9122ec7a779583c6f419dadab230prebuilds the store-pages specialization during dispatch preparation, and the inspected call path uses that same cached specialization while recording.What I ran
Read the prepared review bundle and pinned source with
repo_read.pyreader tools. No tests or builds were run by me; the test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or builds were run in this review. The author's reported test results, validation-layer output, and convention checks were not independently verified.
VulkanDevice.cppwas read through the pinned reader because it was excluded from the review folder; the other changed files were read in full. No other files were excluded by the review manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:37:47Z.
Review: COMMENTED
PrepareDispatchnow warms the{0, 0, 0}store-pages specialization. When a dispatch exceeds a device workgroup limit, recording still builds nonzero-offset variants withspecializedComputePipeline(..., {xBase, yBase, zBase}, storePages). Could the PR state that the lock guarantee covers the zero-base case and add an over-limit check if the guarantee is meant to cover chunked dispatches too?Source review at
8d27fcfebe. The head trial-merges onto700fae9438. Paired Vulkan execution is pending.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.