Skip to content

fix(ngs2): return the voice-index error from sceNgs2RackGetVoiceHandle - #5916

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
JosepBove:fix/ngs2-rack-voice-index-error
Oct 16, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
JosepBove:fix/ngs2-rack-voice-index-error

Conversation

@JosepBove

@JosepBove JosepBove commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Heretic + Hexen (PPSA26525 01.003.000, #5912) stops 1.5 s after start on main 69e7138, before its first frame:

sceNgs2RackGetVoiceHandle: invalid argument

The title creates a one-voice reverb rack (0x2001, max_voices = 1), takes voice 0 and asks for voice 1; sceNgs2RackGetVoiceHandle went through APS5_INVALID_ARG_EX for an index at or beyond the rack's voice count, which throws and ends the process (exit 0xC0000409; the title redirects stderr to app0/stderr.txt, so the message only shows under gdb). DOOM + DOOM II (PPSA21444 03.000.000, #5921) stops on the same line on main 84b01f9, measured here with the identical call sequence (voices 1 to 3 after voice 0), and STAR WARS: Dark Forces Remaster (PPSA19728, #4310) is reported with it; all three run Nightdive's KEX engine.

The index check now returns 0x804A8305 and leaves the output handle untouched. The null-output and rack-handle checks keep their order and codes. The value is the one the PS5 libSceNgs2.native.sprx export MwmHz8pAdAo returns for an index at or past the rack's voice count (firmware 10.01 at 0x11f10, 12.70 at 0x12130, and every module from 1.00 to 12.70 read in this comment), through the same error helper that answers 0x804A8010 for a null output, with the output handle written only on success. The technical-debt entry cites that module and notes that the export checks the rack handle before the output pointer and returns 0x804A8202 for a bad one, which this change leaves as it is on main.

#4788 proposed the same return value for Dark Forces and was closed on 2026-10-14 without a stated reason after twice conflicting with main. This change is rebased on current main, names two more titles that stop on it, and adds the regression as ngs2_voiceindex in the existing NGS2 suite.

Tested

Windows 11 Home (26200), AMD Ryzen 9 9950X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, bundled dependencies. Branch on main 84b01f9.

  • ngs2_voiceindex creates one-voice sampler, submixer, mastering and reverb racks through sceNgs2RackCreate with an explicit option, as the title does, and a default 256-voice sampler rack. For each it checks that the last valid index resolves, that the voice count, the count plus one and UINT32_MAX return 0x804A8305 with the output left at its sentinel, that a null output still returns INVALID_OUT_ADDRESS, that the last valid index resolves to the same handle afterwards, and that an unknown rack handle returns INVALID_RACK_HANDLE. The identical executable aborts against main's libSceNgs2.native.prx with the throw above and passes with this change.
  • ctest -R ngs2_: 11 of 11 pass.
  • Full ctest --parallel 8 --timeout 120: 1193 of 1194 pass on the rebuilt tree. The one failure, conventions_blob_reads, is a tools/ test new on main whose fixture's git tag fails on this machine because its git configuration signs tags; it fails the same way without this change.
  • python tools/check_conventions.py --base origin/main --head HEAD passes; git diff --check is clean.
  • Heretic + Hexen, relinked with --windows --registry (its sce_module/ and prx/ modules converted), ANYPS5_GPU='RTX 5090', 90 s with no input: on main it exits at 1.5 s as above; with this change it shows the logos, the Heretic episode menu at 30 s and the attract demo in game at 75 s at 120 FPS on the window counter, loads a level, plays the demo and writes a quick save. Audio and input were not checked. DOOM + DOOM II, same conversion, 120 s with no input: on main it exits during audio set-up on the same throw; with this change it logs kexAudioNgs2::InitReverbVoices: sceNgs2RackGetVoiceHandle failed (0x804a8305) four times, reaches the attract demo in game at 30 s and its main menu at 110 s at 120 FPS. Dark Forces was not run here.

Checklist

An index at or beyond the rack's voice count returned through
APS5_INVALID_ARG_EX, which throws and ends the process. Heretic + Hexen
(PPSA26525) creates a one-voice reverb rack, takes voice 0 and asks for
voice 1 at start-up, so it stopped at 1.5 s on
"sceNgs2RackGetVoiceHandle: invalid argument". Return 0x804A8305 and
leave the output handle untouched, after the existing null-output and
rack-handle checks. The value follows prosper's analysis of
libSceNgs2.native.sprx; shadPS4 lists 0x804A0302 for the PS4 library.
Neither is a PS5 measurement, recorded in the technical debt.

ngs2_voiceindex creates one-voice sampler, submixer, mastering and
reverb racks and a default sampler rack, and checks the error, the
untouched output, the null-output and invalid-rack codes and that the
last valid index still resolves afterwards. It aborts on main's library
with the throw above and passes with this change.
@fma-rc

fma-rc commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

I checked the value against the PS5 module. In libSceNgs2.native.sprx from PS5 firmware 10.01 (export MwmHz8pAdAo at 0x11f10) and 12.70 (at 0x12130), an index at or past the rack's voice count returns 0x804A8305. The value goes through the same error helper that returns 0x804A8010 for a null output, and the output handle is written only on success. The constant is in this export in all 41 firmware modules from 1.00 to 12.70 that I could read, so the debt entry can cite a PS5 source instead of prosper and shadPS4.

One thing outside this change: the same export validates the rack handle first and returns 0x804A8202 for a bad one, before it looks at the output pointer. main checks the output first and returns 0x804A0261 for a bad rack, and 0x804A0261 does not appear in this export in any of those modules. That could be a separate PR.

On main e34c479 with this PR (17f8bb5), ctest -R ngs2_ passes 11 of 11 on Linux, including ngs2_voiceindex.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1384 core/libs/prx/libSceNgs2.native/CMakeLists.txt
core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
core/libs/prx/libSceNgs2.native/src/Rack.cpp
PR 5797 core/libs/prx/libSceNgs2.native/CMakeLists.txt
core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
docs/dev/debt/libSceNgs2.native.md
PR 5974 docs/dev/debt/libSceNgs2.native.md
PR 6044 core/libs/prx/libSceNgs2.native/CMakeLists.txt
PR 6447 docs/dev/debt/libSceNgs2.native.md
PR 6594 docs/dev/debt/libSceNgs2.native.md
PR 6680 core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
docs/dev/debt/libSceNgs2.native.md

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux run: head 9926c6b76 merged onto main 44df21632 (clean merge). Adds a Linux run to the Windows one in the description.

Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests (Release, BUILD_TESTING=ON).

  • Build: full build passes.
  • Ngs2 tests: all 11 ngs2_* tests pass with the PR, ngs2_voiceindex included. With main's Rack.cpp and the PR's test, ngs2_voiceindex aborts with "sceNgs2RackGetVoiceHandle: invalid argument", the line from the title logs.
  • Non-GPU suite (ctest -E "^agc"): no regressions; the only failures are file_writer_binary and file_writer_text, which fail on main on this machine too.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@JJenkx

JJenkx commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Additional title confirmation: Quake II (PPSA09477), content version 01.003.000.

On current main 44df21632125dbe3113a19173e7ebb879da53003, with the common validator-teardown build repair from #6476, the first native startup aborts at sceNgs2RackGetVoiceHandle: invalid argument before a window appears (exit 134).

Adding exactly this PR’s three commits, preserving their authorship, removes that stop. The title logs three InitReverbVoices failures with 0x804a8305, continues through shader loading and reaches renderer initialization. It then exits with SIGSEGV after about four seconds; this is a startup-blocker confirmation, not a playable-title claim. No game input was injected.

Full libs build succeeded. After rebuilding all NGS2 test executables, all 11 NGS2 CTests passed, 0 skipped (0.42 s). An earlier run against stale test executables failed three tests and is excluded from the final test result.

Environment: Arch Linux, Ryzen 9 7950X, Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1. Local validation head: 86322c5668718c31ebc0b6bae4b504f3bf3c30c7 = current main + #6476 + this PR. No additional production changes, title-specific bypasses, or audio-quality/performance claim. AI-assisted validation.

Follow-up: Quake II bring-up #6554 records the later startup failure. A logging-only diagnostic build reached a 3D scene, presented at least 4,254 frames and closed normally after 83.78 seconds. Normal Release startup remains unreliable; no additional functional fix, input validation or playable-title claim is implied.

@adriadam10 adriadam10 self-assigned this Oct 16, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked build and the NGS2 ctest scope on current main (10/10 pass, ngs2_voiceindex included). The return value 0x804A8305 and the "output written only on success" behaviour match the PS5 libSceNgs2.native.sprx export MwmHz8pAdAo as read by @fma-rc, and the Linux runs by @jotitadev and @johnohhh1 show the new test aborting on main's Rack.cpp and passing here. The technical-debt entry covers the differing rack-handle/output check order. Merging once CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants