perf(agc): build a dispatch's compute pipeline off the submit thread #21708
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21708"
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 Ketz7 on 2026-11-16T16:26:57Z.
What
APS5_ASYNC_DRAW_COMPILEset, a dispatch is already skipped while its shader is prepared or specialized on the library prebuild pool (a9259f8865). The Vulkan compute pipeline for the result is still created on the submit thread, though, and on AMD's Windows compiler (LLPC) a large one takes 1–4 minutes. A title that waits for that submission gives up first.APS5_ASYNC_COMPUTE_WORDSSPIR-V words (32768 by default; 0 for every pipeline) and is not built yet is also skipped.VulkanDevice::ComputePipelineAheadreports where the pipeline stands (built, building, start it, or not buildable ahead). On "start", the dispatch handsPrebuildComputePipelineto the library prebuild pool, and a later dispatch of the same shader uses the pipeline.PrebuildComputePipelinesettles the queued mark on every exit (any exception, SPIR-V it cannot build, a device that cannot build ahead), the dispatch's task catches every exception, and a hand-off to the pool that throws abandons the mark (VulkanDevice::AbandonComputePipelineAhead). Queued and failed pipelines are tracked per device and cleared with its other compute pipelines.VulkanDevice::ComputePipelineCountsgainsahead, the compute pipelines created by a build ahead. WithAPS5_PROFILE_DRAW, the driver prints one line when it starts skipping a shader's dispatches and one when its pipeline is ready, with the number skipped.docs/dev/ENVIRONMENT.mddescribes the switch's new part andAPS5_ASYNC_COMPUTE_WORDS.APS5_ASYNC_PIPELINE_WORDS, and adds its line todocs/dev/ENVIRONMENT.mdnext to theAPS5_ASYNC_DRAW_COMPILEline changed here; #22190 adds a line at the same place. The PRs do not touch the same code; whichever merges second keeps both lines. If one switch should cover both, I can follow #19119's.Dispatch.cppwhere this PR adds the skip-logging helpers. Whichever merges second keeps both.Tested
r_rtshadows 1), AMD's driver cache moved aside,APS5_ASYNC_DRAW_COMPILE=1andAPS5_PROFILE_DRAW=1on both builds, 180 s, RX 7900 XT:main1df8b3234b: demo1 starts, then the submission that dispatches the ray-traced shadow shader waits on its pipeline. vkQuake reportsthe GPU has not reached submission 18 (at 17) in 10 sthree times, thenQuake Error: vkWaitForFences failed with code -4, and exits after 49 s with no presents counted.50749eb5fc: still rendering at 180 s, 7,897 presents, through demo1, demo2 and demo3. Only pipelines of 57,233 to 169,011 words were skipped; every smaller one was built in its dispatch. One wait times out at the 180 s cut-off, as the process is stopped.APS5_TRACE_SECONDS=10:20and no otherAPS5_TRACE_*orAPS5_PROFILE_*switch, 1,199 presents each at 60 Hz. Frame p50/p90/p99/max is 16.674/16.921/16.985/17.033 ms onmainand 16.684/16.914/16.982/17.010 ms here; GPU busy per present 4.569 and 4.774 ms. Traces attached.agc_driver_async_draw_compile_enabled(APS5_ASYNC_COMPUTE_WORDS=0) requires that every compute pipeline created during the test was built ahead. Without theDispatch.cppchange it fails with "a dispatch with APS5_ASYNC_DRAW_COMPILE created its compute pipeline itself (1 created, 0 on the library prebuild pool)".agc_driver_async_draw_compile_small_pipeline(default threshold) requires that the test's small pipeline is built in its dispatch and never ahead;agc_driver_async_draw_compile_disabledruns with the switch unset.agc_driver_async_draw_compilequeues a pipeline whose build ahead fails (an incompatible runtime ABI version, which throws before any Vulkan call) and requiresUnavailableafterwards, then does the same for an abandoned one. Without the failure-path cleanup it fails with "a build ahead that failed left its compute pipeline queued, so every dispatch of it would be skipped".ANYPS5_REQUIRE_VULKAN=1:agc_driver_async_draw_compile_tests,agc_driver_compute_pipeline_outside_gpu_mutex_tests,agc_driver_pipelined_dispatch_tests,agc_driver_dispatch_ahead_adopt_check_tests,agc_driver_prepared_shaders_testsandagc_driver_graphics_tests: 36 of 36 pass. (The threeagc_driver_graphics_dump_*tests matched by the same filter runagc_driver_draw_cache_reuse_tests, which was not built, and report Not Run.)APS5_ASYNC_DRAW_COMPILE=1forced on every test,agc_driver_prepared_shaders_lazy_budget_zero,_abi_deferred_concurrent_lazyand_abi_deferred_compute_lazyfail the same way onmain(they expect the first dispatch to run).tools/check_conventions.pypasses.tools/pr_overlap.py --branch: #19119, #18369 and #22190 are the line overlaps, described above; the PRs it could not compare are older ones that conflict withmainand shareVulkanDevice.cpp,Dispatch.cpp,ShaderRegistry.cppordocs/dev/ENVIRONMENT.md.A skipped dispatch also leaves stale data for later dispatches that read its output. In vkQuake, two of RADV’s BVH build passes (programs 0x20c612000 and 0x20c616e00) are among the skipped pipelines, while the small passes that read their output in the 8 MiB acceleration-structure scratch buffer run. Those passes take another build’s leftover triangle coordinates for node offsets and access unmapped memory, which AnyPS5’s BDA checks catch and report as BDA access failed … reason=1 (about 27,000 in a 420 s run). With the BDA byte-loop change on top, both pipelines finish: 307 faults follow the first, and none follow 0x20c612000 for the rest of the run, about 45% of its dispatches.
main(1df8b3234b):This PR (
50749eb5fc):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)APS5_ASYNC_DRAW_COMPILE=1(on a first launch its status bar stays missing, and two large pipelines take over 7 minutes)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T20:01:07Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: ensure a failed or abandoned build-ahead attempt reaches the ordinary dispatch pipeline build path instead of leaving dispatches indefinitely skipped.
What I ran
Reviewed head
135fd6b2ce6e37716da7e9c8c064ef2ed31f25f4. Read the prepared description, commits, manifest, diff, all included changed files, and the changed regions ofVulkanDevice.cpp, plus the targeted pipeline and compile-budget context viarepo_read.py. No tests or build commands were run.Results
Findings
Blocking
VulkanDevice::PrebuildComputePipelinereturns immediately for invalid SPIR-V before clearing the key fromcomputePipelinesQueuedor marking it failed.ComputePipelineAheadthen continues returningBuildingfor that key, so every dispatch is skipped indefinitely. This is reachable becauseComputePipelineAheadreturnsStartbased on SPIR-V validity, but does not establish thatPrebuildComputePipelinewill proceed; an exception swallowed by the dispatch task also leaves the queue state uncleared. Add cleanup on every early-return and failure path, or transition the key to a state that lets a dispatch build synchronously. Evidence:core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:2951,core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:2958,core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:3001; the relevant changed lines arecore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:2976andcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:2985, where cleanup is attempted only after build work starts or throws.Non-blocking
None.
Not verified
No build, tests, or runtime checks were performed. Read all changed files listed as reviewed in the manifest.
VulkanDevice.cppwas excluded from the prepared full-text bundle because of size; its changed and relevant surrounding ranges were read throughrepo_read.py.To get this to a good state
Clear or resolve queued state on every path after
ComputePipelineAheadmarks a pipeline queued, including invalid input and all swallowed exceptions, then rerun the async compute pipeline tests.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T11:22:33Z.
Review: COMMENTED
Reviewed the compute pipeline build-ahead change — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
50749eb5fc, base main.Dispatch.cpparound the new dispatch skip (lines 500–545), and the head matches for the new names withrepo_read.py search.Results
VulkanDevice.cppis too large for the folder; only its diff and search hits were readFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Diagnostics.cpp:110:AsyncComputePipelineWordsparses the variable withstrtoull, so a value that is not a number becomes 0. With 0, every compute pipeline is skipped, which is the widest setting. A malformed value gives the widest skip without any message. Parsing with a check for a number, or logging the fallback, would avoid that.Not verified
VulkanDevice.cpp, listed underreviewedin the file list: I read its diff and the search hits for the new names, not its full text. The queue and settle logic inPrebuildComputePipeline,ComputePipelineAheadandAbandonComputePipelineAheadis reviewed from the diff only.SubmitComputePrebuildis defined incore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppand was not read. If a task is dropped, that shader's dispatches stay skipped for the rest of the run.To get this to a good state
Nothing is required.
Optional:
APS5_ASYNC_COMPUTE_WORDSvalue, or log the fallback, as noted above.Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-18T12:27:23Z.
Review: COMMENTED
Tested on NVIDIA, since the description's title runs are on AMD.
Setup: Windows 11 Pro (build 26300), AMD Ryzen 5 3400G, NVIDIA GeForce RTX 2060 (driver 621.24), WinLibs GCC 15.2.0, Release.
main648ba19b3ewith #22373 (a test-build fix only), and the same tree with head50749eb5fcmerged (clean). vkQuake PPSA99010 01.000.000 with the sharewarepak0.pak, converted with--windows --registryby each build.APS5_ASYNC_DRAW_COMPILE=1andAPS5_PROFILE_DRAW=1on both runs, AnyPS5'sshader_cache/emptied before each run, no pad input, one run each with a 180 s cap.mainexit: clean, code 0 in the run report)On
mainthe log stops growing about 40 s in. An earlier run of the samemainbuild without the switch ended the same way: 12 presents,[gpu] worker at 44 s: dispatch 43.2 s, then a clean exit at 47 s.So the PR also gets vkQuake past the large compute pipelines on NVIDIA's Windows driver.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:33:45Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation has no verified blocking defects, and the supplied test and performance reports support its intended behavior.
What I ran
Reviewed head
f8844e96787cdc7c3ab0ce97a023ddca388ee106against the prepareddiff.patch; no commands or tests were run. I readdescription.md,commits.md,manifest.json, anddiff.patch, then inspected the changed dispatch path, pipeline key and queue lifecycle, prebuild pool submission, and related code inVulkanDevice.cppandShaderRegistry.cpp.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run tests, build the project, or verify the reported hardware runs, traces, or CI. The supplied review artifacts contain full text for every changed file except
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp; I inspected its changed hunks and targeted context usingrepo_read.py.files.jsonwas not available as a review document; the changed-file listing confirms all eight changed paths, with only that large source file excluded from the full-text bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:38:49Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this change, but a correctness issue in the test setup should be addressed before relying on the reported failure-path coverage.
What I ran
Reviewed head
cf2a368078e384580d09901ef335e85e0d083451using the prepared review bundle andrepo_read.py. No build or tests were run. The author reports Windows Vulkan tests, llvmpipe tests, andtools/check_conventions.pyin the PR description; these were not run as part of this review.Results
Findings
Blocking
None.
Non-blocking
AsyncDrawCompile.cpp:52—CheckFailedBuildAhead()returns early whenComputePipelineAhead(failing)isUnavailable, which also skips the abandoned-queue case. This means the test can silently omit both checks on devices that cannot build ahead, while the PR description presents this test as covering failure-path cleanup. Consider reporting the test as skipped when ahead builds are unavailable, or splitting the abandonment check so its result is still exercised independently.Not verified
VulkanDevice.cppwas read throughrepo_read.pybecause its full text was not included in the bundle.To get this to a good state
Nothing is required. The test coverage point above is optional.