feat(libSceNgs2): support custom rack module id 0x1d (UserFx) and legacy callback dispatch #5140
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5140"
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 pushkarreddyy on 2026-10-13T12:45:14Z.
What
Supports SCE_NGS2_CUSTOM_MODULE_ID_USER_FX (x1d) on custom submixer racks alongside UserFx2 (x1f). Custom submixer voice parameter SCE_NGS2_CUSTOM_VOICE_PARAM_USER_FX (x40001d00 | module index) installs legacy UserFx process callbacks and 3 user data pointers per voice (Ngs2CustomVoiceUserFxParam).
During planar mixing, custom UserFx callbacks are executed with planar mixed samples, honoring initial (lags = 1) and parameter change (lags = 2) state machine transitions, updating sample presence. Modules support optional header validation (Ngs2CustomModuleOption) while rejecting malformed or truncated module options and out-of-range module indices.
Crash Log (Rule 4B):
ext [libc] unhandled exception 'St13runtime_error' thrown from 00007ffaaae172ea terminate called after throwing an instance of 'std::runtime_error' what(): NGS2: custom module id 0x1d is not implemented FATAL: abort() (SIGABRT)Closes #5055
Tested
Checklist
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T13:04:24Z.
I noticed open PR #5139 also implements custom module ID
0x1dand the0x40001d00voice parameter. The approaches differ: this PR aliases theUserFxmodule option to theUserFx2layout and routes its parameter through theUserFx2setter; #5139 adds a separate legacyUserFxcallback/data path and exercises it during rendering.These may represent different supported option forms, but they overlap in module and parameter handling. Could the two authors compare the exact option and callback ABI used by Void Terrarium before treating the changes as independent? I haven’t verified that ABI from the title binary. #5139 reports legacy callback execution tests; this PR reports module/parameter validation tests.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T13:14: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)core/libs/prx/libSceNgs2.native/src/Custom.cppL26, L46, L49-62, L132, L138-139, L142-150core/libs/prx/libSceNgs2.native/src/Ngs2Internal.hppL103, L130core/libs/prx/libSceNgs2.native/tests/Ngs2Custom.cppL341, L346docs/dev/debt/libSceNgs2.native.mdL15ProcessLegacyImported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T13:27:57Z.
Thanks @MarcZX100 for the thorough analysis.
I've updated this PR to eliminate the alias and implement the dedicated legacy
UserFxcallback ABI and rendering path:Option & Callback ABI:
0x1d(SCE_NGS2_CUSTOM_MODULE_ID_USER_FX) can passnullptror anNgs2CustomModuleOptionheader (at least 8 bytes), unlike0x1fwhich requires the 72-byteNgs2CustomUserFx2ModuleOptioncontext table.0x40001d00 | indexinstallsNgs2CustomVoiceUserFxParam(40 bytes: header, callback pointer, and 3 user data pointers), matching the legacyshadPS4/ Orbis / Prospero UserFx dispatch model.Ngs2ProcessUserFx, the legacy handler is invoked per-grain withNgs2UserFxProcessContext, updatinghasSamplesand honoring the flag progression (flag1on setup, flag2on parameter change, flag0on continuation).Combined Coverage:
TestCustomLegacyUserFxinNgs2Custom.cppexercising live callback execution, planar channel buffers, and flag transitions during audio rendering.Cleanly rebased, verified with
check_conventions.py(0 findings, 0 comments in C++), and all CI checks are green.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T15:35:49Z.
Windows test result: merged on its own onto current
mainc35bc4b92(clean merge, Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2),ngs2_customaborts with "NGS2 check failed at line 284" (core/libs/prx/libSceNgs2.native/tests/Ngs2Custom.cpp:Require(state.calls == 1 && state.flags == 1)after the firstRenderin the legacy UserFx test), whilengs2_custompasses on plainmainc35bc4b92. The description lists what the tests cover but not where they were run. I did not look into why the legacy callback does not end up with one call and flag 1 here. (Also: #5139 adds the same module 0x1d and the two heads conflict with each other.)AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T15:52:29Z.
@xXPBSXx Thanks for catching this and running the Windows MinGW build test!
1. Root Cause & Fix for
line 284In
Render.cpp(RenderVoice),Ngs2ProcessUserFxhad an outer guard:Because the legacy UserFx test sets up a generator callback without inputs patched into the submixer voice (
MixInputshas no sources),voice.hasSamplesstarted asfalse, skippingNgs2ProcessUserFxentirely during render and leavingstate.calls == 0.Inside
Ngs2ProcessUserFx:USER_FX2(0x1f) already enforces its own innerif (!voice.hasSamples) continue;check.USER_FX(0x1d) executes the callback and updatesvoice.hasSamplesafter planar samples are produced.Removing the outer
if (voice.hasSamples)guard inRender.cppallows legacy generator callbacks to execute, advancingstate.calls == 1 && state.flags == 1properly.2. Status & Overlap
9fbad86b8, cleanly rebased on currentmain(27477e5f4). All conventions and CI checks are green.0x1doverlap. This PR adds the legacy dispatch path, custom submixer rack creation/validation, and unit test coverage inNgs2Custom.cpp. Ready to adapt or consolidate however maintainers prefer!Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T19:16:25Z.
Thanks for tracing the failure to RenderVoice’s outer hasSamples guard and removing it so the legacy generator callback can produce samples. That change matches the line-284 failure report. The current PR checks show conventions/eligibility/report passing, while platform build jobs are skipped; could you report a Windows ngs2_custom rerun on head 0393546 after this fix? The earlier independent Windows run failed before 9fbad86.
Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T20:04:42Z.
Void Terrarium (PPSA03061) creates a custom submixer rack with one module
0x1dwhose option is 20 bytes (00000014 00000000 00000004 447a0000 00000000), and this PR accepts it. #5139 rejects that size withNgs2CheckCustomRack: invalid argument. Details in https://github.com/boykopovar/AnyPS5/issues/5055#issuecomment-6154121860Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T20:17:17Z.
Thanks for recording the 20-byte
0x1dsubmixer option and the contrast with #5139. That gives the PR a concrete title-level case in addition to its unit coverage; I’ve noted the integration result on #5055.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-14T02:13:22Z.
Rebased cleanly on latest
origin/main(016db923a) resolving the merge conflict with #5139.Both
0x13(Filter) and0x1d(UserFx) custom module options and tests are unified and passing. Calling on @MarcZX100 and @oneandonlydean for merge clearance alongside #5219.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-14T02:14:39Z.
Rebased cleanly on latest
origin/main(016db923a) resolving the merge conflict with #5139.Both
0x13(Filter) and0x1d(UserFx) custom module options and tests are unified and passing. Calling on @MarcZX100 and @oneandonlydean for merge clearance alongside #5219.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:34:03Z.
Thanks for this. #5139 adds the same module and now also accepts the 20-byte option PPSA03061 passes, so we're going on with that one. This head also declares
customModuleIdstwice inNgs2Rackafter the rebase, so it doesn't build. If something here is still missing from #5139, please reopen with the case.Pull request closed