feat(libSceNgs2): implement the Geom family #1021
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1021"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T00:41:05Z.
What this does
Implements the four
sceNgs2Geom*exports, which are the whole Geom (3D listener/sourcegeometry) family of
libSceNgs2.native. All four calledNotImplemented_nid_no_patch, soany title that used them terminated.
sceNgs2GeomResetListenerParamsceNgs2GeomResetSourceParamsceNgs2GeomCalcListenersceNgs2GeomApplyAlso fixes the structures those exports take. They were opaque
reserved[]placeholdersand the wrong size:
Ngs2GeomAttributeheld 128 bytes where the real structure is 308,and
Ngs2GeomListenerParam128 where it is 60. They now carry the real fields with the sizeasserted next to each one, as the rest of the header does.
Where the behaviour comes from
KytyPS5's
src/libs/ngs2.cppis the only source thatimplements them. shadPS4's
ngs2_geom.hconfirmsthe structures field for field, but its four implementations only log and return success
without writing the output — so a title would read back whatever it left in its buffer.
KytyPS5 is already the reference this project cites for NGS2 (the sampler filter and the
custom rack), so it is the source used here.
The port is value for value: the reset defaults, the identity matrix,
343when the paramcarries no sound speed,
flags & 1for the coordinate,std::max(min_level, max_level)forthe volume, and the level diagonal at
max_level(or1when it is zero) formatrix_formatchannels (
2when it is zero, clamped to the eight the level matrix holds).Two deliberate divergences from KytyPS5, both noted for the reviewer:
INVALID_OUT_ADDRESSinstead of throwing, matching howthe rest of
libSceNgs2.nativesignals it (Atrac9.cpp), and a null input throws.sceNgs2GeomApplyignores the listener work, as KytyPS5 does — the source is not placedrelative to the listener. That is recorded as technical debt rather than invented.
Verification
./build/tests/ngs2_geom_testspasses, and the full suite is green.identity matrix and the velocity/sound speed copy, the coordinate flag, the volume, the
level diagonal for
matrix_format0 / 2 / 8 / 99, and the null-argument paths.orient_front.zto0.5)aborts it, and dropping the reference's
listener == nullptrcheck aborted it duringdevelopment — it caught that omission.
static_asserts fix the eight structure sizes at compile time, andnm -Dshows all foursymbols exported from
libSceNgs2.native.prx.Caveats
hardware oracle for them. Recorded in
docs/dev/TechnicalDebt.md.is not observable from the output, because GCC proves the out-of-range iterations are
undefined behaviour and deletes them. The assertion on the surrounding fields documents the
contract but will not catch its removal on this toolchain.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T00:41:30Z.
Progress report (
ee391a5→941344f)📈 System libraries: 86.76% (+0.14%, +4 implemented functions)
✅ 4 implemented
sceNgs2GeomApplysceNgs2GeomCalcListenersceNgs2GeomResetListenerParamsceNgs2GeomResetSourceParamImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T00:43:29Z.
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.
main)docs/dev/TechnicalDebt.mdL163core/libs/prx/libSceNgs2.native/CMakeLists.txtL3core/libs/prx/libSceNgs2.native/src/Unimplemented.cppL11-58core/libs/prx/libSceNgs2.native/CMakeLists.txtL1-20docs/dev/TechnicalDebt.mdL163Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-07T01:48:02Z.
Thanks for the careful write-up, and for checking the structure sizes against two sources.
I'm closing this one for now, for two reasons:
NotImplementedwith the function name.sceNgs2GeomApplyreturns success without placing the source relative to the listener, so a title that uses 3D sound would get a plausible but wrong mix and no error. The project's rule is that a function does exactly what it should or throws, and that's harder to keep when the only reference (KytyPS5) is itself a placeholder. The reset functions alone would be easier to justify, but they still need a title.If a title stops at one of these calls on main, please reopen it (or open a new PR) with the title ID and the log line. If that title only needs the reset functions, or only reads the defaults back, a smaller PR with just those, and
Applyleft throwing, would be the easiest to merge.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T17:59:56Z.
A title for this, as asked in the closing comment: Dead Cells (PPSA15552). On
mainit first stops on the custom sampler rack id (#3553, #3793); with #3793's head on top ofmaina11c8f7f7(Windows, 60 s) it creates its racks and then aborts withso the reset call comes before any voice parameter. I have not seen it call the other three Geom functions yet, because it stops here first.
On the sources for the defaults, since the reset values are what the title would read back:
Ngs2GeomResetSourceParam) and iStark/PS5PCEM (src/hle/ngs2_geom.zig,resetSource) agree on every field: direction(0,0,1), cone levels 1 and angles 360, rolloff model 0 with max distance 1000000, factor 1, reference distance 1, Doppler factor 1, levelsfbw 1,lfe 1,max 1,min 0,num_speakers 2. They differ onmatrix_format: 2 in KytyPS5, 1 in PS5PCEM. Listener reset: front(0,0,1), up(0,1,0), sound speed 343 in both.hle_audio.cppzero-fills 0xa8 bytes for the source and 0xa0 for the listener, which does not match the 308-byte attribute and 60-byte listener sizes this PR used, so I would not take sizes from it.matrix_format(and the sizes) remain unconfirmed. A reset-only PR as suggested would have to take a side onmatrix_format, or throw for that field's case; I am not opening one until there is a measurement or the title shows which value it reads.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T21:16:35Z.
This can be reopened once #3793 is in and Dead Cells (PPSA15552) reaches
sceNgs2GeomResetSourceParamon main.Pull request closed