feat(libSceNgs2): support default listener calculation #4598

Merged
Lorkydey merged 2 commits from upstream-pr/4598 into main 2026-10-12 23:56:18 +00:00
Lorkydey commented 2026-10-12 16:31:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-12T16:31:20Z.


What

Dead Cells (PPSA15552) reaches sceNgs2GeomCalcListener not implemented after its custom sampler rack is supported, as reported in #4334.

Implement only the default listener case: position (0, 0, 0), front (0, 0, 1), up (0, 1, 0) and flags 0. Write the identity matrix, preserve finite velocity and positive finite sound speed, and initialize the complete work structure. Any other position, orientation (including non-unit vectors) or flags throws before touching the output. Nonfinite inputs and nonpositive sound speed also throw; a null output returns the existing NGS2 invalid-address error.

This adopts the restricted option requested in review. The previous normalization, handedness and translation calculations have been removed. The default result follows KytyPS5's implementation and PS5PCEM's model for this case; neither is claimed as a PS5 measurement. The broken investigation link has been replaced by the actual source, and the unsupported cases and remaining uncertainties are recorded in docs/dev/debt/libSceNgs2.native.md.

sceNgs2GeomApply still throws. Source attenuation, panning, Doppler and custom-rack support are outside this change. Dead Cells' listener arguments have not been captured here, and the narrowed implementation has not been run on the title: the linked report establishes the call is reached, not that this restricted case is sufficient for the game.

Tested

Validated head dadc23a8c19b0d42b15e6f593257d8a0c2da612e, rebased onto main 7940cacd834f06012e2678189316cc9dee85b6fd:

  • Local Windows 11 Pro 26100, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON: all runtime libraries (libs) and the 10 NGS2 targets built; all ngs2_* tests passed three times (30 successful executions, 2.31 s total).
  • Linux and Windows validation, checking out that exact source commit: all 10 NGS2 targets built and all 10 tests passed three times on each OS (30 successful executions per OS).
  • Negative controls retain the new tests: main's Geom.cpp, Voice.cpp and Unimplemented.cpp fail at the unimplemented call; the previous PR's Geom.cpp at dd087ce36 fails the new rejection test. Both failures were verified on Linux and Windows, then the updated sources were restored and all tests passed.
  • Regression coverage: exact identity, velocity/sound-speed preservation, initialized output fields, signed zero, non-default positions/orientations in every component (including adjacent float values), nonzero flags, invalid/nonfinite inputs and unchanged output on rejection.
  • Conventions, test registration and git diff --check pass.

This is focused NGS2 validation, not a full test-suite or title run. The validation workflow is on a separate fork CI branch.

The upstream eligibility job failed before building with API rate limit exceeded for installation. The focused Linux/Windows validation linked above and the upstream conventions check passed. Rerunning the failed upstream job requires repository permissions this fork account does not have.

Overlap coordination

Coordination with #4254 and #4788: pairwise simulations conflict only in docs/dev/debt/libSceNgs2.native.md. The proposal is this PR first after review, followed by rebases preserving the default-listener limits, custom-sampler entry and voice-index entry. Agreement is pending; if either other PR lands first, this PR will instead be rebased and the checklist updated for that order. The stale claim that listener calculation is wholly unimplemented must be removed while preserving the sceNgs2GeomApply limitation. The checklist currently declares no prerequisite; no combined runtime validation is claimed.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: no third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA15552 #4334 (reported listener-calculation stop; default-listener calls only, title arguments and the narrowed change not yet validated)
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832248240 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4598). Originally posted by [Lorkydey](https://github.com/Lorkydey) on 2026-10-12T16:31:20Z. --- ### What Dead Cells (PPSA15552) reaches `sceNgs2GeomCalcListener not implemented` after its custom sampler rack is supported, as reported in [#4334](https://github.com/boykopovar/AnyPS5/issues/4334#issuecomment-6125105483). Implement only the default listener case: position `(0, 0, 0)`, front `(0, 0, 1)`, up `(0, 1, 0)` and flags `0`. Write the identity matrix, preserve finite velocity and positive finite sound speed, and initialize the complete work structure. Any other position, orientation (including non-unit vectors) or flags throws before touching the output. Nonfinite inputs and nonpositive sound speed also throw; a null output returns the existing NGS2 invalid-address error. This adopts the restricted option requested in [review](https://github.com/boykopovar/AnyPS5/pull/4598#pullrequestreview-5495942896). The previous normalization, handedness and translation calculations have been removed. The default result follows [KytyPS5's implementation](https://github.com/KytyPS5/KytyPS5/blob/df5b9b92be7dfd463b47756b707d6d356a9f0550/src/libs/ngs2.cpp) and [PS5PCEM's model](https://github.com/iStark/PS5PCEM/blob/d2534bac6325a2c61c0fa88977e5321074304484/src/hle/ngs2_geom.zig) for this case; neither is claimed as a PS5 measurement. The broken investigation link has been replaced by the actual source, and the unsupported cases and remaining uncertainties are recorded in `docs/dev/debt/libSceNgs2.native.md`. `sceNgs2GeomApply` still throws. Source attenuation, panning, Doppler and custom-rack support are outside this change. Dead Cells' listener arguments have not been captured here, and the narrowed implementation has not been run on the title: the linked report establishes the call is reached, not that this restricted case is sufficient for the game. ### Tested Validated head `dadc23a8c19b0d42b15e6f593257d8a0c2da612e`, rebased onto main `7940cacd834f06012e2678189316cc9dee85b6fd`: - Local Windows 11 Pro 26100, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`: all runtime libraries (`libs`) and the 10 NGS2 targets built; all `ngs2_*` tests passed three times (30 successful executions, 2.31 s total). - [Linux and Windows validation](https://github.com/Lorkydey/AnyPS5/actions/runs/38309290830), checking out that exact source commit: all 10 NGS2 targets built and all 10 tests passed three times on each OS (30 successful executions per OS). - Negative controls retain the new tests: main's `Geom.cpp`, `Voice.cpp` and `Unimplemented.cpp` fail at the unimplemented call; the previous PR's `Geom.cpp` at `dd087ce36` fails the new rejection test. Both failures were verified on Linux and Windows, then the updated sources were restored and all tests passed. - Regression coverage: exact identity, velocity/sound-speed preservation, initialized output fields, signed zero, non-default positions/orientations in every component (including adjacent float values), nonzero flags, invalid/nonfinite inputs and unchanged output on rejection. - Conventions, test registration and `git diff --check` pass. This is focused NGS2 validation, not a full test-suite or title run. The validation workflow is on a separate fork CI branch. The upstream [eligibility job](https://github.com/boykopovar/AnyPS5/actions/runs/38309905718/job/115012801128) failed before building with `API rate limit exceeded for installation`. The focused Linux/Windows validation linked above and the upstream conventions check passed. Rerunning the failed upstream job requires repository permissions this fork account does not have. ### Overlap coordination [Coordination with #4254 and #4788](https://github.com/boykopovar/AnyPS5/pull/4598#issuecomment-6134805816): pairwise simulations conflict only in `docs/dev/debt/libSceNgs2.native.md`. The proposal is this PR first after review, followed by rebases preserving the default-listener limits, custom-sampler entry and voice-index entry. Agreement is pending; if either other PR lands first, this PR will instead be rebased and the checklist updated for that order. The stale claim that listener calculation is wholly unimplemented must be removed while preserving the `sceNgs2GeomApply` limitation. The checklist currently declares no prerequisite; no combined runtime validation is claimed. ### 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 - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source: no third-party code added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA15552 #4334 (reported listener-calculation stop; default-listener calls only, title arguments and the narrowed change not yet validated) - [x] AI-assisted: yes (Codex)
github-actions[bot] commented 2026-10-12 16:48:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T16:48:57Z.


Progress report (2fabe44 → dd087ce)

📈 System libraries: 87.43% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceNgs2.native sceNgs2GeomCalcListener
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6128658346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4598#issuecomment-6128658346). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T16:48:57Z. --- <!-- progress-report --> ### Progress report (2fabe44 → dd087ce) 📈 **System libraries**: 87.43% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceNgs2.native | `sceNgs2GeomCalcListener` | </details>
github-actions[bot] commented 2026-10-12 21:06:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T21:06:18Z.


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
#4254 docs/dev/debt/libSceNgs2.native.md L25
#4788 docs/dev/debt/libSceNgs2.native.md L25
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132607519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4598#issuecomment-6132607519). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T21:06:18Z. --- <!-- 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 | |---|---|---|---| | #4254 | `docs/dev/debt/libSceNgs2.native.md` [L25](https://github.com/boykopovar/AnyPS5/blob/056d17ecc5978492ae8d858bf810312de81ddae8/docs/dev/debt/libSceNgs2.native.md#L25) | | | | #4788 | `docs/dev/debt/libSceNgs2.native.md` [L25](https://github.com/boykopovar/AnyPS5/blob/056d17ecc5978492ae8d858bf810312de81ddae8/docs/dev/debt/libSceNgs2.native.md#L25) | | |
adriadam10 commented 2026-10-12 21:06:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:06:21Z.

Review: DISMISSED


Thanks, the code is clean and the test fails without the change (checked: ngs2_geom passes on the PR, fails with the sources reverted to main).

One blocker, per the exact-or-throw rule:

  • The transform convention (row-major right/up/front rows, translation -dot(axis, position), flag 1 = right-handed, cross order) rests only on PS5PCEM's own model. The docs/development/dead-cells-ngs2-2026-10-11.md link in the body and in docs/dev/debt/libSceNgs2.native.md:26 returns 404 at the pinned commit (only src/hle/ngs2_geom.zig exists there, which is another emulator's implementation, not a measurement). The other references disagree: KytyPS5 Ngs2GeomCalcListener writes an identity matrix, prosper zeroes the 0x60-byte work. They only agree on the default listener (identity).

