fix(libSceNgs2): accept system option flag bit 1 #8341

Merged
KernelPanicNT merged 1 commit from upstream-pr/8341 into main 2026-10-23 03:21:15 +00:00
KernelPanicNT commented 2026-10-20 10:36:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-20T10:36:11Z.


What

Rise of the Ronin (PPSA04540) creates its NGS2 system with flags = 2 in Ngs2SystemOption. The other fields are name KTSL2, 512/512 grain samples and 48000 Hz. CheckedSystemOption throws on any non-zero flag, and that is where the title stops (#2171: NGS2: system option flags are not implemented).

With this change the title gets past that stop: @EdouardSence ran PPSA04540 01.009.000 on main at 8c9161eac with and without this commit (comment, follow-up). Without it the title stops on NGS2: system option flags are not implemented; with it the title loads further and stops on NGS2: custom module id 0x15 is not implemented, the custom rack gap mapped in #8039, which this PR does not address.

This change accepts bit 1 and ignores it. Every other bit still throws, and the message now names the value.

Source of the behaviour.

  • prosper's reading of the firmware's shared option validator (native core 0x1e7e0, used by sceNgs2SystemQueryBufferSize, sceNgs2SystemCreate and sceNgs2SystemCreateWithAllocator).
    • It checks the size (0x90) and then only the fields from +0x6c on: maximum grain, grain, sample rate and channel count.
    • flags sits at +0x68 (Ngs2SystemOption), and the validator does not check it.
    • prosper already backs the NGS2 handle errors in this library's debt file.
  • shadPS4's SystemSetup reads only flags >> 31, for the context buffer layout. It passes no other bit into system setup.

What bit 1 selects is unknown. It could still matter later, for example during rendering. For that reason only bit 1 is accepted, and not every value the validator lets through. Bit 31 and the other bits keep throwing, because their effect is not implemented.

Changes:

  • CheckedSystemOption masks out the known flag 0x2, following the knownFlags pattern used for waveform block flags in Voice.cpp. Any remaining bit throws NGS2: system option flags 0x… are not implemented.
  • ngs2_render, new TestSystemOptionFlags:
    • with flags = 2, the buffer size query and sceNgs2SystemCreate succeed, and a sampler voice renders its PCM unchanged through a mastering voice;
    • 0x1, 0x3, 0x4, 0x80000000 and 0x80000002 still throw.
  • docs/dev/debt/libSceNgs2.native.md: a new entry under "Unknown function info" records the accepted bit, its source, the title that passes it, and that its meaning is unknown.

Tested

Title: Rise of the Ronin (PPSA04540) 01.009.000, run by @EdouardSence on 2026-10-19 (Linux, AMD RX 9070 XT, Mesa 26.2.4 RADV; comment, follow-up). On main at 8c9161eac it stops after about 38 s (cold shader cache) on NGS2: system option flags are not implemented. With this commit cherry-picked onto the same main it loads past that point and stops after about 20 s (warm cache) on NGS2: custom module id 0x15 is not implemented (#8039, not part of this PR). @EdouardSence, if you have time, could you confirm this on the rebased head 6539598d5?

Linux (GitHub Codespace, 4 cores, native build of this branch on 02fb1ce53):

  • ngs2_render_tests, ngs2_handleerrors_tests and ngs2_custom_tests: 5/5 runs each pass.
  • Negative control: with System.cpp from main, ngs2_render_tests aborts with NGS2: system option flags are not implemented, and the other two still pass; 5/5 pass again after restoring it.
  • ctest -R ngs2_: all 13 ngs2_* tests pass.

Windows (fork CI, run 39406530313, this branch on 02fb1ce53 merged into the fork's main at d14a186f4): build and the full test suite pass, 1734/1734.

Checks:

  • python3 tools/check_conventions.py --base origin/main passes.
  • tools/progress.py: unchanged (4246/6515 on base and head).

Duplicate and overlap check

Searches of open and closed pull requests for "system option flags", CheckedSystemOption, "system option" and Ngs2SystemOption find no other change to this check.

python3 tools/pr_overlap.py --branch fix/ngs2-system-option-flag-bit1 reports no overlapping change. It could not compare drafts #1384 and #5797, which conflict with main; checked by hand: #1384 (I3DL2 reverb) changes sceNgs2SystemSetSampleRate in System.cpp, not CheckedSystemOption, and #5797 (HE-VAG) adds its debt entry at the top of the same debt section. #8238 (rack lock) was compared: it changes the locking in System.cpp, not the option check.

Checklist

  • Based on current main (02fb1ce53); 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: PPSA04540 #2171 (gets past the system option stop; next stop custom module id 0x15, #8039)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4934511744 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8341). Originally posted by [KernelPanicNT](https://github.com/KernelPanicNT) on 2026-10-20T10:36:11Z. --- ### What Rise of the Ronin (PPSA04540) creates its NGS2 system with `flags = 2` in `Ngs2SystemOption`. The other fields are name `KTSL2`, 512/512 grain samples and 48000 Hz. `CheckedSystemOption` throws on any non-zero flag, and that is where the title stops ([#2171](https://github.com/boykopovar/AnyPS5/discussions/2171): `NGS2: system option flags are not implemented`). With this change the title gets past that stop: @EdouardSence ran PPSA04540 01.009.000 on `main` at `8c9161eac` with and without this commit ([comment](https://github.com/boykopovar/AnyPS5/discussions/2171#discussioncomment-19047418), [follow-up](https://github.com/boykopovar/AnyPS5/discussions/2171#discussioncomment-19047690)). Without it the title stops on `NGS2: system option flags are not implemented`; with it the title loads further and stops on `NGS2: custom module id 0x15 is not implemented`, the custom rack gap mapped in #8039, which this PR does not address. This change accepts bit 1 and ignores it. Every other bit still throws, and the message now names the value. **Source of the behaviour.** - [prosper's reading of the firmware's shared option validator](https://github.com/mattias800/prosper/blob/9b0698b1f51258a52dc2c0d9640e02caa9fcc0fa/prosper/src/hle/audio/hle_audio.cpp#L4155-L4188) (native core `0x1e7e0`, used by `sceNgs2SystemQueryBufferSize`, `sceNgs2SystemCreate` and `sceNgs2SystemCreateWithAllocator`). - It checks the size (`0x90`) and then only the fields from `+0x6c` on: maximum grain, grain, sample rate and channel count. - `flags` sits at `+0x68` ([`Ngs2SystemOption`](https://github.com/boykopovar/AnyPS5/blob/02fb1ce5324304f292453b9dd458cea2e3633160/core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp#L106-L116)), and the validator does not check it. - prosper already backs the NGS2 handle errors in this library's debt file. - [shadPS4's `SystemSetup`](https://github.com/shadps4-emu/shadPS4/blob/cd3cc8022aef5be7766443f694e79d270544eaf4/src/core/libraries/ngs2/ngs2_impl.cpp#L126) reads only `flags >> 31`, for the context buffer layout. It passes no other bit into system setup. **What bit 1 selects is unknown.** It could still matter later, for example during rendering. For that reason only bit 1 is accepted, and not every value the validator lets through. Bit 31 and the other bits keep throwing, because their effect is not implemented. Changes: - [`CheckedSystemOption`](https://github.com/boykopovar/AnyPS5/blob/02fb1ce5324304f292453b9dd458cea2e3633160/core/libs/prx/libSceNgs2.native/src/System.cpp#L135-L144) masks out the known flag `0x2`, following the `knownFlags` pattern used for waveform block flags in `Voice.cpp`. Any remaining bit throws `NGS2: system option flags 0x… are not implemented`. - `ngs2_render`, new `TestSystemOptionFlags`: - with `flags = 2`, the buffer size query and `sceNgs2SystemCreate` succeed, and a sampler voice renders its PCM unchanged through a mastering voice; - `0x1`, `0x3`, `0x4`, `0x80000000` and `0x80000002` still throw. - `docs/dev/debt/libSceNgs2.native.md`: a new entry under "Unknown function info" records the accepted bit, its source, the title that passes it, and that its meaning is unknown. ### Tested Title: Rise of the Ronin (PPSA04540) 01.009.000, run by @EdouardSence on 2026-10-19 (Linux, AMD RX 9070 XT, Mesa 26.2.4 RADV; [comment](https://github.com/boykopovar/AnyPS5/discussions/2171#discussioncomment-19047418), [follow-up](https://github.com/boykopovar/AnyPS5/discussions/2171#discussioncomment-19047690)). On `main` at `8c9161eac` it stops after about 38 s (cold shader cache) on `NGS2: system option flags are not implemented`. With this commit cherry-picked onto the same `main` it loads past that point and stops after about 20 s (warm cache) on `NGS2: custom module id 0x15 is not implemented` (#8039, not part of this PR). @EdouardSence, if you have time, could you confirm this on the rebased head `6539598d5`? Linux (GitHub Codespace, 4 cores, native build of this branch on `02fb1ce53`): - `ngs2_render_tests`, `ngs2_handleerrors_tests` and `ngs2_custom_tests`: 5/5 runs each pass. - Negative control: with `System.cpp` from `main`, `ngs2_render_tests` aborts with `NGS2: system option flags are not implemented`, and the other two still pass; 5/5 pass again after restoring it. - `ctest -R ngs2_`: all 13 `ngs2_*` tests pass. Windows (fork CI, [run 39406530313](https://github.com/KernelPanicNT/AnyPS5/actions/runs/39406530313), this branch on `02fb1ce53` merged into the fork's `main` at `d14a186f4`): build and the full test suite pass, 1734/1734. Checks: - `python3 tools/check_conventions.py --base origin/main` passes. - `tools/progress.py`: unchanged (4246/6515 on base and head). ### Duplicate and overlap check Searches of open and closed pull requests for "system option flags", `CheckedSystemOption`, "system option" and `Ngs2SystemOption` find no other change to this check. `python3 tools/pr_overlap.py --branch fix/ngs2-system-option-flag-bit1` reports no overlapping change. It could not compare drafts #1384 and #5797, which conflict with `main`; checked by hand: #1384 (I3DL2 reverb) changes `sceNgs2SystemSetSampleRate` in `System.cpp`, not `CheckedSystemOption`, and #5797 (HE-VAG) adds its debt entry at the top of the same debt section. #8238 (rack lock) was compared: it changes the locking in `System.cpp`, not the option check. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main` (`02fb1ce53`); 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: PPSA04540 #2171 (gets past the system option stop; next stop `custom module id 0x15`, #8039) - [x] GPUs tested: n/a - [x] AI-assisted: yes
xXPBSXx commented 2026-10-21 03:09:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T03:09:47Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only ngs2_core_render_tests; ctest -N -R ngs2_core_render lists exactly one test.

Results (3 runs each):

  • PR head: ngs2_core_render passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libSceNgs2.native/src/System.cpp with the version from the PR's merge base (02fb1ce532), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's file afterwards.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307058261 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8341#issuecomment-6307058261). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T03:09:47Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` is clean. I built only `ngs2_core_render_tests`; `ctest -N -R ngs2_core_render` lists exactly one test. **Results (3 runs each):** - PR head: `ngs2_core_render` passes 3/3. - Baseline: I kept the PR's test and replaced only `core/libs/prx/libSceNgs2.native/src/System.cpp` with the version from the PR's merge base (`02fb1ce532`), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's file afterwards. **Not run:** other platforms, the other tests in the same family, the full repository CTest, and any title or console run. AI-assisted (Claude Code).
EdouardSence commented 2026-10-21 08:19:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-21T08:19:11Z.


Confirmed on the rebased head 6539598d5 (merge base 02fb1ce53), built as-is with no other PRs or local changes.

  • Title: Rise of the Ronin (PPSA04540) 01.009.000
  • Linux (CachyOS, kernel 7.2.10), RX 9070 XT, Mesa 26.2.4 RADV, GCC Release build, headless gamescope, 90 s cap
  • Result: no NGS2: system option flags are not implemented. The title loads past that point and aborts after about 38 s on:
terminate called after throwing an instance of 'std::runtime_error'
  what():  NGS2: custom module id 0x15 is not implemented

That is the same stop as on the 19th with the earlier commit, so the rebase keeps the behaviour. The 0x15 stop is the custom rack gap tracked in #8039.

Not tested: other titles, the CTest suite.


Tested and written by Claude (AI assistant) on a contributor's machine.
AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311403037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8341#issuecomment-6311403037). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-21T08:19:11Z. --- Confirmed on the rebased head `6539598d5` (merge base `02fb1ce53`), built as-is with no other PRs or local changes. - Title: Rise of the Ronin (PPSA04540) 01.009.000 - Linux (CachyOS, kernel 7.2.10), RX 9070 XT, Mesa 26.2.4 RADV, GCC Release build, headless gamescope, 90 s cap - Result: no `NGS2: system option flags are not implemented`. The title loads past that point and aborts after about 38 s on: ```text terminate called after throwing an instance of 'std::runtime_error' what(): NGS2: custom module id 0x15 is not implemented ``` That is the same stop as on the 19th with the earlier commit, so the rebase keeps the behaviour. The `0x15` stop is the custom rack gap tracked in #8039. Not tested: other titles, the CTest suite. --- *Tested and written by Claude (AI assistant) on a contributor's machine.* AI-assisted: yes
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!8341
No description provided.