feat(libSceNgs2): add custom sampler and custom mastering racks #3793
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3793"
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 Techx3 on 2026-10-11T16:44:20Z.
Add the custom sampler (0x4001) and custom mastering (0x4003) racks on top of the custom submixer support:
Seen on PPSA15552 (Dead Cells), which creates both racks at start-up. (It also patches voices to a rack handle, which still fails and is not part of this change.)
Tests cover both racks in tests/Ngs2Custom.cpp.
Claude-Session: https://claude.ai/code/session_017Dqgm9nUKygsXzr6poJsHJ
What
Adds the NGS2 custom sampler (
0x4001) and custom mastering (0x4003) racks next to the existing custom submixer:Ngs2CustomSamplerRackOption(1304 bytes) andNgs2CustomMasteringRackOption(1288 bytes), and their voice statesNgs2CustomSamplerVoiceState(48) andNgs2CustomMasteringVoiceState(16); the sizes are checked withstatic_assert. Layouts follow KytyPS5, where the same title runs.0x4001xxxx); the custom mastering setup param0x40030000sets the channel count with the custom submixer setup layout.0x4000xxxxoutside UserFx2) are ignored and logged once. The custom submixer keeps rejecting them. Recorded in TechnicalDebt.Tested
ngs2_custom,ngs2_render,ngs2_core_render,ngs2_atrac9,ngs2_filter,ngs2_parse,ngs2_streamandngs2_userfxpass. New cases intests/Ngs2Custom.cppcover both racks (sampler playback with a UserFx2 gain and a built-in module, custom mastering output, voice states).NGS2: rack id 0x4001 is not implemented; with this change it creates both racks (built-in module0x13in the custom sampler) and continues. The title then patches voices to a rack handle, which is not part of this PR.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)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T16:53:39Z.
Review: CHANGES_REQUESTED
Thanks, the layouts match KytyPS5 (
Ngs2CustomSamplerRackOption1304,Ngs2CustomMasteringRackOption1288, voice states 48/16) andngs2_customplus the other Ngs2 tests pass here. A few things before this can merge:Custom.cpp:23-30,Custom.cpp:112-120: built-in modules are accepted, skipped and only logged to stderr. That returns plausible-but-wrong audio wheremainthrew. Please either throw for any built-in module whose behaviour isn't implemented, or show (a test, or a log from the title) that skipping module0x13is exact for what the title does with it and limit the skip to exactly that id/controls.tests/Ngs2Custom.cpp:256-257,:275,:294-295: the project doesn't allow code comments (CONTRIBUTING); please remove them.docs/dev/TechnicalDebt.md:241: KytyPS5 doesn't read the0x40030000setup param at all (it only checks the rack type), so "as KytyPS5 handles them" is wrong for the mastering setup layout. Please say the custom-submixer layout is an assumption. Since the skip changes behaviour, the line also belongs under "### Functional", not "### Unknown function info".Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T17:57:48Z.
Windows data point for Dead Cells (PPSA15552) with this PR: Windows 10, MinGW/Ninja Release build of the PR head on top of
maina11c8f7f7, relinked from the reconstructed ELF (1 module, 0 absent imports), 60 s run.ctest -R ngs2_custompasses. The title creates its custom sampler rack and then aborts on the next missing call:So on this machine it gets past the rack id and does not reach the voice patch to a rack handle mentioned in the description; the Geom call comes first.
The option block I captured with a local trace before this PR (not committed) agrees with the layout here: rack id
0x4001, optionsize = 0x518(1304), name "Default",max_voices = 256,max_ports = 8,max_matrices = 1,state_size = 48,num_buffers = 1,num_modules = 1, and that module hasmodule_id = 0x13,option = nullptr,state_size = 0; the title creates this rack twice. I had a smaller branch for the same rack (xXPBSXx:fix/ngs2-custom-sampler-rack,58c902fe2: only the rack creation and a test, no voices or rendering). This PR covers it, so I am not opening mine.What I did not check: audio, the mastering rack, Linux.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by hansjm10 on 2026-10-11T18:05:18Z.
Linux matches @xXPBSXx's data (Debian 12, GCC 14, RADV gfx1036 and llvmpipe,
maina11c8f7f7): the same 1304-byte option with the single module0x13(no option, no state), sampler limits 256 / 16 / 256 / 256 / 0 / 32, and with a 0x4001 rack the next stop issceNgs2GeomResetSourceParam not implemented.Two points for review:
0x13, so 0x4001 doesn't need the accept-and-ignore path here. Accepting exactly0x13and throwing for other built-in ids and their0x4000xxxxcontrols covers PPSA15552 and keeps "exact behaviour or a throw". I have that variant locally (rack creation only, with a test that fails onmain); I'm not opening it.0x4001xxxxvoice parameters and made nosceNgs2VoiceGetStatecall on this rack's voices. It never requested rack0x4003either; that build had no 0x4003 and would have thrown. It then stopped on an unrelated shader limit of this GPU (Barycentric geometry SPIR-V: the emulated barycentric inputs exceed 32 locations). So the voice side and the mastering rack are not exercised on Linux yet.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T01:37:26Z.
I reviewed the ready branch for #3759 against this PR and current
main. It overlaps the custom sampler implementation here, so I have not opened a parallel PR.The useful difference is the built-in module case from Dead Cells: the candidate accepts and skips module
0x13only on the custom sampler/mastering racks (custom submixer still throws), logs the unimplemented module/control once, keeps the UserFx2 module processing, and has a test that verifies sampler output and UserFx2 gain while a0x13module/control is present. This is aimed at the review request to either throw for unsupported built-ins or demonstrate and limit the skip for the title's0x13module. It also adds rejection tests for loop/filter/other unsupported parameters, buffer-count bounds, and checks custom sampler voice state.I rebased the original one-commit branch onto current
upstream/main; aside from the TechnicalDebt append it applied unchanged and preserves screamm as commit author. Linux Release validation on GCC 12: all ninengs2_*CTests pass, includingngs2_custom; conventions andgit diff --checkpass. The full issue report attributes the rack layout to KytyPS5 and shadPS4, but the sampler behavior itself is still not console-verified.If this follow-up is useful, the branch is
MarcZX100:codex/carry-ngs2-custom-sampler-3759(commit99ff1fa6b). It is currently not pushed.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T07:46:34Z.
Closing in favour of #4417: the points from 10-11 are still open (built-in modules accepted and skipped,
0x40001300ignored), and #4417 implements module0x13instead of skipping it. No title requests rack0x4003yet. Thanks, the run in #4334 on this branch is what showed the remaining stops. If you decide to continue, please reopen.Pull request closed