feat(ngs2): accept custom submixers with more than eight channels #11347

Merged
edubox merged 9 commits from upstream-pr/11347 into main 2026-10-30 00:20:55 +00:00
edubox commented 2026-10-26 06:07:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-26T06:07:30Z.


What

Accept custom submixer racks with more than eight channels (9 to 37) instead of throwing at creation. The rack limit still applies to the matrix-level count and the legacy UserFx channel-pointer array.

Voices on those racks stay limited to eight input and eight output channels, as firmware 13.42 does (0x804A8052 for 9/9, 12/12 and 37/37). A port into more than eight channels without a matrix therefore remains unsupported and throws; the explicit-matrix path is unchanged.

This removes the first blocker of Fatal Frame II (PPSA32802), which creates a 12-channel custom submixer rack during start-up. The voice and matrixless-map limits mean the title still stops later at NGS2: custom module id 0x17 is not implemented (the EQ module, outside this change).

Tested

Linux, GCC 16.2.1, RTX 4080 SUPER. All 16 ngs2_* tests pass. TestWideCustomSubmixer now creates a 12-channel custom submixer rack, checks that a 12/12 voice setup is rejected, and renders an 8/8 voice through explicit matrices.

BunnyFl measured the voice limit on firmware 13.42: a custom submixer rack accepts max_channels 2 to 37, while voice setup returns 0x804A8052 above 8 inputs or outputs; the same run confirms the rack limit of 37. Fatal Frame II (PPSA32802 01.002.002) passes the 12-channel rack creation on this head.

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 (PPSA32802 has no Game bring-up discussion; this alone does not unblock the title)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5012880152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347). Originally posted by [edubox](https://github.com/edubox) on 2026-10-26T06:07:30Z. --- ### What Accept custom submixer racks with more than eight channels (9 to 37) instead of throwing at creation. The rack limit still applies to the matrix-level count and the legacy UserFx channel-pointer array. Voices on those racks stay limited to eight input and eight output channels, as firmware 13.42 does (`0x804A8052` for 9/9, 12/12 and 37/37). A port into more than eight channels without a matrix therefore remains unsupported and throws; the explicit-matrix path is unchanged. This removes the first blocker of Fatal Frame II (PPSA32802), which creates a 12-channel custom submixer rack during start-up. The voice and matrixless-map limits mean the title still stops later at `NGS2: custom module id 0x17 is not implemented` (the EQ module, outside this change). ### Tested Linux, GCC 16.2.1, RTX 4080 SUPER. All 16 `ngs2_*` tests pass. `TestWideCustomSubmixer` now creates a 12-channel custom submixer rack, checks that a 12/12 voice setup is rejected, and renders an 8/8 voice through explicit matrices. BunnyFl measured the voice limit on firmware 13.42: a custom submixer rack accepts `max_channels` 2 to 37, while voice setup returns `0x804A8052` above 8 inputs or outputs; the same run confirms the rack limit of 37. Fatal Frame II (PPSA32802 01.002.002) passes the 12-channel rack creation on this head. ### 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 (PPSA32802 has no Game bring-up discussion; this alone does not unblock the title) - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 06:09:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T06:09:00Z.

Review: APPROVED


I reviewed the current-main diff in Rack.cpp, Render.cpp, Voice.cpp, and the custom-FX path. The expanded 9–37 channel allowance is limited to custom submixer racks; custom mastering and the existing sampler/render limits remain bounded. Matrix validation now uses the public rack maximum, the legacy callback channel array uses the matching capacity, and the default map selects identity only when both wide channel counts match. The new test exercises a 12-channel rack with explicit source/destination matrices and verifies the rendered output, while the updated checks cover 16 and 37 channels. The author reports all 16 NGS2 tests passing on Linux/GCC 16.2.1; hosted product jobs are path-skipped, so those are not independent hosted results. I found no remaining actionable issue in the reviewed scope.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5648015526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347#pullrequestreview-5648015526). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T06:09:00Z. **Review:** APPROVED --- I reviewed the current-main diff in `Rack.cpp`, `Render.cpp`, `Voice.cpp`, and the custom-FX path. The expanded 9–37 channel allowance is limited to custom submixer racks; custom mastering and the existing sampler/render limits remain bounded. Matrix validation now uses the public rack maximum, the legacy callback channel array uses the matching capacity, and the default map selects identity only when both wide channel counts match. The new test exercises a 12-channel rack with explicit source/destination matrices and verifies the rendered output, while the updated checks cover 16 and 37 channels. The author reports all 16 NGS2 tests passing on Linux/GCC 16.2.1; hosted product jobs are path-skipped, so those are not independent hosted results. I found no remaining actionable issue in the reviewed scope.
MarcZX10 commented 2026-10-26 06:16:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T06:16:31Z.

Review: CHANGES_REQUESTED


I found a cross-path correctness issue in the newly enabled 32–37 channel range. Ngs2CheckCustomRack accepts SCE_NGS2_CUSTOM_MODULE_ID_PITCH_SHIFT on a custom submixer; Ngs2SetupUserFx allocates pitch-shift state to rack.maxChannels, and SetupCustomSubmixer now accepts a voice count through that maximum. When such a voice is rendered, Ngs2ProcessPitchShift computes ((1u << voice.channels) - 1) and later tests (1u << c) with a 32-bit 1u (see PitchShift.cpp:223,230 in the integrated NGS2 implementation). For a 32–37 channel voice these shifts have an exponent at least 32, which is undefined behavior; the parameter’s bypass_mask and initializedChannels are also 32-bit, so channels above bit 31 need defined semantics. I confirmed the shift expression triggers UBSan at channel count 37. The new wide-rack test uses no pitch-shift module, so it does not cover this reachable configuration. Please either implement well-defined channel-mask handling for the newly supported range or reject pitch-shift configurations that cannot be represented, and add a focused regression for the selected behavior before this wide-channel support is approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5648065475 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347#pullrequestreview-5648065475). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T06:16:31Z. **Review:** CHANGES_REQUESTED --- I found a cross-path correctness issue in the newly enabled 32–37 channel range. `Ngs2CheckCustomRack` accepts `SCE_NGS2_CUSTOM_MODULE_ID_PITCH_SHIFT` on a custom submixer; `Ngs2SetupUserFx` allocates pitch-shift state to `rack.maxChannels`, and `SetupCustomSubmixer` now accepts a voice count through that maximum. When such a voice is rendered, `Ngs2ProcessPitchShift` computes `((1u << voice.channels) - 1)` and later tests `(1u << c)` with a 32-bit `1u` (see `PitchShift.cpp:223,230` in the integrated NGS2 implementation). For a 32–37 channel voice these shifts have an exponent at least 32, which is undefined behavior; the parameter’s `bypass_mask` and `initializedChannels` are also 32-bit, so channels above bit 31 need defined semantics. I confirmed the shift expression triggers UBSan at channel count 37. The new wide-rack test uses no pitch-shift module, so it does not cover this reachable configuration. Please either implement well-defined channel-mask handling for the newly supported range or reject pitch-shift configurations that cannot be represented, and add a focused regression for the selected behavior before this wide-channel support is approved.
MarcZX10 commented 2026-10-26 06:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T06:17:01Z.

Review: APPROVED


Correction to my prior review: the 32-bit shift concern I raised is in the separate, unmerged PitchShift implementation from #11315. In this PR’s exact current-main base, Ngs2CheckCustomRack still rejects the built-in PitchShift module, so that execution path is not introduced by this diff. The request for changes was therefore too strong for #11347 in isolation; I have restored approval. I will flag the integration risk on #11315, since its implementation would make the newly supported 32–37 channel custom-submixer range relevant.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5648068719 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347#pullrequestreview-5648068719). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T06:17:01Z. **Review:** APPROVED --- Correction to my prior review: the 32-bit shift concern I raised is in the separate, unmerged PitchShift implementation from #11315. In this PR’s exact current-main base, `Ngs2CheckCustomRack` still rejects the built-in PitchShift module, so that execution path is not introduced by this diff. The request for changes was therefore too strong for #11347 in isolation; I have restored approval. I will flag the integration risk on #11315, since its implementation would make the newly supported 32–37 channel custom-submixer range relevant.
MarcZX10 commented 2026-10-26 09:37:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T09:37:53Z.

Review: DISMISSED


Re-reviewed exact head 726587dead747f3af1a4206e69c693b859b0beb5 against current main 4e43321bd6ceccdc1ae28568bbbc35d9a6446464. Conventions and git diff --check pass, and the merge preview is clean. The branch is nevertheless 63 commits behind current main; Render.cpp, Voice.cpp and the NGS2 debt file changed on main since its base. The reported 16-test run and PPSA32802 startup run were on the earlier c3db base. Product test jobs are skipped by path policy, and I cannot run the NGS2 binary on this host because its CPU preflight requires unsupported instructions. Please rebase and rerun the focused suite on the resulting head.

There is also an unverified behavior in the implementation: Ngs2DefaultLevel selects an identity map for a matrixless port when either side has more than eight channels and source/destination counts match. The debt entry calls that mapping unverified, but AGENTS.md requires unknown behavior to remain unsupported. The new TestWideCustomSubmixer sets explicit matrices on both ports, so it does not exercise this new default-map path. Please provide console evidence for the identity mapping and cover it, or keep matrixless wide-channel routing unsupported until its behavior is known; retain the explicit-matrix path separately.

Finally, the checklist says Unblocks: PPSA32802 (no game bring-up discussion). The contribution rule asks for the title's Game bring-up discussion when a PR unblocks it. Please link the applicable discussion, or clarify that this is not a title-unblocking change and update the checklist accordingly.

The previously reported pairwise conflict with #11315 in Rack.cpp and the NGS2 debt file remains; coordinate integration and preserve both changes when resolving it.

AI-assisted review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649963660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347#pullrequestreview-5649963660). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T09:37:53Z. **Review:** DISMISSED --- Re-reviewed exact head `726587dead747f3af1a4206e69c693b859b0beb5` against current `main` `4e43321bd6ceccdc1ae28568bbbc35d9a6446464`. Conventions and `git diff --check` pass, and the merge preview is clean. The branch is nevertheless 63 commits behind current main; `Render.cpp`, `Voice.cpp` and the NGS2 debt file changed on main since its base. The reported 16-test run and PPSA32802 startup run were on the earlier `c3db` base. Product test jobs are skipped by path policy, and I cannot run the NGS2 binary on this host because its CPU preflight requires unsupported instructions. Please rebase and rerun the focused suite on the resulting head. There is also an unverified behavior in the implementation: `Ngs2DefaultLevel` selects an identity map for a matrixless port when either side has more than eight channels and source/destination counts match. The debt entry calls that mapping unverified, but `AGENTS.md` requires unknown behavior to remain unsupported. The new `TestWideCustomSubmixer` sets explicit matrices on both ports, so it does not exercise this new default-map path. Please provide console evidence for the identity mapping and cover it, or keep matrixless wide-channel routing unsupported until its behavior is known; retain the explicit-matrix path separately. Finally, the checklist says `Unblocks: PPSA32802 (no game bring-up discussion)`. The contribution rule asks for the title's Game bring-up discussion when a PR unblocks it. Please link the applicable discussion, or clarify that this is not a title-unblocking change and update the checklist accordingly. The previously reported pairwise conflict with #11315 in `Rack.cpp` and the NGS2 debt file remains; coordinate integration and preserve both changes when resolving it. AI-assisted review.
THEMANnt commented 2026-10-26 15:13:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T15:13:33Z.

Review: DISMISSED


core/libs/prx/libSceNgs2.native/src/Voice.cpp:118: the expanded limit accepts 65 matrix levels, but sceNgs2VoiceGetMatrixInfo still writes into the fixed 64-float Ngs2VoiceMatrixInfo::levels array. Reading that matrix copies the 65th float past the caller’s output buffer and corrupts adjacent memory. Please preserve the ABI capacity or make the getter safely reject/limit matrices that do not fit, and add a regression for this boundary.

Validation: the Release ngs2_custom_tests build succeeded and the author suite passed (1 passed, 0 skipped, 0 failed). A review-only guarded test accepted 65 levels, returned num_levels=65, and changed the adjacent canary from 0x51a7c0de to 0x3e800000. The pinned-base control rejects the 65-level input and preserves the canary. Hosted Actions passed eligibility only; product build/test jobs were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5654339979 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347#pullrequestreview-5654339979). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T15:13:33Z. **Review:** DISMISSED --- `core/libs/prx/libSceNgs2.native/src/Voice.cpp:118`: the expanded limit accepts 65 matrix levels, but `sceNgs2VoiceGetMatrixInfo` still writes into the fixed 64-float `Ngs2VoiceMatrixInfo::levels` array. Reading that matrix copies the 65th float past the caller’s output buffer and corrupts adjacent memory. Please preserve the ABI capacity or make the getter safely reject/limit matrices that do not fit, and add a regression for this boundary. Validation: the Release `ngs2_custom_tests` build succeeded and the author suite passed (1 passed, 0 skipped, 0 failed). A review-only guarded test accepted 65 levels, returned `num_levels=65`, and changed the adjacent canary from `0x51a7c0de` to `0x3e800000`. The pinned-base control rejects the 65-level input and preserves the canary. Hosted Actions passed eligibility only; product build/test jobs were skipped.
THEMANnt commented 2026-10-28 15:56:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T15:56:19Z.

Review: APPROVED


Re-reviewed 0c4d2ca7a58b7505d82aa984fd844fc5d78a2619 against 17f8dfad513b134a4996991109fc9db47a3bb905 — approve. The earlier matrix-output overflow is fixed: sceNgs2VoiceGetMatrixInfo rejects stored matrices larger than its 64-float ABI buffer before any output write. The rack allowance remains separate from the eight-channel voice limit, and unsupported matrixless wide-channel routing still throws.

Validation: Windows/GCC 15.3 Release, isolated pinned checkouts: all 30 NGS2 CTests passed on the head and all 30 passed on the baseline, with no skips. Independent guarded-buffer checks cover 63/64-level success, 65/66/1369-level rejection with the entire output and canary unchanged, rejection above the 37×37 setter maximum, and recovery to a readable 64-level matrix. Removing only the getter guard reproduces the 65-level overwrite and fails the control; restoring the original sources passes. The direct conventions check passes.

Current-head hosted Windows CI succeeded, including its host-only linking step; its CTest step was skipped, so the NGS2 execution results above are local. No console/title run or independent firmware measurement is claimed. I found no remaining blocker in this reviewed scope.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5685659943 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11347#pullrequestreview-5685659943). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T15:56:19Z. **Review:** APPROVED --- Re-reviewed `0c4d2ca7a58b7505d82aa984fd844fc5d78a2619` against `17f8dfad513b134a4996991109fc9db47a3bb905` — approve. The earlier matrix-output overflow is fixed: `sceNgs2VoiceGetMatrixInfo` rejects stored matrices larger than its 64-float ABI buffer before any output write. The rack allowance remains separate from the eight-channel voice limit, and unsupported matrixless wide-channel routing still throws. **Validation:** Windows/GCC 15.3 Release, isolated pinned checkouts: all 30 NGS2 CTests passed on the head and all 30 passed on the baseline, with no skips. Independent guarded-buffer checks cover 63/64-level success, 65/66/1369-level rejection with the entire output and canary unchanged, rejection above the 37×37 setter maximum, and recovery to a readable 64-level matrix. Removing only the getter guard reproduces the 65-level overwrite and fails the control; restoring the original sources passes. The direct conventions check passes. Current-head hosted Windows CI succeeded, including its host-only linking step; its CTest step was skipped, so the NGS2 execution results above are local. No console/title run or independent firmware measurement is claimed. I found no remaining blocker in this reviewed scope.
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!11347
No description provided.