feat(libSceNgs2.native): implement custom sampler rack id 0x4001 (#4334) #4417
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4417"
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 Jnbla6 on 2026-10-12T10:28:27Z.
What
SCE_NGS2_RACK_ID_CUSTOM_SAMPLER(0x4001), which Dead Cells requests during startup.Ngs2CustomSamplerRackOptionlayout and rack/voice parameter IDs. Route sampler controls and rendering through the existing sampler implementation, while supporting UserFx2 modules on the custom rack.TestCustomSampler()regression test and document the implementation assumptions inTechnicalDebt.md.Tested
python3 tools/check_conventions.py --base origin/main.python3 -m unittest discover -s tools/tests: 184 tests passed.Checklist
mainNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T10:37:58Z.
Correction after comparing both diffs: #4254 already has the same
0x4001rack layout, sampler setup/add-waveform/pitch parameter IDs, custom sampler rendering, and UserFx2 setup/processing. #4417 appears largely to duplicate it; the additional sampler behavior I found is customexit_loopparameter handling, alongside a smaller test. Both still callNgs2CheckCustomRack, so neither appears to implement module ID0x13that the maintainer identified as Dead Cells' current stop.Could you coordinate with #4254's author and make this a focused follow-up after #4254, or explain why #4417 is intended to replace it? As written, #4417 targets
main, overlaps the existing open implementation, and its checklist says there is no overlapping PR.Imported from boykopovar/AnyPS5. Originally posted by Jnbla6 on 2026-10-12T11:05:42Z.
thank you for the note! I actually started working on this after seeing issue #4334, and I hadn't noticed that PR #4254 was already open regarding the same thing—my apologies for the overlap!
Since #4254 already covers the core layout and parameters, please feel free to carry it all or take any useful pieces from my code if anything here is helpful. If not, no worries at all! Thank you for your hard work on this.
Imported from boykopovar/AnyPS5. Originally posted by Jnbla6 on 2026-10-12T13:39:48Z.
After investigating the
0x13custom-module roadblock reported for Dead Cells (PPSA15552), I compared the parameter layout withshadPS4’s NGS2 definitions and traced how AnyPS5 currently handles sampler filters. The evidence points to module ID0x13being the built-in Custom Voice Filter module (SCE_NGS2_CUSTOM_MODULE_ID_FILTER), but I have not tested the implementation yet, so I cannot confirm that this fully solves the game’s startup issue.Deep-Dive Discovery & Live Protocol Correlation:
A close cross-section analysis between live protocol traces from Dead Cells (captured via
PROSPER_NGS2_TRACE=2inprosper) and the reference definitions inshadPS4(ngs2_custom.h) reveals the exact identity and memory layout of module0x13:0x13): Option dumps from real title captures show that Dead Cells initializes its0x4001custom sampler rack with a single built-in module0x13whereoption == nullptr,state_size == 0, and all buffer IDs are strictly zero.0x40001300): During playback, the game issues parameter updates via command family0x40001300(0x40000000 | (0x13 << 8) | index). While initial trace analysis in other emulators mistakenly misidentified these payload fields as generic stereo output levels (MatrixLevels), correlating the raw offsets directly againstOrbisNgs2CustomVoiceFilterParamproves they are classic RBJ Biquad filter parameters:+0x00:Ngs2VoiceParamHeader(8 bytes,id = 0x40001300,size = 40).+0x08:u32 type(Filter type, e.g.,1for Low-pass).+0x0c:u32 channelMask(Channel bitmask).+0x10:float fcholding~1e4(10000.0 Hz), representing the cutoff frequency.+0x14:float qholding0.707f(\frac{1}{\sqrt{2}}), representing the Butterworth quality/resonance factor.+0x18:float levelholding1.0f, representing the filter stage level output.Findings & ABI Details:
0x13module with a null option and no state. The implementation now accepts that configuration while keeping the filter module strictly out ofUserFxsetup and processing.0x40001300 | indexcommand is routed to AnyPS5’s existing filter implementation, with validation that the index identifies aFILTERmodule.+0x00,typeat+0x08, 32-bitchannelMaskat+0x0c, and the parameter union at+0x10. In itsfcqform,frequency,q, andlevelreside at+0x10,+0x14, and+0x18respectively. Compile-time assertions check the structure size and key offsets.Verification Status:
git diff --checkis clean, and editor checks found no syntax errors in the changed ABI definition, custom-module code, or test. I’m therefore not fully sure this solution is correct or complete because i didnt test it on the game, it still needs a successful build and runtime test, ideally with Dead Cells.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:10Z.
Four things before this can go in:
docs/dev/TechnicalDebt.md; please rebase. The entry now goes indocs/dev/debt/libSceNgs2.native.md.Custom.cpp:116: onlytype == 1copies its parameters; any other type, and thedirectcoefficient form, reachesNgs2SetFilterwith zeros. Please throw for what isn't implemented.0x13or the0x40001300control. Please add what they are taken to be and the source for the module id; shadPS4'sngs2_custom.hgives the parameter layout but not the id.ngs2_customwas never built or run. Please run it, or say so once CI has.#4254 and #3793 add the same rack, so the checklist's "no other open PR" needs correcting.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T07:46:37Z.
Taking this one for #3553 over #3793 and #4254. Please rebase:
docs/dev/debt/conflicts with main. The four points from earlier today still stand.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T13:17:56Z.
Windows test note: this branch (base
8c4a295ff) no longer merges onto currentmain0f2683cb7;git merge-treereports a conflict indocs/dev/TechnicalDebt.md. Technical debt entries now live in per-library files underdocs/dev/debt/(seedocs/dev/CONVENTIONS.md), so the entry probably has to move there as part of the rebase. I could not run its tests on a merged tree.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T17:21:18Z.
Thanks for offering this implementation. I carried commit
1d5190d0ed9bc084df019d0a93250e02416d9799into #4254 alongside the custom sampler rack work, preserving your commit author. The combined Linuxngs2_customtest passes (1/1); unsupported custom filter types throw explicitly. No Dead Cells runtime test was available. I’m leaving #4417 open.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T17:50:17Z.
I checked the updated head
b2ddb0b7d7. The newelsenow rejects unsupported filter types, and the debt entry is in the per-library file. #4254 already carries the same filter implementation and explicitly tests that types 0 and 2 throw; #4417’s filter test currently covers type 1 and the invalid module index. The sampler-rack implementation also remains substantially overlapping between the two PRs.\n\nI have left both PRs open. If #4417 is meant to contribute only the filter follow-up, narrowing it to the delta that is not already in #4254 would make the remaining review clear.Imported from boykopovar/AnyPS5. Originally posted by Jnbla6 on 2026-10-13T18:11:46Z.
@oneandonlydean I have applied all of your requested changes:
main, resolved the conflict, and correctly moved the documentation todocs/dev/debt/libSceNgs2.native.md.Custom.cppto explicitlythrowfor any filter type other than1, ensuring we strictly track unmodeled behavior instead of silently passing zeros.0x13(Custom Voice Filter) and the0x40001300control command, citing bothshadPS4's layout andprosper's live trace logs as the verification sources.ngs2_customtests, and updated the checklist to acknowledge the overlap.Furthermore, as noted over in issue #3553, @hansjm10 has run a diagnostic test on this branch. His runtime test successfully cleared the initial
0x4001/0x13rack creation roadblock for Dead Cells, successfully advancing the title's execution state to the non-default listener orientation stop (sceNgs2GeomCalcListener). Merging this PR will formally unblock that geometry/listener issue so the next fix can be tested and developed.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T18:36:54Z.
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/debt/libSceNgs2.native.mdL26docs/dev/TechnicalDebt.mdL1-33core/libs/prx/libSceNgs2.native/include/Ngs2Types.hppL59-60, L64core/libs/prx/libSceNgs2.native/src/Custom.cppL20-23, L39-53, L95, L100, L103-110core/libs/prx/libSceNgs2.native/tests/Ngs2Custom.cppL226, L229core/libs/prx/libSceNgs2.native/include/Ngs2Types.hppL59-60, L64, L492-493core/libs/prx/libSceNgs2.native/src/Custom.cppL20-23, L36, L39-53, L95, L100, L103-110core/libs/prx/libSceNgs2.native/tests/Ngs2Custom.cppL226, L229docs/dev/TechnicalDebt.mdL1-33docs/dev/TechnicalDebt.mdL1-33Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T18:47:12Z.
The overlap workflow reports that #4254 and #4417 both change the custom rack structures and implementation across
Ngs2Types.hpp,Custom.cpp,Rack.cpp,Voice.cppand the tests. Since #4417 has a focused sampler-rack implementation and runtime validation, I updated #4254 to depend on #4417 and will rebase the filter follow-up after yours lands. Please let me know if you prefer the opposite order.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T18:47:59Z.
I also updated #4777 to depend on #4417. Its rack-handle fallback changes the same
Patchhunk; after your change lands, I will rebase it while preserving the custom-sampler destination rejection you added.Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T18:47:59Z.
Ran PPSA15552 (Dead Cells, my own dump) on Windows against
main+ this PR, to give the runtime evidence that was missing here and on #4254.Order of stops
0x13and0x40010000setup all go through. It then stops onPatch: invalid argument, because the game patches a sampler voice to a rack handle. #4777 fixes that.Patch: rack-handle fallback plus rejection ofCUSTOM_SAMPLERdestinations. It then stops onNGS2: custom filter type 0 is not implemented.The
0x40001300param doesn't match the 40-byte shadPS4 layoutThe game's header declares
size = 48. Here are the twelve 32-bit words it passes, header included:+0x14..+0x1care10000.0f, 0.7071f, 1.0f. They look like fc / Q / level, and are the values prosper's trace saw.OrbisNgs2CustomVoiceFilterParam.param.fcq(which starts at+0x10).+0x10holds9, which looks like the real type.+0x08and+0x0care zero.So under the shadPS4 struct the type reads as
0andi0as the integer 9. The PS5 struct seems to be 48 bytes with a different field order. I can't name the fields from this alone:+0x08could be a 64-bit channel mask or index plus location, and I don't know what type9means. But both this PR and #4254 currently reject the only filter this title sends.What happens past that point (local diagnostic build, not for merging)
To see what follows, I made the filter param a no-op locally.
NGS2: voice state of rack 0x4001 is not implemented.sceNgs2VoiceGetStateis called on custom sampler voices withstate_size = 48; the sampler's state is 56 bytes.state_flagsset), the game ran for 3 minutes with no further library stop. It mounts its save data, readsdc_options.json, and loads fonts and atlases.Separate from this PR:
sceNgs2GeomCalcListeneronmainmainthrows on the listener the game uses: position 0, front(1,0,0), up(0,0,1), flags 0, sound speed 343.(0,0,1)/ up(0,1,0).sceNgs2GeomApplyis imported but was never called in 3 minutes.I'm not proposing a fix for this here, because the matrix convention has no source beyond the KytyPS5/PS5PCEM inferences.
Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T18:49:09Z.
Follow-up to my Dead Cells comment above: with the same build (main + this PR + #4777, the 48-byte
0x40001300filter param treated as a no-op, custom samplerVoiceGetStateanswered for size 48, and the rotated Geom listener accepted), PPSA15552 reaches its title screen with audio playing, checked by eye on Windows. So these are the only NGS2 gaps between boot and the title screen.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T18:49:24Z.
Thanks for the on-title run and the exact 12-word payload; that is much stronger evidence than the public headers. Your results confirm the ordering I was asking for: #4417 first, then #4777 while preserving the custom-sampler destination rejection. I have updated #4254 and #4777 to depend on #4417.
I also need to correct my earlier #4254 comment: prosper's source labels
0x40001300as MatrixLevels, but your PS5 trace shows a 48-byte payload with9at+0x10and the frequency/Q/level-looking values starting at+0x14. So that source is a conflicting interpretation, not evidence of the console ABI. The 40-byte shadPS4 layout does not fit this observed call. I agree the custom filter path remains unresolved until the 48-byte layout and type 9 are identified; I won't claim the current PR handles this title.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T19:55:17Z.
Rebased onto main (
dacd78525) and pushed here, keeping your three commits as they were. Two commits on top:docs/dev/TechnicalDebt.md, which the earlier rebase deleted (on main it is now the index that points intodocs/dev/debt/), and adds the missing final newline todocs/dev/debt/libSceNgs2.native.md;64110c4fdfrom #4254:ngs2_customaborted withvoice port 0 is out of rangeunder main's port checks, so the test rack now declaresmax_portsandmax_matrices.Merging on a green full build. The 48-byte type-9 filter call traced on the title still throws here; that is the follow-up in #4254.