fix(ngs2): correct UserFx ids and preserve Delay compatibility #9337

Merged
Th3EvilGod merged 3 commits from upstream-pr/9337 into main 2026-10-23 07:24:21 +00:00
Th3EvilGod commented 2026-10-21 18:45:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Th3EvilGod on 2026-10-21T18:45:49Z.


What

Separate UserFx (0x19, 0x40001900 | index) from Delay (0x1d, 0x40001dxx). Reuse the existing 40-byte UserFx callback parameter under the corrected IDs, reject non-zero UserFx module state with INVALID_STATE_SIZE, and reject non-null UserFx options and custom-sampler UserFx until their unsupported contracts are established.

Preserve the existing Delay audio pass-through as requested by the maintainer. A one-buffer custom submixer with eight ports, no module state and option 20, 0, 4, 1000.0f, 0 now passes creation, preserving the rack shape reported for Void Terrarium (PPSA03061) in #5055. The path handles the general supported option family, without a title ID or those specific values in production code: type 0/1, 1..8 taps, finite length 1..20000 and reserved 0. Unknown options, module state and custom-sampler Delay throw. Every 0x40001dxx parameter throws an explicit Delay-not-implemented error before any callback or parameter state is changed.

Evidence: fma-rc's PS5 firmware 12.70 module reading, parameter dispatch 0x25ec4, rack creation 0x13b68, identifies UserFx and Delay, the 40-byte UserFx parameter (8-byte header, handler, three user-data words), and the Delay option layout/ranges. The earlier reading identifies UserFx as having no option or module state. These are attributed findings, not disassembly or hardware measurements I performed.

Delay processing/defaults remain unverified; this deliberately preserves existing host behavior and does not claim a working delay effect. The existing UserFx callback context, flags, null-handler behavior and callback-error model also remain unverified on console. Both limits are recorded in separate debt entries. Multi-buffer racks and other custom DSP modules remain outside this change; no title is claimed unblocked.

Rebased on #9233 at 3e00103497 (including its #8609 prerequisite), with main 1a745ae38e merged. This PR's own change is the single commit b553950ef, affecting four files relative to the combined prerequisite base 154ca3754e; Gain code, its ramp tests and its debt entry are retained. The main-targeting diff includes the prerequisite until it lands.

Tested

Windows 11 Pro, supported WinLibs MinGW-w64 GCC 15.2.0 r7, Release, full-runtime configuration with BUILD_TESTING=ON.

  • Regression control: with the new literal-ID Delay test on the rebased pre-Delay implementation (068856ef5), ngs2_custom aborts at rack creation with custom module id 0x1d is not implemented.
  • Final runtime libs build and both NID-patched NGS2 libraries: pass.
  • Final ctest --test-dir build/windows-cnd -R '^ngs2_' -V: 13/13 pass, 3.63 seconds.
  • Delay regression creates the reported one-buffer / eight-port / no-state rack with literal 0x1d and the 20-byte option. It compares every stereo PCM sample over consecutive grains, silence before input and after stop, and unchanged output after rejected parameters. It covers 1, 2 and 24 Delay modules, both option types and range endpoints, all 256 0x40001dxx IDs, and confirms no legacy UserFx callback runs. Null/wrong options, invalid option fields, NaN/infinity, module state/offset and custom-sampler Delay are rejected.
  • Existing UserFx tests use literal 0x19 / 0x40001900 | index, verify PCM and callback state at positions 0, 1 and 23, and retain invalid-state, parameter-size/index and custom-sampler rejection checks. Gain regressions remain enabled.
  • tools/check_conventions.py --base origin/main: passes with no findings; whitespace check passes.
  • Live overlap scan completed. #9233 and its #8609 prerequisite are ancestors. The scan compares this rebased branch with the old published #9337 head; that row is this update replacing itself. #5548 shares a declaration already affected by the prerequisite, and #8851 edits the same debt. Stale #1384 and #5797 cannot be fully compared with main; their source changes were inspected and concern reverb/HE-VAG rather than this correction. These integration warnings remain visible; no unrelated PR is modified.

