feat(ngs2): copy custom UserFx source to dest across multiple buffers #12673
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12673"
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 2Swagger on 2026-10-29T01:20:30Z.
Stacked on #10599: this diff includes #10599's commits until it merges. This PR's own changes are commits
bdc7af81bandc17c71e4d.What
A custom submixer (
0x4002) with more than one buffer accepted at most one Gain module; anything else threwNGS2: multiple custom buffers require a submixer with at most one Gain module. BLUE REFLECTION Quartet (PPSA33655, #10271) stops there once #10599 lets its Reverb rack through. The rack it is refused on has 2 buffers, 2 inputs and two UserFx0x19modules, the second taking buffer 1 as its extra buffer (JJenkx's rack dump).This PR follows item 4 of fma-rc's reading of the PS5 12.70 module, the reading debt entry "NGS2 custom buffers" already cites for input routing:
0x19module copies its source buffer over its dest buffer. With a handler, the handler runs on the source in place. Without one, the copy is all that happens.0x19modules. Any other module still throws, naming its id, and multi-buffer racks other than the submixer still throw.Two handler gaps still throw. The reading says the extra buffer's channel pointers are appended after the source's, but two things it does not say would be guesses:
extra_buffer_id0 means "no extra buffer". Item 13 says buffer 1 is handed over as extra when none is given and the rack has more buffers.So a UserFx handler in a multi-buffer submixer throws, naming both gaps. The game's rack needs both: its first module has extra 0, its second extra 1. It now stops at its next rack instead (see Tested). I've asked JJenkx on #10271 about these two details and the module order, and whether they can test this branch with the title.
Side effect: the old check also refused any multi-buffer chain with more than one module. Several Gains, or a Gain plus a UserFx, are now accepted in a multi-buffer submixer. They run in list order, as single-buffer chains already do and as item 16 describes. Reordering by voice control is unverified.
The debt entry "NGS2 custom buffers" in
docs/dev/debt/libSceNgs2.native.mdnow records:Tested
TestCustomUserFxBuffersinngs2_custom: a 2-input submixer with a UserFx module that has no handler, reading buffer 1 and writing buffer 0. Input 0 plays 0.5 and input 1 plays 0.25; the output port reads buffer 0. The output is exactly 0.25 on both channels for 2 grains, after the sampler's 3-sample startup delay at the start of the first grain. Before this change the test aborts with the oldmultiple custom buffersmessage.ngs2_userfx,ngs2_gain,ngs2_routing,ngs2_customreverband the fivengs2_custom_safety_*cases all pass, so single-buffer UserFx and Gain behaviour is unchanged.c17c71e4d(on #10599 atbc0711398, merged ontomaincf0e33b6a): those 10 tests pluspublic_headersand its compile batches, 75 of 75 passed.ngs2_custom,ngs2_userfxandngs2_custom_safety_routing_two_bufferspassed 20 consecutive runs each on both platforms (ctest --repeat until-fail:20) at this head, and 200 each atbdc7af81b.main602c0e417cwith this PR merged in (headc17c71e4d), on Linux with a Radeon RX 6650 XT (RADV, Mesa 26.2.4). The rack 3 refusal (multiple custom buffers require a submixer with at most one Gain module) is gone, so the title gets past rack 3. It now stops in the same second at its next rack, a custom mastering rack (0x4003) with modules 0x17 and 0x18:custom mastering racks with modules are not implemented. No audio renders yet, so the two UserFx handler gaps (the channel count with extra-buffer channels appended, and whether extra buffer 0 means none) remain unverified.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T04:43:20Z.
Review: COMMENTED
I ran this PR's own commit (
bdc7af81b) outside CMake on macOS: x86_64, Apple clang, ASan+UBSan. The build used the PR tree'slibSceNgs2.native/src/*.cppwith a stub for the five Atrac9 entry points, linked against each test.Results
ngs2_custompasses (1.2 s). So dongs2_customreverb,ngs2_gain,ngs2_routing,ngs2_userfxand all fivengs2_custom_safety_*cases.Custom.cpp(bdc7af81b^) and the new test, the run aborts withNGS2: multiple custom buffers require a submixer with at most one Gain module. That matches the body.git merge-treewith currentmain(52c09d567d) is clean, andcheck_conventions --headpasses.Mutants (each one applied to
Custom.cpp, then all 10 ngs2 tests run)CopyCustomBuffer0x1athereRefreshHasSamplesinCopyCustomBufferhasSamples, so a copy can only make it over-report)grain * InputChannels())The two guards the body depends on ("Two handler gaps still throw", and multi-buffer racks other than the submixer still throw) aren't tested yet. The rows below go at the end of
TestCustomUserFxBuffers, reusing the file'sProcessLegacy/LegacyUserFxStateandCreateSamplerThrows. They kill both mutants: the handler mutant fails at L615 (the handler gets called) and the rack mutant at L892. Head still passes in 0.09 s.The sampler row hits the new
outside a custom submixerbranch, since a 0-module custom sampler with 2 buffers passes every earlier check. If you'd rather cover the mastering rack too, the same row withMasteringRackOption(2, 1)andnum_buffers = 2should reach the same branch. I didn't run that one.Source and host tests only; nothing on a console, and I didn't use PPSA33655.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T09:17:02Z.
Review: APPROVED
Reviewed — approved
A multi-buffer custom submixer now accepts Gain and UserFx
0x19modules, and a handler-less UserFx copies its source buffer over its dest buffer. The merged tree builds, the NGS2 tests the change touches pass, and the new test fails whenCustom.cppis put back to itsmainversion.What I ran
Head
c17c71e4d1413e3b167debacd69ba9e8a827f35d,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree488ac2d280588fa590cb03801cc164272712d80e. #10599 is already inmain, so the diff againstmaincovers only this PR's own two commits:Custom.cpp,tests/Ngs2Custom.cppand the NGS2 debt file.Results
git diff --checkcheck_conventions.pylibs(script)unwrap_self_..._destination_directory_groupalso fails onmain; it is unrelated to this PRngs2_custom,ngs2_userfx,ngs2_gain,ngs2_routing,ngs2_customreverb, 5 ×ngs2_custom_safety_*ngs2_custom0.06 s)ngs2_core_custom_safety_*,ngs2_core_gain,ngs2_core_routingNegative control
I put
core/libs/prx/libSceNgs2.native/src/Custom.cppback to itsmainversion and kept the new test. After the rebuild,ngs2_customfailed withSubprocess aborted. That matches the oldmultiple custom buffers require a submixer with at most one Gain modulethrow that rooklz reported. I then restored the merged file and rebuilt:ngs2_custompassed again, andgit status --porcelainwas empty.Findings
Blocking
None.
Non-blocking
SetCustomUserFxParamaccepts a handler without complaint. The throw comes on the next render, incore/libs/prx/libSceNgs2.native/src/Custom.cpp:465, insideNgs2ProcessUserFx. So the failure is reported away from the call that caused it, possibly on the render thread. Throwing inSetCustomUserFxParamwhenvoice.customBuffersis not empty and the handler is not null would point at the call that hits the gap. The present behaviour is still correct and still throws, so this is optional.Custom.cpp:465) andmultiple custom buffers outside a custom submixer(Custom.cpp:96). rooklz already showed with mutants that no test fails when either is removed. The author declined, citing the request not to pin unimplemented behaviour. I have no new evidence; I mention it only for completeness.Other checks
CopyCustomBufferis a no-op for single-buffer racks. Creation (Custom.cpp:89-91) rejects buffer ids ≥num_buffers, so source and dest are always 0 there, and single-buffer UserFx/Gain behaviour is unchanged.CopyCustomBuffercannot fire in practice:Render.cpp:405-406sizes every buffergrain * InputChannels(). This agrees with rooklz's equivalent-mutant finding.RefreshHasSamplesafter the copy and after the handler is consistent withProcessGain. It now counts every custom buffer, where the old handler path looked only atsamples.main.Not verified