feat(ngs2): play additional PCM sampler formats #10127

Merged
Felipebmaitan merged 3 commits from upstream-pr/10127 into main 2026-10-25 23:10:05 +00:00
Felipebmaitan commented 2026-10-23 10:25:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-23T10:25:42Z.


What

NGS2 sampler voices rejected unsigned 8-bit, signed 24/32-bit and 32/64-bit floating PCM, while frame addressing and decoded-byte accounting assumed signed 16-bit samples. Add complete-block playback for those five formats through a shared reader used by libSceNgs2 and libSceNgs2.native, and use the actual sample width for validation, positions and counters. Existing resampling, repeats, block callbacks and signed-16 streaming remain in place.

The format mappings follow prosper's published waveform analysis; the parser's WAVE input representations follow the Microsoft PCM description. Integer PCM is normalized by its signed range and double PCM narrows to host float. Console rounding and unsupported behavior are recorded in the library debt entry. The new formats require complete blocks and zero configuration; floating samples outside -1..1, nonfinite values and nonzero magnitudes below the smallest normal float throw. Bit-based checks also reject these values when the caller enables DAZ/FTZ.

Parser expansion remains in #9148. The manual overlap review from 2026-10-23 records the exact heads and integration requirements inspected at that time. It is historical and does not establish compatibility with subsequent updates to those branches. This implementation has no build dependency on them.

Rebased onto main c661d9fae2d630a48819218a8271ce19b39f006a in response to the review from Dean. Nonempty setups accept ATRAC9 and the six implemented PCM formats; the shared PCM-width validator throws for every other type. The empty-format setup handling from main remains before reset/validation, so an empty format preserves an existing setup and its queued playback. The PCM regressions now exercise that behavior for all six formats and 1/2/6/8 channels. The VoiceEvents test from main and both PCM test registrations are retained.

Tested

Windows 11 Pro 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja Release; NVIDIA GeForce RTX 5080, Windows driver 32.0.16.2101. No title or console was run, and no new dumps were used.

  • 2026-10-25 rebase validation on 1cccff944105af1f9987a838609898ad3885f40f: Full Release build cmake --build build --parallel 8 succeeded. ctest --test-dir build -R "^ngs2_" --output-on-failure passed 16/16, including ngs2_pcm, ngs2_core_pcm and ngs2_voiceevents (4.79 s total). python tools/check_conventions.py --base origin/main and git diff --check pass.

  • Previous full build: cmake --build build --parallel 8 succeeded on head 1d945338ebec8582daa8921f213cd23ea2d0d908, based on main 5e9f4b896680f8ec848ba495c556d2ab8b3a99fa.

  • Previous full suite on 1d945338ebec8582daa8921f213cd23ea2d0d908: ctest --test-dir build --output-on-failure --parallel 4: 2001 passed, 3 failed, 4 skipped out of 2008, in 274.52 s. The suite is not fully green.

  • All 15 NGS2 tests passed on that previous head, including the same PCM regression linked separately against both NGS2 libraries. The retained regressions check literal sample bytes, multichannel interleaving, unaligned input, skips, repeats, cross-block resampling, pitch, callbacks, byte positions, short/overflowing buffers and integer/float narrowing.

  • 2026-10-23 maintainer follow-up: removed throw expectations for unimplemented incomplete streaming, silence, configuration, floating inputs and waveform setup. Rebuilt ngs2_pcm_tests and ngs2_core_pcm_tests; ctest --test-dir build -R "^(ngs2_pcm|ngs2_core_pcm)$" --output-on-failure passes 2/2. This follow-up changes tests only; the full suite was not repeated.

  • The three full-suite failures are agc_driver_sample_order, agc_driver_sample_order_grid_reference and agc_driver_sample_order_recipe_depth_locations. They also fail serially on unchanged main c188e01a4286bfc402519df2ceb56441479cc835, on this same machine/GPU, with identical assertion messages. That tested head reproduces those same three messages; no additional failures occurred. This patch changes no AGC, shader or VideoOut code.

  • Baseline assertions: standard 2x sample locations and the grid-reference composite do not leave depth both at and below the clear value; recipe-depth-locations reports depth other than the clear value after the clear between a recorded draw and replay.

  • Skipped: agc_host_import_sparse, agc_driver_sparse_dma_buf_import, agc_driver_stencil_ref_export, guest_video_out_wqhd_detection_no_vulkan.

  • python tools/check_conventions.py --base origin/main and git diff --check pass. The previous tools/pr_overlap.py --branch feat/ngs2-pcm-playback --repo boykopovar/AnyPS5 --jobs 6 run reported no direct overlap among comparisons it completes and warns that the four conflicted branches cannot be compared. The linked manual review documents their actual conflicts and integration requirements.

The tests establish host conversion and integration behavior. PS5 numerical equivalence remains unverified as recorded in the existing library debt file.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4981337382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10127). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-23T10:25:42Z. --- ### What NGS2 sampler voices rejected unsigned 8-bit, signed 24/32-bit and 32/64-bit floating PCM, while frame addressing and decoded-byte accounting assumed signed 16-bit samples. Add complete-block playback for those five formats through a shared reader used by libSceNgs2 and libSceNgs2.native, and use the actual sample width for validation, positions and counters. Existing resampling, repeats, block callbacks and signed-16 streaming remain in place. The format mappings follow [prosper's published waveform analysis](https://github.com/mattias800/prosper/blob/30572df43ae20ff28f995db56149f7af42235741/prosper/src/hle/audio/ngs2_waveform.cpp#L194-L223); the parser's WAVE input representations follow the [Microsoft PCM description](https://learn.microsoft.com/en-us/windows/win32/multimedia/devices-and-data-types). Integer PCM is normalized by its signed range and double PCM narrows to host float. Console rounding and unsupported behavior are recorded in the library debt entry. The new formats require complete blocks and zero configuration; floating samples outside -1..1, nonfinite values and nonzero magnitudes below the smallest normal float throw. Bit-based checks also reject these values when the caller enables DAZ/FTZ. Parser expansion remains in #9148. The [manual overlap review from 2026-10-23](https://github.com/boykopovar/AnyPS5/pull/10127#issuecomment-6363063822) records the exact heads and integration requirements inspected at that time. It is historical and does not establish compatibility with subsequent updates to those branches. This implementation has no build dependency on them. Rebased onto main `c661d9fae2d630a48819218a8271ce19b39f006a` in response to the review from Dean. Nonempty setups accept ATRAC9 and the six implemented PCM formats; the shared PCM-width validator throws for every other type. The empty-format setup handling from main remains before reset/validation, so an empty format preserves an existing setup and its queued playback. The PCM regressions now exercise that behavior for all six formats and 1/2/6/8 channels. The VoiceEvents test from main and both PCM test registrations are retained. ### Tested Windows 11 Pro 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja Release; NVIDIA GeForce RTX 5080, Windows driver 32.0.16.2101. No title or console was run, and no new dumps were used. - 2026-10-25 rebase validation on `1cccff944105af1f9987a838609898ad3885f40f`: Full Release build `cmake --build build --parallel 8` succeeded. `ctest --test-dir build -R "^ngs2_" --output-on-failure` passed **16/16**, including `ngs2_pcm`, `ngs2_core_pcm` and `ngs2_voiceevents` (4.79 s total). `python tools/check_conventions.py --base origin/main` and `git diff --check` pass. - Previous full build: `cmake --build build --parallel 8` succeeded on head `1d945338ebec8582daa8921f213cd23ea2d0d908`, based on main `5e9f4b896680f8ec848ba495c556d2ab8b3a99fa`. - Previous full suite on `1d945338ebec8582daa8921f213cd23ea2d0d908`: `ctest --test-dir build --output-on-failure --parallel 4`: **2001 passed, 3 failed, 4 skipped out of 2008**, in 274.52 s. The suite is not fully green. - All 15 NGS2 tests passed on that previous head, including the same PCM regression linked separately against both NGS2 libraries. The retained regressions check literal sample bytes, multichannel interleaving, unaligned input, skips, repeats, cross-block resampling, pitch, callbacks, byte positions, short/overflowing buffers and integer/float narrowing. - 2026-10-23 maintainer follow-up: removed throw expectations for unimplemented incomplete streaming, silence, configuration, floating inputs and waveform setup. Rebuilt `ngs2_pcm_tests` and `ngs2_core_pcm_tests`; `ctest --test-dir build -R "^(ngs2_pcm|ngs2_core_pcm)$" --output-on-failure` passes **2/2**. This follow-up changes tests only; the full suite was not repeated. - The three full-suite failures are `agc_driver_sample_order`, `agc_driver_sample_order_grid_reference` and `agc_driver_sample_order_recipe_depth_locations`. They also fail serially on unchanged main `c188e01a4286bfc402519df2ceb56441479cc835`, on this same machine/GPU, with identical assertion messages. That tested head reproduces those same three messages; no additional failures occurred. This patch changes no AGC, shader or VideoOut code. - Baseline assertions: standard 2x sample locations and the grid-reference composite do not leave depth both at and below the clear value; recipe-depth-locations reports depth other than the clear value after the clear between a recorded draw and replay. - Skipped: `agc_host_import_sparse`, `agc_driver_sparse_dma_buf_import`, `agc_driver_stencil_ref_export`, `guest_video_out_wqhd_detection_no_vulkan`. - `python tools/check_conventions.py --base origin/main` and `git diff --check` pass. The previous `tools/pr_overlap.py --branch feat/ngs2-pcm-playback --repo boykopovar/AnyPS5 --jobs 6` run reported no direct overlap among comparisons it completes and warns that the four conflicted branches cannot be compared. The linked manual review documents their actual conflicts and integration requirements. The tests establish host conversion and integration behavior. PS5 numerical equivalence remains unverified as recorded in the existing library debt file. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-23 10:30:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:30:16Z.

