perf(agc): share one render pass between mesh-path draws run as compute #15548
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15548"
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 Gonic0 on 2026-11-03T18:37:48Z.
What
Stacked on #17611, which supersedes #9356. This branch is #17611's current head
70015a5ccfand this pull request's commite17b4986d1. That commit is the previous head's91d892a10bcherry-picked onto70015a5ccfwithout conflicts and without changes. It adds no request serialization or shader disk cache version of its own; it uses #17611's shader disk cache format 78. The conflicts withmainare #17611's: #17611 alone conflicts withmainin the same files, and this commit applies cleanly on top of it.Builds on #17611. A mesh-path draw run as a compute pass forces its own render pass today, because its dispatch must be recorded outside one. Consecutive mesh-path draws into the same attachments therefore cost a pass each, and on a tile-based GPU each pass loads and stores the attachments again.
With this change, the recorder splits the batch when a mesh-path draw begins a pass: the work before the pass, a prologue command buffer, and the pass. The draw records its dispatch into the prologue. A later mesh-path draw that continues the pass under the existing hazard check (
PassHazards::Check) records its dispatch into the same prologue and its draw into the open pass. The three command buffers are submitted together, in order, in the batch's onevkQueueSubmit.ALL_COMMANDSmemory writes toCOMPUTE_SHADER,DRAW_INDIRECTandTRANSFERreads and writes, so its dispatches see everything recorded before the pass. Each dispatch keeps its own trailing barrier toDRAW_INDIRECTandVERTEX_SHADER, which orders it before the draws in the pass.mainrecords the work its dispatch depends on into the pass command buffer, which runs after the prologue.DrawPassStartcarriesmain's pass break reason next to the prologue. A draw that closes an open pass to start a prologue reportsforced.Tested
macOS 27.3, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2. #17611's head does not build on macOS without #16591, #16593, #17532, #17767 and #17425, so both trees below are
70015a5ccfwith those five applied on a separate test branch that is not part of this pull request. Seven test targets outside the mesh path still fail to compile on macOS on that tree (agc_driver_table_index_validation,guest_ces_gbsetters,guest_ces_gbsetters_module,nkwebkit_resourcerequest,guest_webrtc_key_params,guest_webrtc_rtcp_transport_feedback,guest_exception_fault), the same with and without this commit.ctest --test-dir build -R '^(request_serializer|shader_cache_file_read|agc_shader_memory|agc_mesh_output_budget|agc_driver_(graphics|layered_[a-z_]+|mesh[a-z_]*|pass_break_reasons|pass_input_hazard))$' -Von MoltenVK from Vulkan SDK 1.4.363.0, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layerandAPS5_NO_MESH_SHADER=1:70015a5ccfe17b4986d1agc_driver_mesh_compute_shared_passVK_LAYER_KHRONOS_validationwas not found but was requested by env var VK_INSTANCE_LAYERSVUID-messagesThe eight skipped tests need
VK_EXT_mesh_shader, which MoltenVK does not expose. KosmicKrisp and Linux and Windows were not run on this head.tools/check_conventions.pypasses.Performance: the measurement below is from an earlier head (
f49a25ae9fplus3a3880e952, onmain4f41f4c375with the macOS port pull requests) and was not repeated on this one, so thetools/trace_digest.pysummaries ofmainand of this change from one machine and scene are still missing. PPSA21564 on KosmicKrisp (noVK_EXT_mesh_shader),APS5_PROFILE_GPU=1. Three rounds of 140 s runs, alternating base and this change. Only the heavy windows count: the 10 s windows with more than 3000 mesh-path draws, about 75 per present.drawclass GPU time per present, basedrawclass GPU time per present, this changeOn average, 21 % more presents and 26 % less
drawGPU time in those windows. This head adds the captured, staged clear and pixel function LDS exclusions above; how many of PPSA21564's mesh-path draws they cover was not measured. Frames dumped in the same scene showed no missing or broken geometry. That the saving comes from attachment loads and stores of the merged passes is inferred from the tile-based design, not measured on its own.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:21:13Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the CPU-resolved indirect mesh-compute records so each draw uses its own arguments and output buffer.
What I ran
Reviewed head
91d892a10bb3c58cb6c98d72c7d52ad3e710a860usingrepo_read.pyagainst the prepared diff; no build or tests were run by me. Read the description, commits, diff, manifest, and changed source files relevant to mesh argument resolution and draw recording. The full text ofVulkanDevice.cpp,Graphics.cpp, andShaderMemory.cppwas excluded from the review folder; I read targeted ranges of the first two through the reader. No ruling file was read, as instructed.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:4017: For indirect draws that cannot use the GPU path,recordPreparedDrawpassesargs != nullptrtorecordMeshCompute, which CPU-resolves the first record intodraw; however, the draw loop can contain multiple resolved records. The function then dispatches and draws using the samemeshArgumentsandmeshOutputfor every record, and writesargumentBufferto that shared output. This causes every fallback record to reuse the first record's mesh arguments and overwrite/read the same output allocation. Create per-record arguments and output, or otherwise batch and dispatch each resolved record with its own data.Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp. Targeted relevant ranges ofVulkanDevice.cppandGraphics.cppwere read throughrepo_read.py;ShaderMemory.cppwas not read.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T14:00:27Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: implement the documented layer-limit fallback in the compute-path decision so oversized layered draws use compute instead of exceeding native mesh output limits.
What I ran
Reviewed head
e17b4986d1f0f395041f4ecc374363a4f2d2699dusing the prepared diff andrepo_read.pyreader. No build or tests were run. The description reports a macOS/MoltenVK test run, but that is author-reported and used a separate test branch with additional commits. No merged-preview check was run.Results
Findings
Blocking
maxMeshOutputLayers:MeshDrawRunsAsCompute(bool meshShader, std::uint32_t, ...)only returns true when mesh shaders are unavailable (Draw.cpp:1297-1298). Its context overload delegates to that predicate, so on mesh-capable devices these layered draws stay on the native mesh path (Draw.cpp:1301-1303). ThemaxMeshOutputLayersargument is also discarded in the compile-time predicate, leaving shader compilation on the native path (DrawCapture.cpp:80-82). Implement the layer-count condition consistently for compilation and draw-time selection; otherwise layered draws beyond the device limit can fail instead of using the advertised fallback.Non-blocking
None.
Not verified
No build or tests were run. The author reports testing on a separate branch with five additional commits; those checks do not establish results for this exact head. KosmicKrisp, Linux, Windows, and console behavior were not verified. The earlier performance measurement was from a previous head, and the description says current-head trace summaries are missing.
files.jsonreports two changed source files excluded from the folder for size; their relevant ranges were read throughrepo_read.py. Other excluded and unchanged files were not read.To get this to a good state
Implement and test the mesh output layer-limit decision for both shader compilation and draw-time path selection, including a layered draw beyond the device limit.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T07:12:56Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: remove the conflict marker from
.gitignoreand correct the malformed README diff artifact.What I ran
Reviewed head
3964c5914c7117eddad2e3f80ad7ef845b843e97usingrepo_read.pyreview-folder and pinned-head readers. No build or tests were run.Results
Findings
Blocking
.gitignore:126adds the literal merge-conflict marker>>>>>>> origin/main. This is an accidental repository artifact and should be removed.Non-blocking
docs/README.md(+ - [DB_RENDER_CONTROL ...), while the surrounding change adds debt entries. Verify and fix the source formatting if this line is present at the head.Not verified
The code changes appear broadly consistent with the described compute fallback and shared-pass flow, but no build or tests were run here. Three changed files were excluded from full-text review by the review-folder size rule:
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp,core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, anddocs/dev/debt/shader.md. RelevantVulkanDevice.cppsections were read through the pinned-head reader; the full excluded files and uninspected hunks were not verified. The author reports test runs and a performance measurement from an earlier head; these were not independently run or verified.To get this to a good state
Remove the conflict marker from
.gitignoreand correct the malformed documentation line if confirmed in the source, then rerun the reported checks on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T13:43:20Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: ensure every resolved indirect record is rendered by the mesh-compute fallback, including synchronous draws.
What I ran
Reviewed head
f47177d66b5501effeee77bb4a4bc55848180e66and the prepared diff. No build or tests were run;repo_read.pywas not run because no shell command interface was available.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:4469routes only GPU-resident indirect arguments toMeshCompute. When arguments are CPU-resolved, the synchronous fallback path usesrecordMeshArguments, which resolves onlyindirect.records.front(), thenrecordMeshComputedispatches once andrecordDrawCommandsImplissues one indirect draw. Additional nonempty records are silently dropped. The recorded path has a one-record guard atDraw.cpp:2688, but the synchronous path has no equivalent guard. Preserve all resolved records through dispatch and draw, or reject multi-record inputs before rendering.Non-blocking
Sources
Not verified
Draw.cpp,Pipeline.cpp,Recorder.cpp,VulkanDevice.cpp, andDraw.hpp. Changed files not fully read:VulkanDevice.cpp,Graphics.cpp,ShaderMemory.cpp, anddocs/dev/debt/shader.md(excluded from the prepared full-text bundle). Other changed-line ranges were not all inspected in full.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:41:00Z.
Review: COMMENTED
I verified that the exact current #17611 head is an ancestor of this revision and that this branch trial-merges cleanly onto
c1601e56d5. Keep the test that forces an attachment hazard between compute-backed mesh draws alongside the one that shares a render pass. It checks that an optimization for independent draws still closes the pass when a dependency requires it. This stack also inherits #17611’s request-format version collision, so the recorded traces and replay tests should identify the merged serializer revision. Paired lavapipe execution is pending.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.