fix(agc): reapply pipeline cache persistence with guarded key queries #15169
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15169"
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 liskeee on 2026-11-02T19:46:08Z.
What
I reapply #13931, reverted in #14839: driver pipeline caches survive source updates, and eligible compute pipelines are captured and restored with
VK_KHR_pipeline_binary, with ordinary driver-cache fallback. Against mergedmain6773f91a7eI keep main's recorder error handling, debt entries,APS5_HEADLESS_PIPELINE_CACHEloading condition and portability-subset test features, and link the store test againstlibSceAgcDriverbecauseDeviceProcLookupsmoved out of the header. The binary layout key also tells main's scratch-pool layouts apart (0, 1 or 2 additional descriptor sets); layouts without a scratch pool keep the same contribution to the key.New in this PR: global and per-pipeline key queries write into separate, 64-byte-aligned heap scratch followed by a 64-byte guard filled with
0xa5, and a key is accepted only afterVK_SUCCESS, an intact guard, the expectedsType, a nullpNextand a size from 1 toVK_MAX_PIPELINE_BINARY_KEY_SIZE_KHR.A rejected per-pipeline key falls back to an ordinary build for that pipeline. I have not found the cause of the NVIDIA Linux startup crash in the code: the call uses the Khronos function-pointer type from the device resolver, the output structure is initialised, and the feature is enabled before the call. These checks detect malformed keys and writes that reach the guard; they cannot contain arbitrary driver corruption or clobbered registers, and they cannot stop a crash inside the call.
APS5_NO_PIPELINE_BINARIESstill turns the store off before the call.Tested
Windows, NVIDIA GeForce RTX 4080, driver 610.88, and the affected Linux RTX 4090 (run by @oneandonlydean). No title or performance claim.
c8244e0269merged with themainof that day and reports 28/28 passing withVK_LAYER_KHRONOS_validationand 28/28 without it, noVUID-line and no crash, with the startup test reportingstore readyon that device. I treat this as startup and store coverage, not a full game boot.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -j 1 -V, the 139 existing tests registered in the files this PR touches (pipeline cache, recorder and Vulkan test-device tests):main6773f91a7e139/139, this PR1202ace37c139/139 (the laterbe14e4c25echanges only the debt entry's coverage sentence). The validation layer loaded in both logs, neither reports a missing requested layer, and neither has aVUID-orSYNC-HAZARD-line.sTypeor non-nullpNextfor global and per-pipeline keys, a corrupted guard and the fallback after a rejected global key. The new tests require the added scratch type andIsReady. With the startup test,agc_pipeline_binary_vulkanand threeagc_pipeline_cache_allocationmodes, all 17 tests this PR adds pass under the settings above.agc_driver_pipeline_binary_startup(new): creates the production device with the shader cache enabled in a temporary directory and requires the store to be ready when the device hasVK_KHR_pipeline_binary(exit 77 withskipped, the device lacks VK_KHR_pipeline_binaryotherwise). On the RTX 4080 it printspipeline binary startup: global-key query completed successfully; store ready; device=NVIDIA GeForce RTX 4080; driver=NVIDIA 610.88.ANYPS5_NO_SHADER_CACHEnorAPS5_NO_PIPELINE_BINARIESset, validation layer loaded), RTX 4080: 103/103 pass: the startup test, the binary-store and pipeline-cache tests,agc_driver_small_copy_sync, bothagc_driver_address_passestests, the otheragc_drivertests that do not disable the cache, and the automatically addedagc_driver_pm4_replayfixture (which disables the shader cache itself). NoVUID-line.agc_pipeline_binary_vulkansaves binary records for two pipelines and restores both in the next process. Onmain6773f91a7e, the 85 of these tests that exist there, plus the fixture, pass 86/86. The binary round-trip test uses trivial shaders and an empty layout, so it does not test scratch-pool layouts.Checklist
main; no other open PR implements the same functionsMerged with
main6773f91a7e, without a force-push.tools/pr_overlap.py --branchon 11-09: of the 295 open PRs that share files or exports with this branch, none of those it could compare has conflicting lines; 94 conflict withmainthemselves, so it could not compare them and failed closed (mostlyVulkanDevice.cpp,Recorder.cpp,CMakeLists.txt,ENVIRONMENT.mdand the debt file). A GitHub search found no open PR implementing driver pipeline caches or pipeline binaries.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt fileNo unimplemented exports or silent stubs are added.
.mdfiles or images added to the repository (attach them to this PR)No third-party code is added.
🤖 Generated with Claude Code