fix(libSceAgc): match interpolant mapping variants to firmware #8402

Merged
hypermoist merged 1 commit from upstream-pr/8402 into main 2026-10-22 22:35:27 +00:00
hypermoist commented 2026-10-20 12:24:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T12:24:35Z.


What

Makes the interpolant mapping exports match the decrypted libSceAgc.sprx.

The firmware has six bodies. sceAgcCreateInterpolantMapping (pdEV7bI6COI) is at 0x10940, sceAgcUpdateInterpolantMapping (SbuY2jN+axQ) at 0x10ca0, _0100 (HV4j+E0MBHE / k0E7vkgqAuE) at 0x10f90 / 0x112a0 and _10000 (dbOlWdppb4o / vieBRwlh1Lw) at 0x11540 / 0x11950. They are pure register builders on SPI_PS_INPUT_CNTL_0 + i, and they differ only in how they derive each value and in whether they fill the identity tail.

  • New: sceAgcCreateInterpolantMapping and sceAgcUpdateInterpolantMapping (unversioned, absent until now). They are the _0100 transform with one difference: a matched non-f16 input that is flat-shaded also gets OFFSET bit 5 (0x20), which _0100 sets only for is_custom (firmware 0x10a8b–0x10aa8). Create fills the identity tail and Update does not.
  • sceAgcUpdateInterpolantMapping_10000 no longer throws for an is_f16 1 or 3 input whose default_value and default_value_hi differ. The firmware takes DEFAULT_VAL from default_value, which is what CreateInterpolantValueSplitF16 already does. So this export is now _10000 without the tail.

Null and empty handling is unchanged, and matches the firmware where the firmware does not crash:

  • a null pixel shader gives the identity for Create;
  • a pixel shader without inputs writes the identity (Create) or nothing (Update);
  • a null gs with inputs, or a null pixel shader for Update, crashes on the console and throws here.

Debt: the two Update_10000 OpenAGC-only entries are removed from libSceAgc.md. The "is_f16 2 bits follow KytyPS5, not confirmed" sentence is dropped from the Create_10000 entry.

Not in this PR: sceAgcUpdateInterpolantMapping_0100 (still NotImplemented in ShaderFusion.cpp) is, per the firmware, the _0100 transform without the tail. It will follow once #8314, which appends to the end of that file, is merged.

Tested

Linux (CachyOS, GCC, Release).

  • Differential test. A harness mapped the console libSceAgc.sprx, seeded its interpolant register template with SPI_PS_INPUT_CNTL_0, and called each of the six exports on 300 000 random pixel and geometry shaders. The shaders had 0 to 32 inputs and outputs, random semantic words and partly overlapping semantic IDs. Upstream's value helpers with the new variant selection gave 0 mismatching registers for every export, tail included.
  • Repo test. agc_interpolant_mapping_tests gains testUnversionedMapping; the old expect-throw case in testUpdateMapping now checks the firmware values 0x01380007 and 0x03680409. All expected values come from the console module's output. The suite passes, as do agc_driver_interpolation_f16_tests and agc_driver_interpolation_modes_tests.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none verified; titles importing pdEV7bI6COI / SbuY2jN+axQ no longer hit a missing NID
  • GPUs tested: NVIDIA GeForce RTX 3060 (tests only)
  • AI-assisted: yes (Claude Code), reviewed by the contributor

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4935670442 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8402). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T12:24:35Z. --- ### What Makes the interpolant mapping exports match the decrypted `libSceAgc.sprx`. The firmware has six bodies. `sceAgcCreateInterpolantMapping` (`pdEV7bI6COI`) is at 0x10940, `sceAgcUpdateInterpolantMapping` (`SbuY2jN+axQ`) at 0x10ca0, `_0100` (`HV4j+E0MBHE` / `k0E7vkgqAuE`) at 0x10f90 / 0x112a0 and `_10000` (`dbOlWdppb4o` / `vieBRwlh1Lw`) at 0x11540 / 0x11950. They are pure register builders on `SPI_PS_INPUT_CNTL_0 + i`, and they differ only in how they derive each value and in whether they fill the identity tail. - **New: `sceAgcCreateInterpolantMapping` and `sceAgcUpdateInterpolantMapping` (unversioned, absent until now).** They are the `_0100` transform with one difference: a matched non-f16 input that is flat-shaded also gets OFFSET bit 5 (`0x20`), which `_0100` sets only for `is_custom` (firmware 0x10a8b–0x10aa8). Create fills the identity tail and Update does not. - **`sceAgcUpdateInterpolantMapping_10000`** no longer throws for an `is_f16` 1 or 3 input whose `default_value` and `default_value_hi` differ. The firmware takes `DEFAULT_VAL` from `default_value`, which is what `CreateInterpolantValueSplitF16` already does. So this export is now `_10000` without the tail. Null and empty handling is unchanged, and matches the firmware where the firmware does not crash: - a null pixel shader gives the identity for Create; - a pixel shader without inputs writes the identity (Create) or nothing (Update); - a null `gs` with inputs, or a null pixel shader for Update, crashes on the console and throws here. Debt: the two `Update_10000` OpenAGC-only entries are removed from `libSceAgc.md`. The "`is_f16` 2 bits follow KytyPS5, not confirmed" sentence is dropped from the `Create_10000` entry. Not in this PR: `sceAgcUpdateInterpolantMapping_0100` (still `NotImplemented` in `ShaderFusion.cpp`) is, per the firmware, the `_0100` transform without the tail. It will follow once #8314, which appends to the end of that file, is merged. ### Tested Linux (CachyOS, GCC, Release). - **Differential test.** A harness mapped the console `libSceAgc.sprx`, seeded its interpolant register template with `SPI_PS_INPUT_CNTL_0`, and called each of the six exports on 300 000 random pixel and geometry shaders. The shaders had 0 to 32 inputs and outputs, random semantic words and partly overlapping semantic IDs. Upstream's value helpers with the new variant selection gave 0 mismatching registers for every export, tail included. - **Repo test.** `agc_interpolant_mapping_tests` gains `testUnversionedMapping`; the old expect-throw case in `testUpdateMapping` now checks the firmware values `0x01380007` and `0x03680409`. All expected values come from the console module's output. The suite passes, as do `agc_driver_interpolation_f16_tests` and `agc_driver_interpolation_modes_tests`. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none verified; titles importing `pdEV7bI6COI` / `SbuY2jN+axQ` no longer hit a missing NID - [x] GPUs tested: NVIDIA GeForce RTX 3060 (tests only) - [x] AI-assisted: yes (Claude Code), reviewed by the contributor 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
github-actions[bot] commented 2026-10-20 12:25:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T12:25:19Z.


Progress report (aa02422 → e95f842)

📈 System libraries: 64.34% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceAgc sceAgcCreateInterpolantMapping_nid_postfix
libSceAgc sceAgcUpdateInterpolantMapping_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290784748 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8402#issuecomment-6290784748). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T12:25:19Z. --- <!-- progress-report --> ### Progress report (aa02422 → e95f842) 📈 **System libraries**: 64.34% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libSceAgc | `sceAgcCreateInterpolantMapping_nid_postfix` | | libSceAgc | `sceAgcUpdateInterpolantMapping_nid_postfix` | </details>
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!8402
No description provided.