fix(agc): select the registered back half for a fused hull header #3444

Merged
Pipodi merged 1 commit from upstream-pr/3444 into main 2026-10-11 11:45:00 +00:00
Pipodi commented 2026-10-11 10:42:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-11T10:42:26Z.


What

For hull halves, sceAgcFuseShaderHalves returns a copy of the back half (type 7, HsBack) and doesn't register it. The copy is marked type 3 (Hs), has user_data cleared, and has its shader registers copied to the caller's scratch memory, where the checksum (0x100), SPI_SHADER_PGM_RSRC1_HS/RSRC2_HS and the LS program address (0x148/0x149) are rewritten. Fused geometry halves are registered as a new program; fused hull halves aren't, because the code stays where it was. Draws already find both halves through 0x148 (type 5) and 0x108 (type 7).

sceAgcCreatePrimState only accepts a hull of type Hs, so a title passes the fused header. ResolveGraphicsStagesAbi then finds no registered header equal to it and throws graphics ABI refers to a replaced shader header.

  • SameHeader also takes a type-3 header as a registered type-7 header for the same code. Every other field must be equal, and the shader registers must have the same offsets in the same order. Values may differ only in the five registers fusion rewrites. Anything else is still refused.
  • When the selected header's type differs from the bound one, ResolveGraphicsStagesAbi applies the bound header's shader registers over the registered state. The ABI is then keyed on the values the title actually binds: the merged RSRC words and the LS address.
  • ARCHITECTURE.md describes the rule.

Ghost of Yōtei (PPSA26344, 01.008) fuses its hull halves while its loading screen is up, and stopped there on every run:

[debug-header] code @80002fc700: the ABI header matched none of 6 registrations
[debug-header] bound @7ff6aca54268: type 3 ... user_data 0 cx @8000038d60 sh @200a80e980 specials @8000038ce0
[debug-header] registered @8000038c80: type 7 ... user_data 8000038d80 cx @8000038d60 sh @8000038d10 specials @8000038ce0
terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC driver: graphics ABI refers to a replaced shader header

(The [debug-header] lines come from a local diagnostic that isn't part of this change.) With this change the fused header resolves to its back half ("ABI header @7ff6aca54268 matched registered header @8000038c80"), and the title gets past this point. Its next stop is a tessellation mode the reference path doesn't support yet, which is a separate topic. Context: #675.

Tested

Windows 11, MinGW-w64 GCC 15.2 (WinLibs), Release, RTX 4090.

  • New FusedHullHeaderSelection in agc_driver_prepared_publication: a fused header built the way sceAgcFuseShaderHalves builds one selects its registered back half. Changing a hull program register, a register offset, a scalar field or the type is still refused. Without the SameHeader change the first check fails.
  • Full ctest on current main (02030f8a6) plus this change: 829 of 830 pass (5 video_out tests skipped on this machine). The one failure, windows_exceptions (0xc0000409), is a libc test built only from files this change doesn't touch, so it fails on main here too; #3415 looks like its fix.
  • In-game on our integration tree (which also has #2293 and #1491): the fused header is accepted in a patch-type sceAgcCreatePrimState.

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 (attach them to this PR)
  • 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:4818469149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3444). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-11T10:42:26Z. --- ### What For hull halves, `sceAgcFuseShaderHalves` returns a copy of the back half (type 7, `HsBack`) and doesn't register it. The copy is marked type 3 (`Hs`), has `user_data` cleared, and has its shader registers copied to the caller's scratch memory, where the checksum (`0x100`), `SPI_SHADER_PGM_RSRC1_HS`/`RSRC2_HS` and the LS program address (`0x148`/`0x149`) are rewritten. Fused geometry halves are registered as a new program; fused hull halves aren't, because the code stays where it was. Draws already find both halves through `0x148` (type 5) and `0x108` (type 7). `sceAgcCreatePrimState` only accepts a hull of type `Hs`, so a title passes the fused header. `ResolveGraphicsStagesAbi` then finds no registered header equal to it and throws `graphics ABI refers to a replaced shader header`. - `SameHeader` also takes a type-3 header as a registered type-7 header for the same code. Every other field must be equal, and the shader registers must have the same offsets in the same order. Values may differ only in the five registers fusion rewrites. Anything else is still refused. - When the selected header's type differs from the bound one, `ResolveGraphicsStagesAbi` applies the bound header's shader registers over the registered state. The ABI is then keyed on the values the title actually binds: the merged RSRC words and the LS address. - `ARCHITECTURE.md` describes the rule. Ghost of Yōtei (PPSA26344, 01.008) fuses its hull halves while its loading screen is up, and stopped there on every run: ``` [debug-header] code @80002fc700: the ABI header matched none of 6 registrations [debug-header] bound @7ff6aca54268: type 3 ... user_data 0 cx @8000038d60 sh @200a80e980 specials @8000038ce0 [debug-header] registered @8000038c80: type 7 ... user_data 8000038d80 cx @8000038d60 sh @8000038d10 specials @8000038ce0 terminate called after throwing an instance of 'std::runtime_error' what(): AGC driver: graphics ABI refers to a replaced shader header ``` (The `[debug-header]` lines come from a local diagnostic that isn't part of this change.) With this change the fused header resolves to its back half ("ABI header @7ff6aca54268 matched registered header @8000038c80"), and the title gets past this point. Its next stop is a tessellation mode the reference path doesn't support yet, which is a separate topic. Context: #675. ### Tested Windows 11, MinGW-w64 GCC 15.2 (WinLibs), Release, RTX 4090. - New `FusedHullHeaderSelection` in `agc_driver_prepared_publication`: a fused header built the way `sceAgcFuseShaderHalves` builds one selects its registered back half. Changing a hull program register, a register offset, a scalar field or the type is still refused. Without the `SameHeader` change the first check fails. - Full `ctest` on current `main` (`02030f8a6`) plus this change: 829 of 830 pass (5 `video_out` tests skipped on this machine). The one failure, `windows_exceptions` (`0xc0000409`), is a libc test built only from files this change doesn't touch, so it fails on `main` here too; #3415 looks like its fix. - In-game on our integration tree (which also has #2293 and #1491): the fused header is accepted in a patch-type `sceAgcCreatePrimState`. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [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)
github-actions[bot] commented 2026-10-11 10:43:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T10:43:09Z.


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
#3159 core/libs/prx/libSceAgcDriver/tests/execution/PreparedPublication.cpp L236
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108189396 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3444#issuecomment-6108189396). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T10:43:09Z. --- <!-- 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 | |---|---|---|---| | #3159 | `core/libs/prx/libSceAgcDriver/tests/execution/PreparedPublication.cpp` [L236](https://github.com/boykopovar/AnyPS5/blob/97fbc7e629e139749a16f1763a875dc7690880db/core/libs/prx/libSceAgcDriver/tests/execution/PreparedPublication.cpp#L236) | | |
adriadam10 commented 2026-10-11 11:44:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:44:56Z.


Checked the build and agc_driver_prepared_publication on Linux (passes; it does not compile without the change), the fused-register set against the PR description, the bounds checks on the guest register arrays, and the ARCHITECTURE.md update; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108672429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3444#issuecomment-6108672429). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:44:56Z. --- Checked the build and `agc_driver_prepared_publication` on Linux (passes; it does not compile without the change), the fused-register set against the PR description, the bounds checks on the guest register arrays, and the ARCHITECTURE.md update; merging.
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!3444
No description provided.