No actual title, console-hardware or Linux run, no full repository test-suite run, and no performance claim. The synthetic Delay regression establishes preservation of existing PCM behavior, not console equivalence or game compatibility.

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: #9233
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4956642460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9337). Originally posted by [Th3EvilGod](https://github.com/Th3EvilGod) on 2026-10-21T18:45:49Z. --- ### What Separate UserFx (`0x19`, `0x40001900 | index`) from Delay (`0x1d`, `0x40001dxx`). Reuse the existing 40-byte UserFx callback parameter under the corrected IDs, reject non-zero UserFx module state with `INVALID_STATE_SIZE`, and reject non-null UserFx options and custom-sampler UserFx until their unsupported contracts are established. Preserve the existing Delay audio pass-through [as requested by the maintainer](https://github.com/boykopovar/AnyPS5/pull/9337#issuecomment-6351205140). A one-buffer custom submixer with eight ports, no module state and option `20, 0, 4, 1000.0f, 0` now passes creation, preserving the rack shape reported for Void Terrarium (PPSA03061) in [#5055](https://github.com/boykopovar/AnyPS5/issues/5055#issuecomment-6154121860). The path handles the general supported option family, without a title ID or those specific values in production code: type 0/1, 1..8 taps, finite length 1..20000 and reserved 0. Unknown options, module state and custom-sampler Delay throw. Every `0x40001dxx` parameter throws an explicit Delay-not-implemented error before any callback or parameter state is changed. Evidence: [fma-rc's PS5 firmware 12.70 module reading](https://github.com/boykopovar/AnyPS5/issues/8039#issuecomment-6319332943), parameter dispatch `0x25ec4`, rack creation `0x13b68`, identifies UserFx and Delay, the 40-byte UserFx parameter (8-byte header, handler, three user-data words), and the Delay option layout/ranges. [The earlier reading](https://github.com/boykopovar/AnyPS5/issues/8039#issuecomment-6294323150) identifies UserFx as having no option or module state. These are attributed findings, not disassembly or hardware measurements I performed. Delay processing/defaults remain unverified; this deliberately preserves existing host behavior and does not claim a working delay effect. The existing UserFx callback context, flags, null-handler behavior and callback-error model also remain unverified on console. Both limits are recorded in separate debt entries. Multi-buffer racks and other custom DSP modules remain outside this change; no title is claimed unblocked. Rebased on #9233 at `3e00103497` (including its #8609 prerequisite), with main `1a745ae38e` merged. This PR's own change is the single commit `b553950ef`, affecting four files relative to the combined prerequisite base `154ca3754e`; Gain code, its ramp tests and its debt entry are retained. The main-targeting diff includes the prerequisite until it lands. ### Tested Windows 11 Pro, supported WinLibs MinGW-w64 GCC 15.2.0 r7, Release, full-runtime configuration with `BUILD_TESTING=ON`. - Regression control: with the new literal-ID Delay test on the rebased pre-Delay implementation (`068856ef5`), `ngs2_custom` aborts at rack creation with `custom module id 0x1d is not implemented`. - Final runtime `libs` build and both NID-patched NGS2 libraries: pass. - Final `ctest --test-dir build/windows-cnd -R '^ngs2_' -V`: 13/13 pass, 3.63 seconds. - Delay regression creates the reported one-buffer / eight-port / no-state rack with literal `0x1d` and the 20-byte option. It compares every stereo PCM sample over consecutive grains, silence before input and after stop, and unchanged output after rejected parameters. It covers 1, 2 and 24 Delay modules, both option types and range endpoints, all 256 `0x40001dxx` IDs, and confirms no legacy UserFx callback runs. Null/wrong options, invalid option fields, NaN/infinity, module state/offset and custom-sampler Delay are rejected. - Existing UserFx tests use literal `0x19` / `0x40001900 | index`, verify PCM and callback state at positions 0, 1 and 23, and retain invalid-state, parameter-size/index and custom-sampler rejection checks. Gain regressions remain enabled. - `tools/check_conventions.py --base origin/main`: passes with no findings; whitespace check passes. - Live overlap scan completed. #9233 and its #8609 prerequisite are ancestors. The scan compares this rebased branch with the old published #9337 head; that row is this update replacing itself. #5548 shares a declaration already affected by the prerequisite, and #8851 edits the same debt. Stale #1384 and #5797 cannot be fully compared with main; their source changes were inspected and concern reverb/HE-VAG rather than this correction. These integration warnings remain visible; no unrelated PR is modified. No actual title, console-hardware or Linux run, no full repository test-suite run, and no performance claim. The synthetic Delay regression establishes preservation of existing PCM behavior, not console equivalence or game compatibility. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: <!-- #PR, or none --> #9233 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
KernelPanicNT commented 2026-10-21 19:03:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-21T19:03:23Z.


Thanks for picking this up so quickly, it's good to see 0x19 used as fma-rc read it. The move to 0x19 / 0x40001900 | index, INVALID_STATE_SIZE for a non-zero state and the throw for an option all line up with his two readings in #8039.

Two things worth a look before it goes in:

  1. Void Terrarium (PPSA03061) would stop. With this change 0x1d no longer matches any branch in Ngs2CheckCustomRack, so it hits the unknown-module throw (Custom.cpp:62-63), and the tests at tests/Ngs2Custom.cpp:470 and :584-588 expect that. Void Terrarium creates exactly that rack: one 0x1d module with the option 20, 0, 4, 1000.0f, 0, one buffer, no state (#5055 has a 150 s run reaching the title screen with sound). Today it gets through because main still accepts that option through the #5139 path.
    Throwing for a Delay we can't process yet is within the rules, so I'm not asking you to change the behaviour. It would just help to mention PPSA03061 in the PR body as a known regression and keep the title in the debt entry, so the maintainers can make that call knowingly. The other route is to keep main's 0x1d path under a Delay name until fma-rc tells us what Delay writes before any parameter is set (question 1 here). Either is fine by me.
  2. 0x19 on the custom sampler rack does nothing. Ngs2CheckCustomRack also runs for 0x4001 (Rack.cpp:106) and accepts 0x19 there, but 0x400019xx is only accepted on 0x4002 (Custom.cpp:202), so the handler can never be set and the audio passes through silently. To be fair, main has the same gap for 0x1d. fma-rc says the index is one higher on 0x4001, so it could either throw at creation there, as #9233 does for Gain, or route the parameter with index - 1. Main's Filter handling on 0x4001 can stay as it is, since Dead Cells sends 0x40001300 and that's still an open question (question 5).

For what it's worth, the merge of #8609 in your branch is unchanged, so there's no conflict with mine, and the conflicts with #9233 are only textual, as your merge-order note already says.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6324169090 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9337#issuecomment-6324169090). Originally posted by [KernelPanicNT](https://github.com/KernelPanicNT) on 2026-10-21T19:03:23Z. --- Thanks for picking this up so quickly, it's good to see `0x19` used as fma-rc read it. The move to `0x19` / `0x40001900 | index`, `INVALID_STATE_SIZE` for a non-zero state and the throw for an option all line up with his two readings in #8039. Two things worth a look before it goes in: 1. **Void Terrarium (PPSA03061) would stop.** With this change `0x1d` no longer matches any branch in `Ngs2CheckCustomRack`, so it hits the unknown-module throw (`Custom.cpp:62-63`), and the tests at `tests/Ngs2Custom.cpp:470` and `:584-588` expect that. Void Terrarium creates exactly that rack: one `0x1d` module with the option `20, 0, 4, 1000.0f, 0`, one buffer, no state ([#5055](https://github.com/boykopovar/AnyPS5/issues/5055#issuecomment-6154121860) has a 150 s run reaching the title screen with sound). Today it gets through because main still accepts that option through the #5139 path. Throwing for a Delay we can't process yet is within the rules, so I'm not asking you to change the behaviour. It would just help to mention PPSA03061 in the PR body as a known regression and keep the title in the debt entry, so the maintainers can make that call knowingly. The other route is to keep main's `0x1d` path under a Delay name until fma-rc tells us what Delay writes before any parameter is set (question 1 [here](https://github.com/boykopovar/AnyPS5/issues/8039#issuecomment-6320348229)). Either is fine by me. 2. **`0x19` on the custom sampler rack does nothing.** `Ngs2CheckCustomRack` also runs for `0x4001` (`Rack.cpp:106`) and accepts `0x19` there, but `0x400019xx` is only accepted on `0x4002` (`Custom.cpp:202`), so the handler can never be set and the audio passes through silently. To be fair, main has the same gap for `0x1d`. fma-rc says the index is one higher on `0x4001`, so it could either throw at creation there, as #9233 does for Gain, or route the parameter with `index - 1`. Main's Filter handling on `0x4001` can stay as it is, since Dead Cells sends `0x40001300` and that's still an open question (question 5). For what it's worth, the merge of #8609 in your branch is unchanged, so there's no conflict with mine, and the conflicts with #9233 are only textual, as your merge-order note already says.
JJenkx commented 2026-10-22 09:07:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T09:07:25Z.


Title data point: BLUE REFLECTION Quartet (PPSA33655). Its racks are listed in #8851:

  • MixerB: 0x19;
  • ReverbB: 0x15 Gain + 0x1b Reverb (12-byte option);
  • DuckingCompSB: 0x19 ×2, 2 buffers.

The stop moves forward with each PR. Same scripted runs, natively on Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release:

Build Stop
main d6eafa54d0 2 s: NGS2: custom module id 0x19 is not implemented
d6eafa54d0 + #9337 ea6fc50b30 4 s: NGS2: the custom Gain module is not implemented
d6eafa54d0 + #9337 + #9233 8f6f1eac86 2 s: NGS2: the custom Reverb module is not implemented

So:

  • with #9337, the 0x19 modules in MixerB pass creation as UserFx;
  • with #9233 added, the Gain module in ReverbB passes;
  • the next stop is Reverb (0x1b), which neither PR covers;
  • after that comes DuckingCompSB, which needs 2-buffer racks.

No audio was produced or checked; this only shows rack creation getting further. Combining the two PRs conflicted in Ngs2Types.hpp: I kept both SCE_NGS2_CUSTOM_VOICE_PARAM_GAIN and #9337's UserFx id 0x40001900. It also conflicted in the test and debt files, where I kept #9337's side; those are not built in this test.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337031154 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9337#issuecomment-6337031154). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T09:07:25Z. --- Title data point: **BLUE REFLECTION Quartet (PPSA33655)**. Its racks are listed in #8851: - `MixerB`: 0x19; - `ReverbB`: 0x15 Gain + 0x1b Reverb (12-byte option); - `DuckingCompSB`: 0x19 ×2, 2 buffers. The stop moves forward with each PR. Same scripted runs, natively on Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release: | Build | Stop | |---|---| | `main` `d6eafa54d0` | 2 s: `NGS2: custom module id 0x19 is not implemented` | | `d6eafa54d0` + #9337 `ea6fc50b30` | 4 s: `NGS2: the custom Gain module is not implemented` | | `d6eafa54d0` + #9337 + #9233 `8f6f1eac86` | 2 s: `NGS2: the custom Reverb module is not implemented` | So: - with #9337, the 0x19 modules in `MixerB` pass creation as UserFx; - with #9233 added, the Gain module in `ReverbB` passes; - the next stop is Reverb (0x1b), which neither PR covers; - after that comes `DuckingCompSB`, which needs 2-buffer racks. No audio was produced or checked; this only shows rack creation getting further. Combining the two PRs conflicted in `Ngs2Types.hpp`: I kept both `SCE_NGS2_CUSTOM_VOICE_PARAM_GAIN` and #9337's UserFx id `0x40001900`. It also conflicted in the test and debt files, where I kept #9337's side; those are not built in this test.
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!9337
No description provided.