feat(agc): capture and replay compute pipeline compilation #3717
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3717"
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 jweidenh on 2026-10-11T15:55:51Z.
What
Cold title startup can spend seconds inside the host driver compiling very large compute pipelines (#2292). Existing shader request replay stops before Vulkan pipeline creation, so it cannot reproduce that compiler workload.
Add opt-in capture of the final SPIR-V and actual descriptor layouts, push-constant ranges, specialization values, required subgroup size and creation flags immediately before compute pipeline compilation.
APS5_DUMP_COMPUTE_MIN_WORDScan restrict captures to large modules. The versioned format is bounded and preserves existing records: up to 8,388,608 SPIR-V words (32 MiB), 36 MiB per record, and 256 MiB per capture directory. This accommodates the reported 5.41–5.45-million-word workload; a 5.5-million-word synthetic record exercises serialization only.agc_compute_pipeline_replayreconstructs one captured pipeline using the runtime pipeline creation helper. Compile-only devices additionally enable supported partially-bound, variable-count and runtime-array descriptor features; ordinary runtime feature enablement is unchanged. It reports module/layout/pipeline/cache wall times and device identity, with explicit fresh or imported application cache. Replay performs no dispatch, imports no guest memory and leaves the normal title pipeline cache untouched. Driver cache state remains uncontrolled. SPIR-V validation is required; unsupported layouts/features and incompatible cache headers fail explicitly. Capture exports the same per-binding flags used to create the native layout, and replay attaches them independently of update-after-bind. Variable-count bindings must be highest-numbered and fit the device layout-support result. Following the RTX 5070 Ti cross-test report, replay also accepts exactly the unconditional Vulkan 1.0 capabilities from the pinned Vulkan registry; feature-dependent capabilities remain checked against the enabled device target.This is a diagnostic prerequisite for the remaining NVIDIA compilation stall, not a claimed startup fix. We do not have the affected title or its large shader capture. No shader semantics or default optimization policy changes.
Tested
Current head:
3740c233bca5f89ef744e7cfb7d7d02b0a82d848, based on0a8b1d32b12a6d6a3acd462787750b482bf78884. Native runtime validation usedecb343aa989954d51f1d488d9b21c25a77f67853; the current head changes only the documentation registry link and commit subject to satisfy conventions. Its C++ and test files are identical, so runtime tests were not repeated. Release builds with SPIRV-Tools and 30-second test limits.ecb343aa: the earlier598e991bCLI reproduced rejection of a valid 49-word Sampled1D fixture on Windows RTX 5090. After the correction, both affected runtime tests passed onecb343aa: Windows 11 / RTX 5090 / NVIDIA 617.42 (2.62 s replay, 3.01 s capture integration) and Linux GCC 13.3 / lavapipe on the private self-hosted validation run, both below 0.54 s with no skips. Lavapipe retained only its explicit subgroup-size-32 refusal. Sampled1D compiled, Kernel and unknown capability values were rejected by the capability guard, all descriptor-flag checks remained positive, and two captured pipelines replayed after matching normal/captured output. The unchanged codec and layout-mock tests were not repeated for this capability-only change.598e991bca21695ec316bce908d5fd00449acff8: Windows 11, RTX 5090 / NVIDIA 617.42, portable WinLibs GCC 15.2.0 r7: all four focused tests passed on that exact head, no skips or feature refusals (7.90 s total; each below 2.80 s). All three flag combinations, runtime-array capability and required subgroup size 32 compiled. Normal and captured output matched, and two captured pipelines replayed.a4ae6d7e311d98e415322e701d1f8f24df9f2d6c, each below 0.54 s. All new flag combinations and runtime-array capability compiled; subgroup size 32 was explicitly refused by lavapipe. That initial run failed only the new mock fixture because it lacked a placeholder buffer. The fixture-only change froma4ae6d7eto598e991badds that buffer; the targeted continuation passed the corrected layout test on598e991bwithout rerunning the three unchanged passing tests. Both runs built the targeted executables and patched runtime libraries.f2b13cd385b29be8f0826d8507f3b50d35649060format implementation rejects the 5.5-million-word fixture and partially-bound/variable-count flags in separate native macOS controls. The corrected format test passes: large encode/decode/file round trip, oversized word/record/file rejection, flag identity and invalid-variable-binding checks.The affected title's SPIR-V is unavailable. The large fixture tests serialization, not driver compilation of that workload. No retail-title startup improvement, cold-driver-cache benchmark or NVIDIA LTO policy change is claimed.
AI-assisted implementation and review.
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 Scramblrrrr on 2026-10-11T19:51:04Z.
I am cross-testing 007 on Windows RTX 5070 Ti / NVIDIA 617.14, and this diagnostic could help isolate our compile-memory stop. Source review of f2b13cd38 against the #757/#758 runtime table stack found two integration limits before I attempt a title capture:
ComputePipelineCapture::MaxFileBytes = 20 * 1024 * 1024before metadata. SleglJan separately measured a ~5.45M-word module. A bounded format is useful, but the current bound excludes this motivating workload. My newer current-main run was guarded earlier at a 750,409-word pipeline, which fits.PARTIALLY_BOUND | VARIABLE_DESCRIPTOR_COUNTflags.LayoutBindings()returns the Vk bindings without their flags; the capture reconstructs flags only for update-after-bind storage buffers, and replay attaches binding-flags pNext only when updateAfterBind is set. That cannot preserve the actual table layout on this stack. The schema already has per-binding flags, so exporting the real flags and accepting/attaching them independently of update-after-bind seems the natural compatibility path.These are source-review findings, not a replay test result or a clean-main failure. I keep title SPIR-V/captures local and can report metadata/timing when the capture is compatible. I am using your implementation rather than opening a duplicate diagnostic PR. AI-assisted (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T20:14:16Z.
Windows cross-test follow-up: local integration
codex/first-light-compute-capture-cross-testhead f04a55c662 is public on my fork (your commits retained). Runtime-table binding flags now survive capture and replay; format roundtrip/rejection coverage added. The OFF runtime table fixture emitted34 captures,17 with variable descriptor counts.Separate tools-ON replay build, optimizer disabled, required Vulkan on RTX5070Ti/NVIDIA617.14: original three capture/replay tests pass, plus a synthetic runtime-table capture replays successfully (no dispatch, pipeline create52.24ms, uncontrolled driver cache). This exposed another compatibility issue: the optional target capability list does not include core Vulkan capabilities such as
Sampled1D43, so replay rejected an otherwise accepted runtime module. Local fix permits the Vulkan1.0 core set from Vulkan-Headersregistry/vk.xmland still rejects unsupported capabilities; regression accepts43 and explicitly rejects Kernel6. The three checks pass again (1.77s).No title captures or code uploaded. These are integration changes, not a competing PR; happy for you to fold in the focused fixes.
AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T20:32:44Z.
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.
main)core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL1156, L1233core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL1149-1151, L1156, L1417-1418, L1424, L1427, L2629, L2638core/libs/prx/libSceAgcDriver/tests/Graphics.cppL4324core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL1156, L1233core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL1149-1151, L1156, L1417-1418, L1424, L1427, L2629, L2638core/libs/prx/libSceAgcDriver/tests/Graphics.cppL4324Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:54:48Z.
Checked on current main (RADV): build and the scoped ctest pass; with SPIRV-Tools ON the capture, replay, capture_run, descriptor-layout-flags, graphics and branch_past_endpgm tests pass too. The compute pipeline refactor keeps the same flags and required subgroup size as before, and the cross-test findings from @Scramblrrrr (file bound, per-binding flags, core capabilities) are covered by the tests.
Note: #757/#758 touch the same per-binding flag code in
ShaderResources.cpp/VulkanDevice.cpp; whichever lands second will need a rebase. Merging once the full Linux/Windows build is green, since the new tests open a Vulkan device.Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T00:35:32Z.
Additional Windows/RTX 3060 evidence from the existing capture/replay tool:
For one large original compute capture, native pipeline creation took 291368.2 ms when importing the title's existing extracted application cache. Replaying it again with that run's exported cache took 21.0412 ms. Whole-process wall time changed from 294.497 s to 4.729 s (62.28×). These were compile-only replays without dispatch; NVIDIA's global driver cache was uncontrolled, and both runs imported application-cache data.
In the next Demon's Souls run after merging a separately replayed original 756283-word pipeline's cache into the title's cache, that pipeline's creation took 153.60 ms. Its earlier fresh-application-cache offline replay took 279101.34 ms. The game and offline replay are different contexts, and the global driver cache was again uncontrolled, so this supports using the tool for iteration. It does not establish a controlled full-title FPS improvement.
The resulting title run reached cinematic text and online login. Character creation, the first level and a playable milestone were not verified in that run. No full-title FPS or memory improvement is claimed. No shader code, captures, disassembly or data files are attached.
GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100.