feat(agc): decode GS_FAST_LAUNCH geometry with one point per subgroup #4702

Merged
tv7 merged 2 commits from upstream-pr/4702 into main 2026-10-14 02:31:34 +00:00
tv7 commented 2026-10-12 19:14:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-12T19:14:52Z.


What

First step for #3880, as discussed there: decode VGT_SHADER_STAGES_EN.GS_FAST_LAUNCH = 1 for the case games use, and keep throwing for everything else.

Marvel's Wolverine (PPSA03671) links geometry programs with VGT_SHADER_STAGES_EN=0x482030 (GS_EN, ES_EN=2, PRIMGEN_EN, GS_W32_EN, GS_FAST_LAUNCH=1). The rest of its state, captured at sceAgcLinkShaders time: primitive type 1 (point list), GE_CNTL=0x201 (one vertex and one primitive per group), GE_NGG_SUBGRP_CNTL=0x40 (PRIM_AMP_FACTOR 64), GE_MAX_OUTPUT_PER_SUBGROUP=0x20, VGT_GS_MAX_VERT_OUT=0x20, GE_USER_VGPR_EN=0, SPI_SHADER_PGM_RSRC1_GS=0x022c0245, RSRC2_GS=0x9002a. Its draws are DRAW_INDIRECT (0x24) with no base vertex or start instance location.

This matches how RADV drives mesh shaders on gfx10.3 (mesh_fast_launch_2 off): a point-list draw of x * y * z vertices, one subgroup per point, and the shader takes its workgroup index from the vertex id of its first thread (ac_nir_lower_ngg.c, "the HW doesn't support a proper workgroup index for vertex processing stages, so we use the vertex ID"). Wolverine's program does the same: thread 0 reads v5, looks up its work in a buffer and shares it through LDS. The subgroup size follows ac_compute_ngg_workgroup_size: the larger of the vertex limit and PRIM_AMP_FACTOR primitives.

The mesh prologue already gives v5 the point's vertex id when a subgroup holds one point, so the change is in the decode:

  • DecodeShaderStages accepts GS_FAST_LAUNCH = 1 only with a point list and GE_CNTL groups of one vertex and one primitive. It takes the primitive limit from GE_NGG_SUBGRP_CNTL.PRIM_AMP_FACTOR instead of VGT_GS_MAX_VERT_OUT - 2, and does not require full GS and ES VGPR counts (the program gets a superset of its inputs).
  • Still throwing: GS_FAST_LAUNCH = 2, other group sizes or input primitives, a zero amplification factor, and indexed fast-launch draws (prepareDrawInputs). Non-indexed indirect draws on the mesh path are already resolved by the driver into direct draws.
  • Registered shader type 8 is not touched; I have not tied it to these programs.

Tested