What would fix it, either:

  • restrict the implementation to what is supported: default orientation (front +Z, up +Y, left-handed) giving the identity plus the preserved velocity/sound speed, and throw for any other orientation, flag or translation (listing them in TechnicalDebt), or
  • give evidence for the convention (a title's call site/disassembly showing how the work matrix is consumed by sceNgs2GeomApply, or a PS5 measurement) and fix the link.

Also, the new TechnicalDebt entry ends with a period, unlike its neighbours (docs/dev/debt/libSceNgs2.native.md:26).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5495942896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4598#pullrequestreview-5495942896). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:06:21Z. **Review:** DISMISSED --- Thanks, the code is clean and the test fails without the change (checked: `ngs2_geom` passes on the PR, fails with the sources reverted to main). One blocker, per the exact-or-throw rule: - The transform convention (row-major right/up/front rows, translation `-dot(axis, position)`, flag 1 = right-handed, `cross` order) rests only on PS5PCEM's own model. The `docs/development/dead-cells-ngs2-2026-10-11.md` link in the body and in `docs/dev/debt/libSceNgs2.native.md:26` returns 404 at the pinned commit (only `src/hle/ngs2_geom.zig` exists there, which is another emulator's implementation, not a measurement). The other references disagree: KytyPS5 `Ngs2GeomCalcListener` writes an identity matrix, prosper zeroes the 0x60-byte work. They only agree on the default listener (identity). What would fix it, either: - restrict the implementation to what is supported: default orientation (front +Z, up +Y, left-handed) giving the identity plus the preserved velocity/sound speed, and throw for any other orientation, flag or translation (listing them in TechnicalDebt), or - give evidence for the convention (a title's call site/disassembly showing how the work matrix is consumed by `sceNgs2GeomApply`, or a PS5 measurement) and fix the link. Also, the new TechnicalDebt entry ends with a period, unlike its neighbours (`docs/dev/debt/libSceNgs2.native.md:26`).
Lorkydey commented 2026-10-12 21:31:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-12T21:31:36Z.


@adriadam10 Thanks for the review! Updated in dadc23a8c: only the default listener at the origin with flags 0 is accepted now. Other orientations, translations and flags throw without modifying the output. I also fixed the reference link and updated TechnicalDebt.
All 10 NGS2 tests pass three times on both Windows and Linux, and the new rejection tests fail against the previous implementation.
The upstream eligibility check hit GitHub’s API rate limit; details are in the PR description. Ready for another look when you have time :)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132988998 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4598#issuecomment-6132988998). Originally posted by [Lorkydey](https://github.com/Lorkydey) on 2026-10-12T21:31:36Z. --- @adriadam10 Thanks for the review! Updated in dadc23a8c: only the default listener at the origin with flags 0 is accepted now. Other orientations, translations and flags throw without modifying the output. I also fixed the reference link and updated TechnicalDebt. All 10 NGS2 tests pass three times on both Windows and Linux, and the new rejection tests fail against the previous implementation. The upstream eligibility check hit GitHub’s API rate limit; details are in the PR description. Ready for another look when you have time :)
Lorkydey commented 2026-10-12 23:48:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-12T23:48:03Z.


@MarcZX100 @PrintOrb Coordinating the debt-file overlap with #4254 and #4788.

Pairwise merge simulations of #4598 (dadc23a8c) with #4254 (b0524d092) and #4788 (a9fe4ac4e) conflict only in docs/dev/debt/libSceNgs2.native.md. The implementations cover different functions.

The resolution should retain the restricted default-listener entry from this PR and both the custom-sampler and voice-index entries from yours, with a single Functional heading. The reset-parameter paragraph must no longer call sceNgs2GeomCalcListener wholly unimplemented; its supported case and limitations belong in the separate listener entry. sceNgs2GeomApply remains unimplemented.

I propose #4598 first once its pending review is cleared, followed by rebases of the debt entries in your PRs. Would that work? If either of yours is ready first, I can rebase this one instead and record the agreed order in Depends on. No runtime dependency or combined runtime validation is implied by this documentation conflict.

AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134805816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4598#issuecomment-6134805816). Originally posted by [Lorkydey](https://github.com/Lorkydey) on 2026-10-12T23:48:03Z. --- @MarcZX100 @PrintOrb Coordinating the debt-file overlap with #4254 and #4788. Pairwise merge simulations of #4598 (`dadc23a8c`) with #4254 (`b0524d092`) and #4788 (`a9fe4ac4e`) conflict only in `docs/dev/debt/libSceNgs2.native.md`. The implementations cover different functions. The resolution should retain the restricted default-listener entry from this PR and both the custom-sampler and voice-index entries from yours, with a single `Functional` heading. The reset-parameter paragraph must no longer call `sceNgs2GeomCalcListener` wholly unimplemented; its supported case and limitations belong in the separate listener entry. `sceNgs2GeomApply` remains unimplemented. I propose #4598 first once its pending review is cleared, followed by rebases of the debt entries in your PRs. Would that work? If either of yours is ready first, I can rebase this one instead and record the agreed order in `Depends on`. No runtime dependency or combined runtime validation is implied by this documentation conflict. AI-assisted: yes (Codex).
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!4598
No description provided.