perf(agc): relink library pipelines with link-time optimization in the background #2713
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2713"
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 adriadam10 on 2026-10-10T11:55:05Z.
What
A graphics pipeline linked from libraries (#2636) is fast-linked at the draw, as before. A background thread then links the same libraries again with
VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT, and the pipeline binds the optimized one from the next draw on. This is the TechnicalDebt entry #2636 added.Why: a fast link cannot drop the vertex outputs the fragment stage doesn't read. I measured it with
VK_KHR_pipeline_executable_propertieson RADV (Radeon 660M, Mesa 26.2.4), using Astro's Playroom's 483 prepared vertex shaders, each paired with a fragment stage that reads none of their outputs:The optimized link equals the whole pipeline on every statistic in 483/483. On NVIDIA (RTX 4090, Raghav314's run in #2242) 13 of 15 PPSA36082 vertex shaders went from 38 to up to 68 registers fast-linked, and the optimized link gave back the whole pipeline's code.
Changes:
PipelineLibrary: libraries are created withRETAIN_LINK_TIME_OPTIMIZATION_INFO.LinkPipelineFromLibrariesreturns the fast link and queues the optimized link on one detached worker. The result goes into anOptimizedPipelineslot shared with thePipeline. Whichever side comes second (thePipelinebeing destroyed, or the job finishing) destroys it, through an atomic exchange, so it is destroyed exactly once.Pipeline::Continuebinds the optimized handle once it exists. The fast pipeline stays alive until thePipelineis destroyed, since recorded draws may still reference it.ClearPipelineLibraries, and soClearCachedPipelinesat device teardown, waits for the device's pending jobs.WaitForOptimizedPipelinesdoes the same for tests.APS5_NO_PIPELINE_LTO=1keeps fast links only.Tested
Linux, AMD Radeon 660M (RADV, Mesa 26.2.4), and CI's lavapipe (Mesa 25.2.8).
ctest -R '^agc_|^shader', GPL on (default)APS5_NO_GPL=1(today's path)^agc_on CI's lavapipe (GPL on), without the 4-minutebuffer_formatVK_LAYER_KHRONOS_validation, GPL on and offVUID-vkCmdPipelineBarrier-dstAccessMask-02816,VUID-vkCmdPipelineBarrier-srcAccessMask-02815,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605)agc_pipeline_library, recorder, depth bias per face, dual-source blend, mesh)--repeat until-fail:20agc_pipeline_librarynow waits for the worker and checks two things: every linked pipeline got its optimized link, and two of them bind it. The newagc_pipeline_library_fast_onlyruns the same test withAPS5_NO_PIPELINE_LTO=1and expects none.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T12:25:04Z.
Fixed:
agc_pipeline_library_fast_onlylacked the Windows PATH to libc's DLL (exit 0xc0000135 in the full build). It now gets the same ENVIRONMENT_MODIFICATION as the other two pipeline-library tests.