Repository navigation
perf(agc): create compute pipelines before taking the GPU lock - #5989
Merged
oneandonlydean merged 3 commits intoOct 14, 2026
Merged
oneandonlydean merged 3 commits into
oneandonlydean merged 3 commits into
Conversation
PrepareDispatch now creates a missing compute pipeline once the descriptor set layout is known, so the driver's compile no longer runs under GuestMemory::GpuMutex. Other queues, presentation and label writes go on during it, and compiles from different queues overlap. Two queues that need the same new variant create it once. The pipeline is still created in dispatch() when the layout is only built under the lock, or with APS5_LOCKED_BUILD=1. The creation passes the context's PipelineCacheSynchronization to CreateComputePipeline.
… from the described set layout
9 tasks done
11 tasks done
|
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.
|
11 tasks done
This was referenced Oct 16, 2026
Merged
TheBlenDed
pushed a commit
to TheBlenDed/AnyPS5
that referenced
this pull request
Oct 25, 2026
Main now carries boykopovar#4450, boykopovar#4475 and Pipodi's pointer-in-record table columns (c794273), which replace our copies and our record-pointer columns; boykopovar#5181, boykopovar#5989, boykopovar#5906, boykopovar#5484 (live snapshot mismatches serve live bytes; our retry is dropped), boykopovar#5483, boykopovar#5522, boykopovar#4732, boykopovar#5792. Kept local: the two-lane wave64 hang fixes, boykopovar#5815, option 1 substitutes, image-table stores and set 0 tables, stencil remap, 10_11_11 blending, the VRAM share/spill, block-hash snapshots, diagnostics. Versions: disk FormatVersion 42, RuntimeAbi 17, request serializer v30, BdaAbi UnnormalizedWrap 11 / DirectImage 12. Notes in work/sync-20261013/*-3.md. AI-assisted: yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carries @karanvora2599's #4897 (authorship kept) with MarcZX100's review point, plus the address-table shaders that #4897 still compiled under the lock; supersedes #4897; fixes #4977.
What
Compute pipelines are created before the dispatch takes
GuestMemory::GpuMutex, instead of inVulkanDevice::dispatchunder it.Background. On
main, the first dispatch of a compiled variant creates its pipeline indispatch(), whichDriver::dispatchcalls underGpuMutex. While the driver compiles, everything else that takes the mutex waits: other queues' dispatches and draws,Driver::Present, label writes, memory waits and the guest'smunmap. Large compute modules take seconds on NVIDIA (#2292, #2013) and minutes on ANV (#4977).#4897 (karanvora2599), rebased onto
main:VulkanDevice::computePipeline: module, layout, specialization, subgroup size, feat(agc): capture and replay compute pipeline compilation #3717's capture and the statistics.computePipelinereturns the pipeline fromcomputePipelines, or creates and inserts it. A pipeline another thread is creating is waited for through ashared_futureper key incomputePipelinesBuilding, so two queues that need the same new variant create it once; if creation fails, every waiter gets the error.PrepareDispatchcalls it once the descriptor set layout is known (stage A or the cachedShaderResources); the result travels inPreparedDispatch::objects.dispatch()still creates it under the lock withAPS5_LOCKED_BUILD=1.CreateComputePipelinegetscontext.pipelineCacheSynchronization(fix(agc): serialize pipeline cache snapshots #4795), so the moved creation is guarded against the cache snapshot (MarcZX100's review).APS5_LOCKED_PIPELINEis dropped; comparisons are against amainbuild.PreparedDispatch::cachedkeeps alive,workgroupMemoryLayoutand the pipeline cache, which is created withoutVK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT(graphics library prebuilds already use it outside the lock).Address-table shaders:
ShaderResourcesdefers its whole build toComplete(), under the mutex), so with perf(agc): create compute pipelines before taking the GPU lock #4897 alone its layout is null inPrepareDispatchand it is still created under the mutex. These are the largest modules, and the ones in AGC: vkQuake's ray-traced shadow compute shader becomes 519,500 SPIR-V words; Intel ANV compiles it for minutes under GpuMutex and crashes (PPSA99010, Linux) #4977.Graphics::DescribeSetLayoutsmakes it from the shader alone, as the draw path and the graphics library prebuild already do. For an address-table shader,PrepareDispatchcreates the pipeline with that layout.dispatch()checks afterComplete()that the build's layout key equals the described one, and throws if not.computePipelinetakes the set layout and its key instead of aShaderResources; the compute capture (APS5_DUMP_COMPUTE_PIPELINES) reads the bindings from the key.VulkanDevice::ComputePipelineCounts()counts compute pipelines created, and those created while the creating thread held the mutex; the[vk]line ofAPS5_PROFILE_DRAWprints both.Results don't change: module, specialization, subgroup size, flags, per-variant key and the descriptor-cache set layout object are the same.
Tested
ANYPS5_ENABLE_SPIRV_TOOLS=ON, onmainat ea30c92:ctest -R "agc_|dispatch|bda|pipeline"withANYPS5_REQUIRE_VULKAN=1, 556 tests, all pass (agc_driver_stencil_ref_exportskipped).agc_driver_compute_pipeline_outside_gpu_mutex(new): the test thread holds the mutex and submits a new program on queue 0x20. Its pipeline has to be created while the lock is still held, none under the lock, and the dispatch stores the right value after release. Fails onmain.agc_driver_global_loadsnow goes throughPrepareDispatchandDispatchunder the mutex, as the driver does, and requires the address-table program's pipeline to be created inPrepareDispatch. It fails with perf(agc): create compute pipelines before taking the GPU lock #4897's change alone.APS5_PROFILE_DRAW=1, each build with its own empty shader and pipeline caches, then a second run on the same caches. Time invkCreate*Pipelinescalls of 2 ms or more while the creating thread heldGpuMutex(local timing patch, not part of this PR; measured on the same change rebased onto 78f1aea):With #4897's change alone (first run, first 152 s), 43 creates held the mutex for 54.3 s: queue 0's four largest programs (406K to 504K words, all address-table shaders) were still created under it. With this PR no compute pipeline is created under the mutex; what remains are graphics pipelines in
Draw(the 8.5 s one is aDRAW_INDEX_AUTO), which is a separate change.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)