fix(agc): route registered NGG workgroups through mesh #2261
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2261"
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 Sanjaysrinivas on 2026-10-09T13:36:38Z.
What
Registered type-2 NGG vertex programs using LDS or
s_barrierneed the existing mesh path's workgroup storage and wave64 cross-lane operations. Preparing them as ordinary vertex shaders can reject a lane-63 read on a 32-lane host subgroup.Defer their registration preparation until routing and primitive state are available, and share the workgroup decision between static ABI resolution and draw decoding. Reserved address bits and misaligned entries still throw. Workgroup use follows Mesa's NGG lowering; console routing remains unmeasured and is recorded in TechnicalDebt.
The branch contains one commit over main
a11c8f7f70a0ed4e71504a89de69e8cdae687817, changing seven files. #1732/#1825 are already merged; their seven prerequisite commits are absent from this diff. Current main and existing PRs were checked for an equivalent registered-program extension. Related #3546 changes vertex-wave lowering; it does not implement this registration deferral or registered mesh routing. Depends on: none.Two registration-only CTests call the actual registration export in asynchronous and synchronous modes, with no mesh-shading or subgroup-size gate. The same valid LDS/lane-63 fixture registers on lavapipe's eight-lane subgroup. A missing-user-data variant also registers with NGG routing; changing only the routing to non-NGG requires the normal eager vertex-ABI validation to throw. This control checks that deferral is limited to NGG on any subgroup width. On a synchronous host narrower than 64 lanes, the valid non-NGG header additionally must reach preparation and produce the lane-63 error. These checks need Vulkan initialization, available through lavapipe, but no mesh compilation or hardware GPU.
The separate wave64 mesh preparation fixture requires mesh shading and a supported 32- or 64-lane host subgroup. It reports when that subcase cannot run and executes before the failure-capture check. CPU routing checks remain unconditional and use main's registry with multiple shader headers per address.
Tested
ShaderRegistry.cpp. Both new registration tests failed on lavapipe: asynchronous mode reached the missing-user-data validation, and synchronous mode hit the eight-lane/lane-63 error. Restored the production source byte for byte, rebuilt, and obtained the 12/12 result above. This directly guards the behavior requested in review.agc_driver_prepared_shaders,_indirect,_uncached,_debug) report "shader failure capture was incomplete". The previous same-environment baseline rebuild of main's registry/draw sources and original fixture reproduces all four failures. The Windows expected-failure scenario also stops at that capture error before its intended injection, so its CTest pass is not injection coverage; Linux covers the intended injection.tools/check_conventions.py --base origin/mainandgit diff --check origin/main...HEADpass. The original subgroup-gate mutation also reproduced the eight-lane/lane-63 error. macOS was not tested locally.Automatic CI on the preceding head passed; full hosted Linux/Windows library jobs require a collaborator's manual Build dispatch. A new push restarts automatic checks and requires a new dispatch for full hosted builds.
These fixtures contain synthetic code. The private game source, installed runtime and title assets were preserved; no gameplay or FPS claim is made.
Checklist
main; no other open PR implements the same registered-program extensionImported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:05:24Z.
Additional platform validation on standalone PR head
029b2e41508bf5c23bd9a9497a0fcb243ea59e62:Linux: failed tests — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja.
Release /
BUILD_TESTING=ON: built the selected test targets; 7 CTest cases, 4 failures, 0 CTest skips.Tests:
agc_driver,agc_driver_graphics,agc_driver_prepared_shaders,agc_driver_prepared_shaders_indirect,agc_driver_prepared_shaders_uncached,agc_driver_prepared_shaders_debug,agc_driver_prepared_shaders_debug_failure.Reproduce after building the test targets:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver($|_graphics$|_prepared_shaders)".Vulkan: Mesa lavapipe 26.2.4 software Vulkan; no native Linux GPU/retail-title validation.
Internal limitation: write-watched guest-heap mirror subcases returned early because WSL userfaultfd async write protection is unavailable. The other graphics assertions ran; zero CTest skips does not include this internal early return.
Failed cases:
agc_driver_prepared_shaders,agc_driver_prepared_shaders_indirect,agc_driver_prepared_shaders_uncached,agc_driver_prepared_shaders_debug.The new
RegisteredVertexWorkgroupcase fails while preparing its wave64 shader:v_readlane_b32 of lane 63 is outside the 8-lane host subgroup. Lavapipe advertises mesh shaders but has subgroup size 8, and this test currently checks mesh support only. The driver, graphics and injected-failure cases passed; this is not a clean Linux pass.Integration limitation: a local merge against main
948a526c2has source conflicts; these results validate the standalone PR head, not a resolved merge.Imported from boykopovar/AnyPS5. Originally posted by Sanjaysrinivas on 2026-10-10T11:55:37Z.
Pushed
5c43862b7, fixing a compile error I introduced while resolving this branch's conflicts against current main (5314908d1did not build).Cause.
ProgramUsesWorkgroupandVertexWorkgroupRequiredare declared inDriver/Shaders/ShaderRegistry.hppand called from other translation units (Submit.cppuses both;DrawDecode.cppand the draw decode path callVertexWorkgroupRequired). The branch defined them inside an anonymous namespace, so the unqualified calls inShaderRegistry.cppsaw two candidates — the header declaration atAgcDriver::DriverDetailscope and the definition atAgcDriver::DriverDetail::{anonymous}scope. The fix keeps both atAgcDriver::DriverDetailscope, matching their declarations: 4 lines deleted, no behaviour change.Build and test evidence on this head (Ubuntu 24.04, g++ 13.3.0, Release,
-DBUILD_TESTING=ON):agc_driver_testspasses on llvmpipe (llvmpipe (LLVM 20.1.2, 256 bits), subgroup=8), which covers theSubmit.cppchecks forProgramUsesWorkgroup(s_barrier and LDS detection, entry-point offset) andVertexWorkgroupRequired(registered NGG vertex program needing a workgroup, non-NGG routing, dword-alignment and reserved-bit rejects). So the new NGG routing behaviour is exercised, not just compiled.agc_driver_prepared_shaders_testsfails before it reachesRegisteredVertexWorkgroup, on an earlierDeferredRegistrationcase:That is a wave64 program on a software device whose subgroup is 8. It is not related to this change, and no device here provides 64 lanes — llvmpipe reports subgroup=8 with
GALLIUM_OVERRIDE_CPU_CAPSunset,avx(as CI sets) andavx2alike. Worth knowing that the newRegisteredVertexWorkgroupcase therefore has no execution coverage under lavapipe; it needs a real wave64 device.On CI. This branch showed every check green while being unbuildable, because
linux/windows— the only jobs that runcmake --build build --target libs— are gated ongithub.event_name == 'push'. On a pull request onlyrelinker,register-contextandwrite-watchcompile, and none of them buildlibSceAgcDriver. Flagging in case that gate is wider than intended; it is pre-existing on main, not something this PR introduces.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:53:27Z.
Review: CHANGES_REQUESTED
Thanks. Two things before this can land:
mainunder different SHAs, and it conflicts withmain. Please rebase so only the registered-NGG commits remain, and rerun the focused tests on the result.tests/execution/PreparedShaders.cpp:500(RegisteredVertexWorkgroup) only checks forMeshShadingEXT. On Mesa lavapipe (subgroup size 8) the wave64 shader fails to prepare withv_readlane_b32 of lane 63 is outside the 8-lane host subgroup, which failsagc_driver_prepared_shaders,_indirect,_uncachedand_debugon Linux (reported by @Mouhand-Kaddo). Gate the case on the host subgroup size the mesh path actually supports (and keep a CPU-side check for what is independent of the device), or make it pass on an 8-lane subgroup.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T13:00:49Z.
Review: CHANGES_REQUESTED
Thanks for the rebase and the subgroup gate; the branch is now a single commit over main.
ShaderRegistry.cpp:625is the actual behaviour change (a registered type-2 NGG vertex program using LDS/s_barrieris no longer prepared at registration), but nothing that runs on Linux CI pins it. I deleted that line locally andagc_driver,agc_driver_prepared_shaders*(all 8) still pass.RegisteredVertexWorkgroup(PreparedShaders.cpp:528) only runs with mesh shading and a 32/64-lane subgroup, and prints "not run" on lavapipe (subgroup 8).RegisteredVertexWorkgroupand assert the preparation is left pending (asDeferredRegistrationdoes) instead of prepared, and that it is prepared as before with a non-NGG routing value. It should fail with the line removed.VertexWorkgroupRequiredand its tests (Submit.cpp:632) look fine: they fail to build without the change and pin the reserved-bit/alignment cases.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:23:51Z.
Review: APPROVED
Checked on the merged tree: libSceAgcDriver build and the
agc_driverandagc_driver_prepared_shaders*tests pass, including both newregistered_workgrouptests. With only theShaderRegistry.cppregistration-deferral line removed, both new tests fail, so they pin the behaviour. TechnicalDebt entry is in place. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T21:58:43Z.
Post-merge validation on pinned main
a672688e94f3ba3503c58fc70871f37c4f198a28, in a local diagnostic integration: Windows 11, RTX 5080 / host subgroup 32, MinGW GCC 15.2 UCRT, Release /BUILD_TESTING=ON, Vulkan required, shader cache off.Confirmed fixture problem. The unchanged
agc_driver_prepared_shaders_registered_workgroup_syncfails in the full suite and 5/5 isolated runs because its final expected lane-63 rejection does not happen. An external diagnostic copy names that exact expectation; an independently reconstructed vertex request with the fixture's metadata prepares successfully (311 SPIR-V words). Its compiler IR contains:The fixture reads lane 63 of constant zero. Current emitter now accepts a value proven zero in upper lanes, so this fixture no longer exercises the intended rejection.
Suggested test correction, validated locally in
0e79f49d9(not pushed): increase its code array from eight to nine words and insert0x7e000281u(v_mov_b32 v0, 1) immediately beforev_readlane_b32:This preserves the LDS/workgroup marker and positive mesh-preparation path while keeping the unimplemented ordinary vertex lane read observable. Both registered-workgroup modes pass five times in each of a parallel and sequential group run. Build,
libs, registration and convention checks pass; all 122 patched + 122 unpatched module hashes remain unchanged. This changes only the test, not shader semantics.Reproduce with
ctest --test-dir build-review -R "^agc_driver_prepared_shaders_registered_workgroup(_sync)?$" --repeat until-fail:5 --parallel 1 --timeout 30 -V. CTest suppliesAPS5_SYNC_SHADER_PREPARE=1for the synchronous case.Scope: this is not a build of the unchanged standalone #2261 head. The broader suite has separate intermittent
0xC0000374heap-corruption failures: initially deferred preparation, subsequently debug preparation in a parallel run and undecodable preparation in a sequential run. These initially prevented a clean full-validation claim. The three production changes from existing #4029 are now applied locally: independent validation records100/100 selected heap-case runs and a full suite of863pass/0fail/5skip. Those crashes are not attributed to this PR, and finite clean campaigns do not prove every rare crash absent. No push or new PR.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T23:58:43Z.
Confirmed on a real title: High on Life (PPSA15388 v01.120.000, Unreal Engine 4). Its NGG culling vertex programs are registered: LDS compaction plus
v_readlane_b32of lanes 31 and 63, and nos_barrier. Without this PR they ran on the vertex path, where their LDS becomes a per-invocation Function array, so each lane reads slots only other lanes wrote. The GPU stopped making progress right after the first level loaded:Xid 109 CTX SWITCH TIMEOUT, thenVK_ERROR_DEVICE_LOST, in every run (10+).With #1732, #1825 and this PR cherry-picked, the hang is gone. With #3738 as well, the title gets into the level: its audio, an opening cutscene, and in-engine rendering.
One note for anyone running the suite: on
main,agc_driver_prepared_shaders_registered_workgroup_syncfails on 32-lane hosts, because #3546 made the lane-63 read its non-NGG control relied on build. #4142 swaps the control for a program no vertex stage can build.How the hang was located
A local diagnostic put a
VK_NV_device_diagnostic_checkpointsmarker before every draw, dispatch and internal command, and read the markers back after device loss. In every run, the last completed and first unfinished markers were draws using one of two culling-program variants: for example, 1710-, 10404- and 88206-index depth-only draws into a 256x256 shadow map. Skipping every draw of one variant by its code moved the hang to the other variant's draws. The pixel shaders involved are a 25-dword alpha test with no loops.Setup: CachyOS (Linux 7.2), RTX 4090 (NVIDIA 615.78, 32-lane subgroups), GCC, Release. The base is
mainf5c0fe00plus local integration patches and ports of #423/#1077, #425, #454, #2904, #3202, #3546 and #3279. The 10 commits of #1732/#1825/#2261 needed two small conflict resolutions (one TechnicalDebt line, and the deferral line next to an olderreturn nullptrinShaderRegistry.cpp).Tested and written by Claude (AI assistant) on a contributor's machine.