feat(ngs2): custom submixer rack with UserFx2 modules #781
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/781"
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 adriadam10 on 2026-10-05T23:29:15Z.
What
NGS2 custom submixer rack (
0x4002) whose modules are all UserFx2 (title-supplied effect callbacks). Before this,sceNgs2RackQueryBufferSize/sceNgs2RackCreatethrew for any custom rack id.ngs2_custom.h/ngs2.h(SDK-style headers). KytyPS5's structs have the same sizes (72/72/104/40 bytes), checked withstatic_assert.src/libs/ngs2.cpp), the only reference with a body:0x1f= UserFx2;setup_handleris called for every voice of every module at rack creation (common/param/work buffers sized from the option,max_voices,voice_index,user_data);cleanup_handlerfor every voice at rack destruction (also fromsceNgs2SystemDestroy).0x40001f00 | module indexcopiesdatainto the module's param buffer (size must equalparam_size) and sets process flag 2 for the next process call; the flag is cleared after it.process_handlerruns in order on the voice's channels in place (input = output channels, grain, system sample rate, per-module state buffer ofstate_size). Nothing is processed when no input produced samples.0x40020000sets the channel count (input must equal output).EXIT_NOT_IMPLEMENTEDor not covered there): other module ids,num_buffers != 1, module/port buffer ids other than 0, a modulecontrol_handlerwhen its param is set, input != output channels, setup flags, a null rack option (default custom options), a handler returning non-zero,sceNgs2VoiceGetStateon this rack. Nullprocess_handler, wrong module option size, too many modules/ports and out-of-range module index or channel count are invalid arguments.ParamAsmoved fromVoice.cpptoNgs2Internal.hppsoCustom.cppuses the same check.state_offsetslice of the voice state.Port delay, reverb rack and submixer filters/envelopes were checked too: KytyPS5 only logs or ignores them and no other reference has a body, so they stay throwing.
Tested
Linux, GCC Release (
-O3) and the fast build. Newngs2_customtest (registered in ctest): two UserFx2 modules on a sampler → custom submixer → mastering chain, pins the rendered samples (gain from param, offset from common, module order), setup/cleanup call order per voice and module, the process flag (0, 2 after a param update, then 0), and every throwing/invalid path above. It fails onmain(rack id0x4002throws). 18 mutations of the implementation (process call, flag set/clear, setup, cleanup, per-module common, each validation) each make the test fail.ngs2_render,ngs2_atrac9and allguest_*tests pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)foreachline as #778; whichever merges second gets a one-word rebase)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T23:29:38Z.
Progress report (
481c85e→5a031f3)📈 System libraries: 82.34% (+0.03%, +5 implemented functions)
✅ 5 implemented
CleanupControlHandlerGainOffsetSetupImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T01:12:37Z.
Thanks. The layouts match shadPS4's
ngs2.h/ngs2_custom.h(contexts 72/72/72/104, module option 72, module info 40, the submixer setup and UserFx2 params 24), and the handler typedefs useAPS5_VABIlike the existing allocator and voice callbacks, so the calls are right on Windows too.One difference from KytyPS5, which the PR follows for the behaviour: its per-voice module state starts with
flags = 1(struct Module { ... uint32_t flags = 1; }insrc/libs/ngs2.cpp). So the firstprocess_handlercall after setup sees 1, later calls see 0, and the call after a param change sees 2 (module.flags |= 2, thenmodule.flags = 0after the call). HereNgs2UserFx2::flagsstarts at 0 (Ngs2Internal.hpp:61), andNgs2Custom.cpppins{0}and{0, 2, 0}. If the first-call bit is what tells an effect to initialise itswork/state, an effect would start on uninitialised buffers. Could you start at 1 and pin{1}and{1, 2, 0}?Minor: process runs only when an input produced samples (as in KytyPS5), so an effect tail stops and a pending flag 2 waits for the next audible grain. That's worth a few words in the TechnicalDebt entry. This also conflicts with #778 on the
foreachline inlibSceNgs2.native/CMakeLists.txt(FiltervsCustom). Whichever lands second only needs both names.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T05:17:47Z.
Fixed, thanks:
Module::flags = 1); the test pins{1}and{1, 2, 0}(fails if the init is removed).main. Theforeachconflict with #778 stays: whichever lands second needs both names.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T05:40:45Z.
Rebased on main after #778: the only conflict was the test
foreachline, nowRender Atrac9 Filter Custom. ngs2_render/atrac9/filter/custom pass (Release, GCC).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T09:27:54Z.
Thanks, that covers both points: the flags start at 1 at setup and the test pins
{1}and{1, 2, 0}, and the TechnicalDebt entry now lists the flags and the process-only-on-audible-grains behaviour. The feature commit is unchanged apart from the #778 context, and it merges cleanly with main.