Windows 11, RTX 3070, GCC 15.2.0 UCRT, Release, on main d53960612.

  • agc_driver_graphics: Wolverine's register values decode to one point per subgroup, 32 vertices, 64 primitives, 64 threads, wave32, 128 LDS dwords. Fast launch 2, a group of two, a triangle list and a zero amplification factor throw. Fails on main with VGT_SHADER_STAGES_EN=0x482030: unsupported geometry routing, fast launch or wave-ID state.
  • agc_driver_mesh (GPU): a hand-encoded wave32 fast-launch program reads its workgroup index from v5 with v_readfirstlane, loads one triangle per subgroup and exports it. A direct draw of 40 points draws all 40 triangles; a draw of 20 points starting at vertex 10 draws exactly triangles 10 to 29; an indexed fast-launch draw is refused.
  • ctest 995/995. tools/check_conventions.py passes.
  • Wolverine, on main a11c8f7f7 plus #757, #3588, #3633, #3846, #3867 and #3831 (current main does not reach this point without #757): without this change it stops at link time with the error above. With it, the four fast-launch draws decode and the title continues until a separate wave64 vertex program fails with conditional block 5 has no structured merge, before those draws reach the GPU. So the fast-launch draws themselves are covered by the GPU test, not yet by the title.
  • Merges cleanly with #4341, the other open PR in DecodeShaderStages.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, Claude Code

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4833929152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4702). Originally posted by [tv7](https://github.com/tv7) on 2026-10-12T19:14:52Z. --- ### What First step for #3880, as discussed there: decode `VGT_SHADER_STAGES_EN.GS_FAST_LAUNCH = 1` for the case games use, and keep throwing for everything else. Marvel's Wolverine (PPSA03671) links geometry programs with `VGT_SHADER_STAGES_EN=0x482030` (GS_EN, ES_EN=2, PRIMGEN_EN, GS_W32_EN, GS_FAST_LAUNCH=1). The rest of its state, captured at `sceAgcLinkShaders` time: primitive type 1 (point list), `GE_CNTL=0x201` (one vertex and one primitive per group), `GE_NGG_SUBGRP_CNTL=0x40` (PRIM_AMP_FACTOR 64), `GE_MAX_OUTPUT_PER_SUBGROUP=0x20`, `VGT_GS_MAX_VERT_OUT=0x20`, `GE_USER_VGPR_EN=0`, `SPI_SHADER_PGM_RSRC1_GS=0x022c0245`, `RSRC2_GS=0x9002a`. Its draws are `DRAW_INDIRECT` (0x24) with no base vertex or start instance location. This matches how RADV drives mesh shaders on gfx10.3 (`mesh_fast_launch_2` off): a point-list draw of `x * y * z` vertices, one subgroup per point, and the shader takes its workgroup index from the vertex id of its first thread (`ac_nir_lower_ngg.c`, "the HW doesn't support a proper workgroup index for vertex processing stages, so we use the vertex ID"). Wolverine's program does the same: thread 0 reads `v5`, looks up its work in a buffer and shares it through LDS. The subgroup size follows `ac_compute_ngg_workgroup_size`: the larger of the vertex limit and `PRIM_AMP_FACTOR` primitives. The mesh prologue already gives `v5` the point's vertex id when a subgroup holds one point, so the change is in the decode: - `DecodeShaderStages` accepts GS_FAST_LAUNCH = 1 only with a point list and `GE_CNTL` groups of one vertex and one primitive. It takes the primitive limit from `GE_NGG_SUBGRP_CNTL.PRIM_AMP_FACTOR` instead of `VGT_GS_MAX_VERT_OUT - 2`, and does not require full GS and ES VGPR counts (the program gets a superset of its inputs). - Still throwing: GS_FAST_LAUNCH = 2, other group sizes or input primitives, a zero amplification factor, and indexed fast-launch draws (`prepareDrawInputs`). Non-indexed indirect draws on the mesh path are already resolved by the driver into direct draws. - Registered shader type 8 is not touched; I have not tied it to these programs. ### Tested Windows 11, RTX 3070, GCC 15.2.0 UCRT, Release, on main `d53960612`. - `agc_driver_graphics`: Wolverine's register values decode to one point per subgroup, 32 vertices, 64 primitives, 64 threads, wave32, 128 LDS dwords. Fast launch 2, a group of two, a triangle list and a zero amplification factor throw. Fails on main with `VGT_SHADER_STAGES_EN=0x482030: unsupported geometry routing, fast launch or wave-ID state`. - `agc_driver_mesh` (GPU): a hand-encoded wave32 fast-launch program reads its workgroup index from `v5` with `v_readfirstlane`, loads one triangle per subgroup and exports it. A direct draw of 40 points draws all 40 triangles; a draw of 20 points starting at vertex 10 draws exactly triangles 10 to 29; an indexed fast-launch draw is refused. - ctest 995/995. `tools/check_conventions.py` passes. - Wolverine, on main `a11c8f7f7` plus #757, #3588, #3633, #3846, #3867 and #3831 (current main does not reach this point without #757): without this change it stops at link time with the error above. With it, the four fast-launch draws decode and the title continues until a separate wave64 vertex program fails with `conditional block 5 has no structured merge`, before those draws reach the GPU. So the fast-launch draws themselves are covered by the GPU test, not yet by the title. - Merges cleanly with #4341, the other open PR in `DecodeShaderStages`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes, Claude Code 🤖 Generated with [Claude Code](https://claude.com/claude-code)
xXPBSXx commented 2026-10-12 23:24:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T23:24:44Z.


Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built in a batch with five other open GPU PRs cherry-picked onto main 44ab0c39e (not current main, which needs a submodule that isn't checked out here), so only the tests that belong to this PR say anything about it:

  • tests/Mesh.cpp (agc_driver_mesh): 3 of 3 runs passed.
  • tests/Graphics.cpp (agc_driver_graphics, this PR's change is in that file too): see below.

agc_driver_graphics over the batch: 9 of 10 runs passed. The one failure is the known address-layout flake from #4660 as far as I can tell: I kept only the first lines of that run's log (the host import ... vkAllocateMemory (-2) lines, which appear in passing runs as well), not its final error message, so I can't confirm the cause for that one run. Plain main failed 2 of 10 on the same machine earlier.

Not tested: no game run; the batch was not rebuilt per PR, so a failure would have needed a bisect (there was none besides the flake).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134542859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4702#issuecomment-6134542859). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T23:24:44Z. --- Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built in a batch with five other open GPU PRs cherry-picked onto main `44ab0c39e` (not current main, which needs a submodule that isn't checked out here), so only the tests that belong to this PR say anything about it: - `tests/Mesh.cpp` (`agc_driver_mesh`): 3 of 3 runs passed. - `tests/Graphics.cpp` (`agc_driver_graphics`, this PR's change is in that file too): see below. `agc_driver_graphics` over the batch: 9 of 10 runs passed. The one failure is the known address-layout flake from #4660 as far as I can tell: I kept only the first lines of that run's log (the `host import ... vkAllocateMemory (-2)` lines, which appear in passing runs as well), not its final error message, so I can't confirm the cause for that one run. Plain `main` failed 2 of 10 on the same machine earlier. Not tested: no game run; the batch was not rebuilt per PR, so a failure would have needed a bisect (there was none besides the flake). AI-assisted (Claude Code).
oneandonlydean commented 2026-10-13 02:43:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:43:12Z.


Please add a docs/dev/debt/libSceAgcDriver.md entry for the fast-launch decode: one point per subgroup with the primitive limit from GE_NGG_SUBGRP_CNTL.PRIM_AMP_FACTOR follows RADV's gfx10.3 mesh path, it isn't measured on the console, and PPSA03671's fast-launch draws don't reach the GPU yet.

Both runs so far are on Windows; a Linux run of agc_driver_mesh and agc_driver_graphics on this head would cover the rest.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6137040780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4702#issuecomment-6137040780). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T02:43:12Z. --- Please add a `docs/dev/debt/libSceAgcDriver.md` entry for the fast-launch decode: one point per subgroup with the primitive limit from `GE_NGG_SUBGRP_CNTL.PRIM_AMP_FACTOR` follows RADV's gfx10.3 mesh path, it isn't measured on the console, and PPSA03671's fast-launch draws don't reach the GPU yet. Both runs so far are on Windows; a Linux run of `agc_driver_mesh` and `agc_driver_graphics` on this head would cover the rest.
adriadam10 commented 2026-10-13 15:05:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:05:39Z.


Rebased onto current main and added one commit: the docs/dev/debt/libSceAgcDriver.md entry @oneandonlydean asked for (follows RADV's gfx10.3 mesh path, not measured on the console, PPSA03671's fast-launch draws don't reach the GPU yet).

Checked on Linux (rebased tree, libSceAgcDriver scope, 538 tests): agc_driver_graphics and agc_driver_mesh pass, and both fail with the Draw.cpp/State.cpp changes reverted. The only failing test, agc_driver_tessellation (SEGFAULT), fails the same on main. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148618203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4702#issuecomment-6148618203). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:05:39Z. --- Rebased onto current main and added one commit: the `docs/dev/debt/libSceAgcDriver.md` entry @oneandonlydean asked for (follows RADV's gfx10.3 mesh path, not measured on the console, PPSA03671's fast-launch draws don't reach the GPU yet). Checked on Linux (rebased tree, libSceAgcDriver scope, 538 tests): `agc_driver_graphics` and `agc_driver_mesh` pass, and both fail with the Draw.cpp/State.cpp changes reverted. The only failing test, `agc_driver_tessellation` (SEGFAULT), fails the same on main. Merging once the full Build is green.
fdfawef324 commented 2026-10-13 19:04:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T19:04:53Z.


Tested #4702 with Resident Evil 4 (PPSA07411) on Windows Server 2025 build 26100, GCC 15.2.0 UCRT, and NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325.

Both PR commits, 7370aaf6d and 1a2a4265c, cherry-pick cleanly onto main 61b8742b6 and the local integration tree 716c9045c. agc_driver_graphics and agc_driver_mesh pass on main plus this PR (10.6 s and 2.6 s).

RE4 prepares three wave64 fast-launch geometry programs. Their common state is VGT_SHADER_STAGES_EN=0x82030, point-list input, and GE_CNTL=0x201. The subgroup amplification factors are 64, 128, and 128. This matches the PR's supported one-point-per-subgroup case.

On the same integration base and input schedule:

  • Without #4702, preparation stops at 552 s with VGT_SHADER_STAGES_EN=0x82030: unsupported geometry routing, fast launch or wave-ID state.
  • With #4702, all three fast-launch program ABIs resolve without error. Preparation then stops at 494 s on the separate tessellation check: VGT_SHADER_STAGES_EN=0x200210d: only triangle and quad domains with fractional-odd partitioning and triangle output are supported by the reference path.

The title's fast-launch draws have not reached the GPU before that next stop. All 17 captured frames are entirely black, matching the earlier integration run, so this establishes preparation progress only.

A temporary wave64 variant of the PR's GPU test rendered 40/40 triangles and exactly triangles 10–29 when given a nonzero start vertex. Its negative control failed as expected. That check exercised the wave64 path with an explicit mesh configuration; it did not test the state decoder. The temporary test was reverted and is not included in a new PR.

AI-assisted: yes.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153041085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4702#issuecomment-6153041085). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-13T19:04:53Z. --- Tested #4702 with Resident Evil 4 (PPSA07411) on Windows Server 2025 build 26100, GCC 15.2.0 UCRT, and NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325. Both PR commits, 7370aaf6d and 1a2a4265c, cherry-pick cleanly onto main 61b8742b6 and the local integration tree 716c9045c. `agc_driver_graphics` and `agc_driver_mesh` pass on main plus this PR (10.6 s and 2.6 s). RE4 prepares three wave64 fast-launch geometry programs. Their common state is `VGT_SHADER_STAGES_EN=0x82030`, point-list input, and `GE_CNTL=0x201`. The subgroup amplification factors are 64, 128, and 128. This matches the PR's supported one-point-per-subgroup case. On the same integration base and input schedule: - Without #4702, preparation stops at 552 s with `VGT_SHADER_STAGES_EN=0x82030: unsupported geometry routing, fast launch or wave-ID state`. - With #4702, all three fast-launch program ABIs resolve without error. Preparation then stops at 494 s on the separate tessellation check: `VGT_SHADER_STAGES_EN=0x200210d: only triangle and quad domains with fractional-odd partitioning and triangle output are supported by the reference path`. The title's fast-launch draws have not reached the GPU before that next stop. All 17 captured frames are entirely black, matching the earlier integration run, so this establishes preparation progress only. A temporary wave64 variant of the PR's GPU test rendered 40/40 triangles and exactly triangles 10–29 when given a nonzero start vertex. Its negative control failed as expected. That check exercised the wave64 path with an explicit mesh configuration; it did not test the state decoder. The temporary test was reverted and is not included in a new PR. AI-assisted: yes. 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.
github-actions[bot] commented 2026-10-13 22:26:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T22:26:12Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#5521 docs/dev/debt/libSceAgcDriver.md L7-8
#5604 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L651
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156535830 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4702#issuecomment-6156535830). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T22:26:12Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5521 | `docs/dev/debt/libSceAgcDriver.md` [L7-8](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/libSceAgcDriver.md#L7-L8) | | | | #5604 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L651](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L651) | | |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4702
No description provided.