Review: APPROVED


Reviewed the full diff, linked issue #10126 and the existing NGS2 format/render paths. The change keeps this scope to sampler input playback; render-buffer output remains on the existing supported formats. I checked the signed 24-bit sign extension, signed-width normalization, little-endian float decoding and range checks, and the updates to frame positions, byte accounting, skips, repeats, resampling and multichannel access. The new tests exercise both NGS2 libraries and cover those paths, malformed/incomplete input, unsupported formats and floating-point edge cases. The unsupported console-specific behavior is recorded in the library debt entry.

The PR's reported Windows run passes all 15 NGS2 tests; its full suite has three failures that the author reproduced with identical assertions on unchanged main, and four skips. The hosted intake, conventions and labels checks pass; hosted Linux/Windows builds are skipped by repository policy. I ran the conventions checker and git diff --check on the exact head; both pass. I also attempted a local focused build, but CMake configuration stops before building because the SDL2 submodule is absent and XRandR development support is unavailable in this environment. The PR is mergeable with current main, and the pairwise merge check is clean. I found no blocking correctness issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5627018617 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10127#pullrequestreview-5627018617). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T10:30:16Z. **Review:** APPROVED --- Reviewed the full diff, linked issue #10126 and the existing NGS2 format/render paths. The change keeps this scope to sampler input playback; render-buffer output remains on the existing supported formats. I checked the signed 24-bit sign extension, signed-width normalization, little-endian float decoding and range checks, and the updates to frame positions, byte accounting, skips, repeats, resampling and multichannel access. The new tests exercise both NGS2 libraries and cover those paths, malformed/incomplete input, unsupported formats and floating-point edge cases. The unsupported console-specific behavior is recorded in the library debt entry. The PR's reported Windows run passes all 15 NGS2 tests; its full suite has three failures that the author reproduced with identical assertions on unchanged main, and four skips. The hosted intake, conventions and labels checks pass; hosted Linux/Windows builds are skipped by repository policy. I ran the conventions checker and `git diff --check` on the exact head; both pass. I also attempted a local focused build, but CMake configuration stops before building because the SDL2 submodule is absent and XRandR development support is unavailable in this environment. The PR is mergeable with current main, and the pairwise merge check is clean. I found no blocking correctness issue.
MarcZX10 commented 2026-10-23 11:13:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:13:33Z.

Review: APPROVED


Reviewed the exact head 1d945338ebec8582daa8921f213cd23ea2d0d908. The sample-width helper is used consistently for frame addressing, byte counts and waveform positions; signed 24-bit sign extension, signed normalization, float range checks and multichannel reads have targeted fixtures. New formats are limited to complete blocks, and the remaining numerical/console assumptions are recorded in debt. The PR documents the three unrelated AGC failures as reproduced on unchanged main, with no additional failures on its full Windows suite; all 15 NGS2 tests reportedly pass, including both library variants. Hosted conventions, intake, labels and report pass; product jobs were skipped by path policy. I reviewed the listed overlap conflicts and the explicit coordination notes; this PR does not claim the combined branches were tested. No blocking issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5627444925 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10127#pullrequestreview-5627444925). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T11:13:33Z. **Review:** APPROVED --- Reviewed the exact head `1d945338ebec8582daa8921f213cd23ea2d0d908`. The sample-width helper is used consistently for frame addressing, byte counts and waveform positions; signed 24-bit sign extension, signed normalization, float range checks and multichannel reads have targeted fixtures. New formats are limited to complete blocks, and the remaining numerical/console assumptions are recorded in debt. The PR documents the three unrelated AGC failures as reproduced on unchanged main, with no additional failures on its full Windows suite; all 15 NGS2 tests reportedly pass, including both library variants. Hosted conventions, intake, labels and report pass; product jobs were skipped by path policy. I reviewed the listed overlap conflicts and the explicit coordination notes; this PR does not claim the combined branches were tested. No blocking issue found.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10127
No description provided.