feat(agc): emulate mesh pipeline draws with a compute pass when VK_EXT_mesh_shader is unavailable #17611
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17611"
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 SuarezPM on 2026-11-09T02:30:14Z.
What
Emulates mesh-path draws through a compute pass on devices without
VK_EXT_mesh_shader(or withAPS5_FORCE_MESH_COMPUTE=1). Supported subset only (see Known limitations). Supersedes #9356: commitsc0faaafc0f,fe9ac9351candecf0a2b4f7by @billythemenace2 are cherry-picked with authorship preserved, reconciled onto current main (recompile-request serialization 64, disk-cache format 97) with fallback hardening and tests; commit479fb1cb41and the merge are mine.Activation matrix (capability x flag):
maxMeshOutputLayers): native layer-window path, not compute (draw-time decision matches the compile-time one)Tested
Linux x86_64, NVIDIA GeForce RTX 2060 SUPER (driver 615.78.08). Unit/execution coverage local (below) plus real-hardware runs by contributors (see Real hardware):
de5c510e8b(thanks @Jazeupoi): vkQuake renders 1166 frames ~44 fps with correct drawing where main stops at startup; 15 catalog homebrew titles 15 s each: 8 run with correct UI (SpeedBreaker 57 FPS, PSXS5 37, SwanStationPS5 60, DevilutionX 60, PSFlyCast 40, OGBox 39, Mario 64 52, FBNeo 60), 4 pass mesh draws then stop at 8-sample target vs 1/2/4 offered (not from this PR), 2 stop at barycentric #9387, PS5SX2 stops at viewport depth [-1,1] without depth_range_unrestrictedAPS5_NO_PRESENT_QUEUE=1, also orthogonalmainb8b8f49250and on the same tree with this head merged, both 0 failed and 0 VUIDs with the layer inserted in every Vulkan test.agc_driver_meshskips on main and passes here;agc_driver_layered_volume_drawtakes thetarget.meshAsComputebranch and its "mesh draw run as compute" check passes. First RDNA1 (gfx1010) data point, one generation from the console's gfx1013APS5_FORCE_MESH_COMPUTE=1; a temporary probe counted 40 compute dispatches in the forced run (37 inagc_driver_mesh, 13 of them indirect) and removing the two dispatches fails exactly the three tests that depend on them. First run where both routes execute on one cardVK_EXT_mesh_shader(thanks @GiannisG1): 47 catalog titles that stop at the mesh-stage recompile onmain, 90 s each headless Xvfb, head59203ed861merged ontomaine09d1349b5with-DANYPS5_ENABLE_SPIRV_TOOLS=ON-- 20 keep running the full session vs 0 onmain(Crux2, DK64 Rekompiled, DevilutionX x2, James Pond 2, Links Awakening, Mario 64, OGBox, PSFlyCast, Rush 2, Second Coat London, Shining Force III, Ship of Harkinian, SpeedBreaker, SwanStationPS5, TrinityX360, VLC, Wave Race 64, Wind Waker HD, osu!); 25 stop at the mesh-path pixel shader (stage 5) with SPV_EXT_mesh_shader extension requires SPIR-V 1.4 or later (log-confirmed: Lantern Miner shader 0x200790c00 stage 5; pixel module still declares the mesh extension on the compute path -- emitter follow-up, not this PR); Conker (guest memory unreadable at 0x4009000000 after passing the mesh draws, honest throw, separate triage still open) and ProsperoAI (debug-label run 7199688305: no host device loss, title-side 10 s fence timeout + abort; cold cache ~5.5 s preparing draw-8 pair 0x201d80900/0x201d80f00, warm cache reaches the same stage-5 emitter ceiling at 0x201d86400 as the 25; dispatch 1x1x1 rules out huge dispatch; Dean flag withdrawn, emitter follow-up covers it)main(bc4cddf422, #25434 included) and fixed the prebuild collision it introduced:Pipeline::Prebuildreturns false whenMeshDrawRunsAsComputeis set, so the compiled mesh program is never handed to a graphics pipeline library on a device withoutVK_EXT_mesh_shader, and the constructor now requires that no stage is still Mesh whenmeshComputeis set. Re-verified with the validation layer: 23 focused tests pass in default,APS5_FORCE_MESH_COMPUTE=1andAPS5_NO_MESH_SHADER=1, 0VUID-lines, layer inserted in every runKnown limitations (follow-ups, not in this PR): compute readbacks have no eviction yet; multi-record CPU indirect mesh draws run as compute throw instead of dispatching per record (see debt entry); a mesh shader writing a viewport index other than the fallback path has no dedicated throw (no cheap signal; documented for review); no execution-level test pins the per-draw meshAsCompute override; no defensive meshAsCompute => !meshWindowBuffer assert in Recompiler/SpirvEmitter (only the two driver constructors set the flags).
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)de5c510e8b; NVIDIA GTX 1060 3GB (Pascal) on Windows 11, ccleste with the combined #9387 carry; AMD RX 5700 XT (RDNA1) on Windows 11, 41-test A/B against main; AMD R9700 (RDNA4) on Windows, both routes on one card with a negative control; NVIDIA GTX 1050 Ti title run 20/47 full-session (pixel-stage ceiling is follow-up)Overlap note: tools/pr_overlap.py fails closed listing open PRs with adjacent files (the tool timed out on a full scan here, so this note is manual). #16413 landed and is integrated in this branch (its async MaterializeInBackground path now hosts the re-derived per-draw override; no action left). #15548 stacks on top of this PR and needs a rebase after landing (size asserts already account for the mesh key field). Manually compared hunk-by-hunk against current main: #15917 touches adjacent lines in the same functions (buildTarget, emitVariant, SpirvTarget, cache-key append, Emit mesh-window area; different lines, should auto-merge); #16115, #16260, #16088, #16474, #16887 share files but all hunks are 25+ lines away; docs-only adjacency in ENVIRONMENT.md/debt files is append-style. #9356 overlap is by design (superseded).
Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-16T23:12:51Z.
Review: COMMENTED
Tested on an Apple M4 (macOS 27.2, MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363.1, x86-64 build under Rosetta 2). This MoltenVK has no
VK_EXT_mesh_shader, so it takes the compute route this PR adds.Not tested on current
main. A trial merge ontomainat459f4f8c22conflicts in 15 files:core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Draw.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/ControlFlow/src/RequestSerializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hppcore/shader/recompiler/tests/RequestSerializerTests.cppdocs/dev/ENVIRONMENT.mdSo I built the head (
70015a5ccf) as it is and compared it with its own merge-base (47adcad89a). Same tests, same environment, three runs per side.The merge-base doesn't build on macOS.
libc(RunReport.cpp),libkernel(Stdio.cpp),libSceLibcInternal(BasicString.cpp) andlibSceAgcDriver(VulkanDevice.cpp,::environ) fail to compile, so every AGC test was Not Run on both sides. I applied the same four-file shim to the base and the head; it's below.extern char** environ;declaration is what currentmainhas.Stdio.cpplines do change runtime behaviour: they drop the macOSMNT_NOEXECflag fromsceKernelFstatfs/statfsresults. None of the tests below calls statfs.VulkanDevice.cpp, and the shim applies to it unchanged.Build shim applied to both sides
Method:
ctest --test-dir build -R '^(agc_driver_.*(mesh|barycentric|layered_volume).*|agc_mesh_.*|agc_fragment_barycentric|agc_driver_unobserved_provoking_vertex|agc_shader_memory|request_serializer)$' -V, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer. All 15 test processes that create a Vulkan instance loggedInsert instance layer "VK_LAYER_KHRONOS_validation"(layer 1.4.363) on both sides. None logged the missing-layer message, and there were 0VUID-lines on either side. All three runs were identical.agc_driver_meshagc_driver_mesh_barycentric_emulation,_draw_relocation,_index_cache,_provoking_layer,_provoking_vertex,_vector_window_waves,_vector_window_writesagc_driver_layered_volume_meshagc_driver_layered_volume_draw,_submit,_vertex,_vertex_no_gpl,agc_driver_pixel_barycentric_emulation,agc_driver_unobserved_provoking_vertex,agc_fragment_barycentric,agc_mesh_output_budget,agc_shader_memory,request_serializerSo on an Apple GPU, the compute route passes the
Mesh.cppchecks, and nothing in this set regresses. But the driver-level mesh execution tests (MeshProvokingVertex.cpp,MeshDrawRelocation.cpp,MeshBarycentricEmulation.cpp, ...) still skip as soon as the device lacksVK_EXT_mesh_shader(for exampleTargetHasCapability(..., spv::CapabilityMeshShadingEXT)atMeshProvokingVertex.cpp:204). They never submit a mesh draw through the compute route on MoltenVK. Gating them on "mesh shaders or the compute route" would let them cover the path this PR adds on exactly the devices it targets. As it stands, this run doesn't show that a submitted mesh-path draw renders correctly through compute.Overlap: #15548 shares 705 of this PR's 717 added lines (comparing the added lines of each diff against its own merge-base). Both carry the commits of #9356 (billythemenace2, opened 2026-10-21), which is the oldest of the three; this PR was opened 2026-11-09 and #15548 on 2026-11-03.
I didn't test Linux, Windows or another GPU, or any title.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:26:51Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix compute fallback activation so it honors the layer limit and documented force flag consistently.
What I ran
Reviewed head
70015a5ccffd2c9a10a9acd362ef4ec6e42d1ba2using the prepared diff and pinned reader. No tests were run. Author-reported test results are not independently verified.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:1297: the overload called throughout draw planning discardsmaxMeshOutputLayersand returns compute only when mesh shaders are unavailable. The context overload separately forces compute forAPS5_FORCE_MESH_COMPUTE, but thebool, uint32_t, Stateoverload used byDrawCapture.cppandMeshArgumentRulesFordoes not receive that override. Consequently, mesh capable devices with oversized layer draws will not use the compute fallback even though the description says those draws do; forcing compute also does not affect the capture-side target selection. Use one shared activation decision that accounts for the force flag and the layer requirement, so all call sites agree.Non-blocking
None.
Not verified
No tests or Vulkan validation were run. The author-reported hardware runs and test results were not independently confirmed. Full text was available and read for 33 of 36 changed files;
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded by the review folder size rule and were not read. The diff artifact was read only through line 2050 of 2264; remaining diff content was not reviewed.To get this to a good state
Unify fallback selection and ensure the force and oversized-layer cases are consistently handled across compilation, capture, and draw recording; then rerun the focal tests and Vulkan validation on the new head.
Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-21T02:18:58Z.
Review: COMMENTED
This complements @kurexw's run, which covered tests but no title: here a whole game renders through the compute route on MoltenVK.
Tested with real games on an Apple M4 (macOS 27.0.1, MoltenVK 1.4.2, x86-64 Release under Rosetta 2; this MoltenVK has neither
VK_EXT_mesh_shadernorVK_KHR_fragment_shader_barycentric). I built the head70015a5ccfon its own merge-base (47adcad89a) plus #11049 and #17425 for the macOS build. That base needed five local-only macOS compile fixes, already solved on currentmainand unrelated to this PR: missing<thread>inRunReport.cpp, the Apple branch ofFillStatfs,size_t/uint64_tmismatches inBasicString.cpp,libSceAppContentandlibSceNpCppWebApi, and::environinVulkanDevice.cpp.main(adbc1273c5)So the compute route unblocks one title on macOS. The other two need pixel-shader barycentrics without mesh shaders, which is what #9387 addresses.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-21T16:44:47Z.
Review: COMMENTED
More Mac data for this PR, from 15 catalog homebrew titles that stop on
mainwithAGC graphics: device does not support mesh shaders(PS5SX2 stops earlier, on its viewport depth range).Apple M4, macOS 27.0.1, MoltenVK 1.4.2 (no
VK_EXT_mesh_shader), x86_64 under Rosetta. Headde5c510e8bmerged intomainof 2026-11-21, 15 s per title, no game data.the device cannot render color with the target's sample count: a 3840x2160 8-sample color target, while MoltenVK offers 1, 2 and 4. It's created even with the game's MSAA set to None, so it's not from this PRdocs/dev/debt/libSceAgcDriver.mdlists as still throwing withoutVK_EXT_depth_range_unrestrictedAll eight that run draw their UI correctly in the window captures, with no missing or garbled elements.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T04:49:42Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed diff shows no verified blocking defect, but I did not read every changed file at the pinned head, so a formal approval is not justified.
What I ran
Inspected the prepared diff for head
de5c510e8be89f14befcacdf8d33586097d1cf0aand usedrepo_read.pyto read targeted source ranges inDraw.cppandVulkanDevice.cpp. No tests or builds were run. The description’s test results are author-reported, not independently verified.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
.gitignore:126adds a line that appears to be a leftover merge-conflict marker. Remove it to avoid ignoring a file with that literal name. Pinned diff sourceSources
Not verified
The changed files
VulkanDevice.cpp,tests/Graphics.cpp, andtests/ShaderMemory.cppwere excluded from the prepared full-text folder because they were too large; their diff hunks were inspected, but their full contents were not read. I also did not read every other changed file’s full contents at the pinned head. No build, test run, or hardware behavior was independently confirmed.To get this to a good state
Nothing is required. Optionally remove the stray
.gitignoreline. The remaining review work is to read the changed files not inspected at the pinned head and run the relevant checks before requesting approval.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T05:57:19Z.
Review: COMMENTED
Reviewed — comments
The compute fallback has substantial reported hardware and validation coverage, but I did not inspect every changed file or run checks, so the evidence is insufficient for a formal decision.
What I ran
Read the prepared diff and selected source ranges at head
f858499c771723667055f87c65db98fa96533831usingrepo_read.py. No build or tests were run in this review.Results
Findings
Blocking
None identified in the portions inspected.
Non-blocking
The review is incomplete:
VulkanDevice.cpp,tests/Graphics.cpp, andtests/ShaderMemory.cppwere excluded from the review bundle, and I did not inspect all included changed files. A formal approval is not supported by this evidence.Not verified
Read the description, commits, manifest, diff, and selected ranges of
Draw.cpp. The excluded changed files werecore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp. The remaining changed files and the full behavior of the fallback were not fully reviewed. The reported build, tests, validation-layer results, and hardware runs were not independently confirmed.To get this to a good state
Complete inspection of the remaining changed files and run the relevant checks before a formal review decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:32:53Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: fix the mesh compute fallback’s indirect draw handling so it processes or explicitly rejects every resolved record.
What I ran
Reviewed head
640a4428ac22435bd3d7203523e7c9f2b2537e4c. Read the prepared description, commits, diff, and manifest; used the pinned reader for changed source and test context. No build or tests were run.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:352— The guard permits multiple resolved records whenindirect.path == Gpu, but fallback selection changes that path toMeshComputebefore CPU-resolving records. For that path,recordMeshArgumentscopies onlyindirect.records.front()into one argument buffer, and the fallback issues one dispatch and one indirect draw. Thus a mesh-path indirect draw with multiple resolved records silently drops all but its first record. Extend the fallback to dispatch and draw each record, or reject multi-record fallback requests before recording them.Non-blocking
None.
Not verified
No commands, build, or tests were run. The full changed-file texts for
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded from the review folder; the reader was used for targeted ranges in the first two, andShaderMemory.cppwas not inspected beyond its path. Other included changed files were not all read in full, so this review does not claim a complete audit of every changed line. Author-reported hardware and test results were not independently verified.To get this to a good state
Process each resolved indirect record through the fallback, or fail explicitly when more than one record is present; then run the focused graphics and mesh fallback tests on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T22:07:18Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
59203ed86130d51e13a03cd43f0c23728d208d5e. I read the prepared description, commit list, manifest and diff, then inspected relevant source at the pinned head throughrepo_read.py. I did not run commands or tests.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
The full text of changed files excluded from the review bundle was not read, including
VulkanDevice.cppandShaderMemory.cpp; their relevant diff hunks were inspected where available. Other changed files were not individually audited. No tests were run. Author-reported test and hardware results were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:35:55Z.
Review: COMMENTED
I compiled the exact request serializer. A request using
meshAsComputeround-trips here, but mainc1601e56d5rejects it as truncated. This reader also rejects main’s version 64 split-state capture, and both layouts claim version 64. A further exact version 64 cross-check with typed storage merges in #17056 failed in both directions. Reconcile the request version and legacy decoding when resolving the current conflicts inRequestSerializer.cpp, cache keys, mesh draw, and device integration.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.