A render recorded only the innermost system it was rendering, so a
destroy called from the callback of a system rendered inside another
system's callback was let through, and the outer render then used the
destroyed rack. Each system now counts the renders it is in. A destroy
first waits until no other thread holds the exclusive state, so a
non-zero count can only come from the calling thread's own stack.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A voice callback runs during its system's render. A rack or system
destroyed from that callback was freed while the render still walked
it, which corrupted the heap. sceNgs2RackDestroy and
sceNgs2SystemDestroy now throw when the calling thread is rendering
that system; the console's behaviour there is not measured.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A destroy waited only for another thread's render, so destroying a rack
that another thread had locked freed it under that lock. Destroys now
wait like renders and rack locks do, and the render owner field that
only those waits read is gone.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rack locks and renders were tracked per system, so a voice callback
that locked a rack of another system could deadlock with that system's
render, or with a thread holding rack locks in both systems. Rack locks
and renders now exclude each other across threads and systems, as the
single internal lock did, while a thread nests them and other calls go
ahead.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A voice callback runs with the internal lock released, so another
thread could lock the rack being rendered and the render then finished
it under that lock. sceNgs2RackLock now also waits while another thread
renders the rack's system, as it did when the rack lock was the
internal lock.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sceNgs2RackLock took the library's internal recursive mutex and kept it
until sceNgs2RackUnlock, and a render held the same mutex while it called a
voice's block-end or repeat callback. Every NGS2 call from another thread
waited behind either one. A title that takes one of its own locks while it
holds a rack lock (or inside the callback), while another of its threads
holds that lock and calls sceNgs2VoiceGetStateFlags, deadlocks.
A rack lock is now an owner and a depth on the rack, and only a render of
its system waits for another thread's rack lock. The voice callback runs
with the internal lock released (the lock depth is tracked per thread so it
is released fully and taken back after). A rack or system destroy waits
while another thread renders its system, as the callback window would
otherwise let it free what the render still walks.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sceNgs2ReportRegisterHandler and sceNgs2ReportUnregisterHandler stop
being throwing stubs: they keep a registry of report handlers, so a
title that imports them can register and later drop its handler.
Register rejects a null handler with an invalid argument and returns
INVALID_OUT_ADDRESS for a null out handle, then stores the report
type, handler and user data under a freshly allocated opaque handle.
Unregister removes and frees the matching record and throws for a
handle that is not registered.
The signatures follow SharpProspero and shadPS4's ngs2_report.h, and
the 24-byte Ngs2ReportDataHeader passed to a handler is its
OrbisNgs2ReportDataHeader. No report is produced yet, so no registered
handler is ever invoked.
PPSA15552 passes matching front/up after a listener move; pick a perpendicular up hint instead of throwing so Dead Cells can keep running.
Co-authored-by: Cursor <[email protected]>
Implement sceNgs2GeomApply, which was previously an unimplemented
throwing stub and was blocking Dead Cells (PPSA15552).
The implementation validates null handles/output addresses and writes a
minimal Ngs2GeomAttribute: pitch_ratio 1.0, source position, source
volume/level maxima, and diagonal channel levels for the source's channel
count. It does not implement source attenuation, distance rolloff, panning
or Doppler.
The export lives in Geom.cpp's internal Ngs2GeomApply and is exposed through
the existing default-visibility wrapper in Voice.cpp. Unimplemented.cpp no
longer defines the stub. A passing test was added to Ngs2Geom.cpp.
Unblocks: PPSA15552 #<Game bring-up discussion number>
Depends on: none
AI assistance: yes
Allow custom voice filter type 0 to clear the destination filter,
matching the sampler filter convention. Type 1 continues to configure
the biquad frequency, Q and level. Other unsupported filter types
still throw.
This follows the listener-transform support in
fix/libSceNgs2-listener-transform and is needed for Dead Cells
(PPSA15552), which reaches this path after the custom sampler rack.
Depends on: fix(libSceNgs2): support listener transforms in sceNgs2GeomCalcListener- #5810
Unblocks: PPSA15552
AI assistance: yes
Restore world-to-listener matrix construction instead of rejecting
non-default orientation, translation or flags.
- Build an orthonormal row-major matrix from position, orient_front
and orient_up; apply the right-handed axis flip for flag 1.
- Store the negated dotted translation in each matrix row.
- Validate unknown flags, invalid or non-finite input, short
orientation axes, and unrepresentable translation without changing
the output.
- Preserve finite velocity and positive finite sound speed.
- Update NGS2 geometry tests and the libSceNgs2 technical debt note.
AI assistance: yes
A sampler voice set up with an all-zero format has no channels. Adding no
waveform blocks to it, or setting a matrix with no levels, threw
std::invalid_argument, which ends the title.
Accept both on such a voice: the empty add only applies RESET and the
CONTINUE state, and the empty matrix clears that matrix, which rendering
already treats as unset. Blocks with data, APPEND, and an empty matrix on
a voice with a format are still refused.
Steins;Gate Re:Boot (PPSA36591) clears a voice this way when a button is
pressed at its title screen.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An index at or beyond the rack's voice count returned through
APS5_INVALID_ARG_EX, which throws and ends the process. Heretic + Hexen
(PPSA26525) creates a one-voice reverb rack, takes voice 0 and asks for
voice 1 at start-up, so it stopped at 1.5 s on
"sceNgs2RackGetVoiceHandle: invalid argument". Return 0x804A8305 and
leave the output handle untouched, after the existing null-output and
rack-handle checks. The value follows prosper's analysis of
libSceNgs2.native.sprx; shadPS4 lists 0x804A0302 for the PS4 library.
Neither is a PS5 measurement, recorded in the technical debt.
ngs2_voiceindex creates one-voice sampler, submixer, mastering and
reverb racks and a default sampler rack, and checks the error, the
untouched output, the null-output and invalid-rack codes and that the
last valid index still resolves afterwards. It aborts on main's library
with the throw above and passes with this change.
Accept SCE_NGS2_CUSTOM_MODULE_ID_USER_FX (0x1d) on custom submixer racks alongside UserFx2 (0x1f). When configuring a custom rack voice, support voice control parameter SCE_NGS2_CUSTOM_VOICE_PARAM_USER_FX (0x40001d00) to install custom submixer UserFx callbacks with user data. Run legacy UserFx callbacks during custom voice rendering and update sample presence flags accordingly.
Fixes runtime abort in Void Terrarium (PPSA03061):
terminate called after throwing an instance of 'std::runtime_error'
what(): NGS2: custom module id 0x1d is not implemented
FATAL: abort() (SIGABRT)
Closes#5055
Dead Cells (PPSA15552) calls sceNgs2VoiceGetState on custom sampler
voices with a 48-byte buffer and reads the 64-bit value at offset 16 as
a running counter. Fill it with the decoded sample count, keep the
common state flags, and return INVALID_OUT_SIZE for other sizes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>