VSP-17: host-side convolution for audio DSP streams (dsp.rs) #23

Closed
github-bot wants to merge 0 commits from github-bot/gh-23 into main AGit
Owner

@⁠thefafu on GitHub · 2026-11-30 18:20 UTC · original
thefafu:vsp-17-dsp-convolution → main · +830 −24 · 1 files · 50 commits · closed without merging

Summary

  • Claimed Task ID: VSP-17 (linked Task Claim issue: #21). Fixes #6.
  • What this PR changes: only crates/vesper-hle/src/modules/dsp.rs (its unit tests included). Convolution streams used to complete with silent output, so sounds a title routes through them (phone calls, TVs, radios, voices under water) were mute.
    • Activation: XDspActivate reads the impulse response the title hands over with a checked copy (ReadProcessMemory on the own process), so a bad pointer refuses the filter instead of faulting. The IR is in the coprocessor's partitioned frequency-domain layout:

      • per partition, frames complex bins of a 2 * frames FFT, without the Nyquist bin;
      • partition k is the window [k * frames, k * frames + 2 * frames) of the filter;
      • a stereo IR (option 8) has one run per channel;
      • the IR ends in a closing partition whose first word is not a finite float.

      Each partition's first frames time samples are rebuilt and kept as a spectrum.

    • Submit: uniformly partitioned overlap-add convolution per channel, with the command's linear gain ramp. Blocks can be interleaved or deinterleaved (option 2). The input is copied out first, so in-place blocks work. Non-finite samples become 0, and the output is held to [-1, 1].

    • No audio-thread stalls:

      • Every buffer (filter, input-history ring, FFT scratch, twiddle table) is allocated at activation. A command allocates nothing and takes no lock.
      • Only the frames + 1 unique bins of real signals are multiplied, in split real/imaginary runs that vectorize.
      • Partition k is first needed k blocks in, so a long filter is built one partition per block and activation does not stall either.
      • Commands still complete synchronously, so the status block never reports an overrun.
    • Fallback: a convolution stream whose filter is unusable passes its input through with the command's gains (one warning per stream, at most 16). VESPER_DSP_CONVOLUTION=0 does the same for every stream. FFT/IFFT transform streams stay silent as before.

    • Basis: follows the GPL-3.0-or-later host convolution of the lineage this project descends from (used in other forks to restore these voices), reworked as described above.

Cost, measured (cargo test --release -p vesper-hle --lib modules::dsp::tests::block_cost -- --ignored --nocapture, repo .cargo config, 7800X3D). This is the longest filter a connection allows (30 s at 48 kHz, stereo, 1,024 frames: 1,407 partitions):

Steady block 0.61 ms
Slowest block 0.92 ms
Block period 21.3 ms
Activation 4.6 ms

The title's actual stream in game: mono, 1,024 frames, 19 partitions.

AI Assistance Disclosure

  • No AI coding tools were used
  • AI coding tools were used: Claude Code (Claude Opus 5.5) wrote the change and the tests. I checked the following myself:
    • I ran every command below locally and read the results.
    • I drove the game with this build: the caller's voice in phone calls is audible again (silent on main).
    • The log shows the host convolution stream built and no refused filter.

Benchmark Comparison (Required for perf / GPU / memory changes)

This is an audio change, with no GPU or memory path touched. Hardware: Ryzen 7 7800X3D / 32 GB DDR5-4800 / Radeon RX 9060 XT 16 GB (driver 32.0.32029.2010) / Windows 11 build 26300, inbox D3D12. Profile: scripts\launch.cmd [1] Series X 1440p Native (HW RT), telemetry on, same restored save. Both drives are on this PR's build:

  • Drive 1: the first on the new main. 565 pipelines were dropped while being made; the shader cache was cold.
  • Drive 2: the next one, with the cache settled.
Metric Drive 1 (cold cache, 408 s) Drive 2 (settled, 205 s)
p50 FPS / ms 20.69 / 48.3 17.90 / 55.9
p95 Frame Time (ms) 78.2 115.9
p99 ms (1% Low FPS) 989.6 (1.01) 195.4 (5.12)
Frames >100 ms (%) 3.06 % 8.4 %
Max >100 ms Streak (s) 18.9 (loading) 0.81
Peak Private RAM (MB) 33,530 35,820

Drive 2 spent more time in the dense city. The routes differ, so these numbers describe this hardware rather than compare before and after.

Telemetry reports (cleaned): Drive 1: vesper_report_20261130-205954_e9ac841_clean.zip, Drive 2: vesper_report_20261130-210901_e9ac841_clean.zip.

The bundles the launcher makes still carry the game folder path, the title executable's file name and the machine name in drive_telemetry.log (only summary.txt and env.txt are redacted). In these copies every file was scrubbed of local paths, machine and user names, the title's folder, executable, id and file names, 64-bit hashes and user ids. Nothing else was changed. I am happy to file the redaction gap as a separate bug against collect_telemetry.ps1.

Mandatory Verification Checklist

  • Diff obeys AGENTS.md, stays inside claimed VSP-17 files (dsp.rs only), and avoids the Maintainer Active Queue (ROADMAP.md)
  • cargo xtask policy and cargo test -p xtask --locked pass cleanly (xtask: 9 passed)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings passes with 0 warnings (also without --all-features)
  • cargo xtask test-fast passes. cargo test --workspace --locked --no-fail-fast -- --test-threads=1 gives 1,268 passed, 48 ignored and 2 failed. The 2 failures are in vesper-shader (emit::valu_tests::normalized_buffer_formats_load_correctly_rounded_quotients, emit::valu_tests::normalized_codes_truncate_back_to_themselves, WARP rounding: 0x3ca0a0a0 vs 0x3ca0a0a1) and fail the same way on an untouched main here. The new and existing dsp tests: 9 passed, 1 ignored (the cost measurement).
  • Safety gates remain enabled (VESPER_WAIT_RESIDENT=textures, indirect clamping intact); no rendering code touched
  • Contains zero proprietary assets, keys, dumps, screenshots, or third-party studio/franchise names
  • Ready for 3 independent peer reviews (peer-review-gate) before maintainer review

🤖 Generated with Claude Code

**@⁠thefafu** on GitHub · 2026-11-30 18:20 UTC · [original](https://github.com/monte-alt/vesper/pull/23) `thefafu:vsp-17-dsp-convolution` → `main` · +830 −24 · 1 files · 50 commits · closed without merging ## Summary - **Claimed Task ID:** `VSP-17` (linked Task Claim issue: #21). Fixes #6. - **What this PR changes:** only `crates/vesper-hle/src/modules/dsp.rs` (its unit tests included). Convolution streams used to complete with silent output, so sounds a title routes through them (phone calls, TVs, radios, voices under water) were mute. - **Activation:** `XDspActivate` reads the impulse response the title hands over with a checked copy (`ReadProcessMemory` on the own process), so a bad pointer refuses the filter instead of faulting. The IR is in the coprocessor's partitioned frequency-domain layout: - per partition, `frames` complex bins of a `2 * frames` FFT, without the Nyquist bin; - partition k is the window `[k * frames, k * frames + 2 * frames)` of the filter; - a stereo IR (option 8) has one run per channel; - the IR ends in a closing partition whose first word is not a finite float. Each partition's first `frames` time samples are rebuilt and kept as a spectrum. - **Submit:** uniformly partitioned overlap-add convolution per channel, with the command's linear gain ramp. Blocks can be interleaved or deinterleaved (option 2). The input is copied out first, so in-place blocks work. Non-finite samples become 0, and the output is held to [-1, 1]. - **No audio-thread stalls:** - Every buffer (filter, input-history ring, FFT scratch, twiddle table) is allocated at activation. A command allocates nothing and takes no lock. - Only the `frames + 1` unique bins of real signals are multiplied, in split real/imaginary runs that vectorize. - Partition k is first needed k blocks in, so a long filter is built one partition per block and activation does not stall either. - Commands still complete synchronously, so the status block never reports an overrun. - **Fallback:** a convolution stream whose filter is unusable passes its input through with the command's gains (one warning per stream, at most 16). `VESPER_DSP_CONVOLUTION=0` does the same for every stream. FFT/IFFT transform streams stay silent as before. - **Basis:** follows the GPL-3.0-or-later host convolution of the lineage this project descends from (used in other forks to restore these voices), reworked as described above. **Cost, measured** (`cargo test --release -p vesper-hle --lib modules::dsp::tests::block_cost -- --ignored --nocapture`, repo `.cargo` config, 7800X3D). This is the longest filter a connection allows (30 s at 48 kHz, stereo, 1,024 frames: 1,407 partitions): | | | |---|---:| | Steady block | 0.61 ms | | Slowest block | 0.92 ms | | Block period | 21.3 ms | | Activation | 4.6 ms | The title's actual stream in game: mono, 1,024 frames, 19 partitions. ## AI Assistance Disclosure - [ ] No AI coding tools were used - [x] AI coding tools were used: Claude Code (Claude Opus 5.5) wrote the change and the tests. I checked the following myself: - I ran every command below locally and read the results. - I drove the game with this build: the caller's voice in phone calls is audible again (silent on `main`). - The log shows the host convolution stream built and no refused filter. ## Benchmark Comparison (Required for perf / GPU / memory changes) This is an audio change, with no GPU or memory path touched. Hardware: Ryzen 7 7800X3D / 32 GB DDR5-4800 / Radeon RX 9060 XT 16 GB (driver 32.0.32029.2010) / Windows 11 build 26300, inbox D3D12. Profile: `scripts\launch.cmd` [1] Series X 1440p Native (HW RT), telemetry on, same restored save. Both drives are on this PR's build: - **Drive 1:** the first on the new `main`. 565 pipelines were dropped while being made; the shader cache was cold. - **Drive 2:** the next one, with the cache settled. | Metric | Drive 1 (cold cache, 408 s) | Drive 2 (settled, 205 s) | |---|---:|---:| | p50 FPS / ms | 20.69 / 48.3 | 17.90 / 55.9 | | p95 Frame Time (ms) | 78.2 | 115.9 | | p99 ms (1% Low FPS) | 989.6 (1.01) | 195.4 (5.12) | | Frames >100 ms (%) | 3.06 % | 8.4 % | | Max >100 ms Streak (s) | 18.9 (loading) | 0.81 | | Peak Private RAM (MB) | 33,530 | 35,820 | Drive 2 spent more time in the dense city. The routes differ, so these numbers describe this hardware rather than compare before and after. **Telemetry reports (cleaned):** Drive 1: [vesper_report_20261130-205954_e9ac841_clean.zip](https://github.com/user-attachments/files/35634724/vesper_report_20261130-205954_e9ac841_clean.zip), Drive 2: [vesper_report_20261130-210901_e9ac841_clean.zip](https://github.com/user-attachments/files/35634726/vesper_report_20261130-210901_e9ac841_clean.zip). The bundles the launcher makes still carry the game folder path, the title executable's file name and the machine name in `drive_telemetry.log` (only `summary.txt` and `env.txt` are redacted). In these copies every file was scrubbed of local paths, machine and user names, the title's folder, executable, id and file names, 64-bit hashes and user ids. Nothing else was changed. I am happy to file the redaction gap as a separate bug against `collect_telemetry.ps1`. ## Mandatory Verification Checklist - [x] Diff obeys `AGENTS.md`, stays inside claimed `VSP-17` files (`dsp.rs` only), and avoids the Maintainer Active Queue (`ROADMAP.md`) - [x] `cargo xtask policy` and `cargo test -p xtask --locked` pass cleanly (xtask: 9 passed) - [x] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` passes with 0 warnings (also without `--all-features`) - [x] `cargo xtask test-fast` passes. `cargo test --workspace --locked --no-fail-fast -- --test-threads=1` gives 1,268 passed, 48 ignored and 2 failed. The 2 failures are in `vesper-shader` (`emit::valu_tests::normalized_buffer_formats_load_correctly_rounded_quotients`, `emit::valu_tests::normalized_codes_truncate_back_to_themselves`, WARP rounding: `0x3ca0a0a0` vs `0x3ca0a0a1`) and fail the same way on an untouched `main` here. The new and existing `dsp` tests: 9 passed, 1 ignored (the cost measurement). - [x] Safety gates remain enabled (`VESPER_WAIT_RESIDENT=textures`, indirect clamping intact); no rendering code touched - [x] Contains zero proprietary assets, keys, dumps, screenshots, or third-party studio/franchise names - [x] Ready for **3 independent peer reviews** (`peer-review-gate`) before maintainer review 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Convolution streams were completed with silent output, so sounds a title
routes through them (phone calls, TVs, radios, voices under water) were
mute. dsp.rs now convolves each block on the host with the impulse response
the title hands over in the coprocessor's partitioned frequency-domain
layout (uniformly partitioned overlap-add, gain ramp, interleaved or
deinterleaved blocks, in-place blocks).

- Everything a block needs is allocated at activation; a command neither
  allocates nor locks, and multiplies only the block + 1 unique bins in
  split real/imaginary runs. A long filter is built one partition per
  block, so activation does not stall either (30 s stereo filter: 0.6 ms
  a block of 21.3 ms).
- A convolution stream whose filter cannot be read passes its input
  through with the command's gains; VESPER_DSP_CONVOLUTION=0 does that
  for every stream. FFT/IFFT transform streams stay silent.
- Non-finite output samples become silence; output is held to [-1, 1].

Fixes #6. Claim: #21.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 18:25:35 +00:00
Author
Owner

@⁠adriaespii on GitHub · 2026-11-30 20:53 UTC · original · approved these changes

Independent 6-point peer review (AGENTS.md Section 6):

  1. Claim & Scope: Verified against VSP-17 / claim #21. Diff touches only crates/vesper-hle/src/modules/dsp.rs (matches ROADMAP.md Primary Files) and stays outside the Maintainer Active Queue.
  2. Safety & Visual Integrity:
    • Reads guest impulse responses safely via ReadProcessMemory (
      ead_samples) and ry_reserve_exact, avoiding faults/OOM on malformed descriptors.
    • Copies input into stream.input before processing so in-place commands (input == output) are sound.
    • Builds filter partitions incrementally (uild_next(), 1 partition/block) and drops self.ir once uilt == partitions, avoiding activation stalls and per-block allocations.
    • Graceful fallback (Work::Pass with linear gain ramp and capped warning log) plus VESPER_DSP_CONVOLUTION=0 escape hatch. No GPU/rendering barriers touched.
  3. Performance & Cost Proof: Worst-case 30 s stereo filter (1,407 partitions) measured at
**@⁠adriaespii** on GitHub · 2026-11-30 20:53 UTC · [original](https://github.com/monte-alt/vesper/pull/23#pullrequestreview-6120371717) · **approved these changes** Independent 6-point peer review (AGENTS.md Section 6): 1. **Claim & Scope:** Verified against VSP-17 / claim #21. Diff touches only crates/vesper-hle/src/modules/dsp.rs (matches ROADMAP.md Primary Files) and stays outside the Maintainer Active Queue. 2. **Safety & Visual Integrity:** - Reads guest impulse responses safely via ReadProcessMemory ( ead_samples) and ry_reserve_exact, avoiding faults/OOM on malformed descriptors. - Copies input into stream.input before processing so in-place commands (input == output) are sound. - Builds filter partitions incrementally (uild_next(), 1 partition/block) and drops self.ir once uilt == partitions, avoiding activation stalls and per-block allocations. - Graceful fallback (Work::Pass with linear gain ramp and capped warning log) plus VESPER_DSP_CONVOLUTION=0 escape hatch. No GPU/rendering barriers touched. 3. **Performance & Cost Proof:** Worst-case 30 s stereo filter (1,407 partitions) measured at
Author
Owner

@⁠adriaespii on GitHub · 2026-11-30 20:53 UTC · original · approved these changes

Independent 6-point peer review (AGENTS.md Section 6):

  1. Claim & Scope: Verified against VSP-17 / claim #21. Diff modifies only crates/vesper-hle/src/modules/dsp.rs (matches ROADMAP.md Primary Files) and does not touch the Maintainer Active Queue.
  2. Safety & Integrity: Title IR reads go through ReadProcessMemory (
    ead_samples) to avoid faulting on unreadable pointers; large allocations use ry_reserve_exact; non-finite IR bins are zeroed ( inite()) and output samples are guarded with is_finite() + .clamp(-1.0, 1.0); separate stream.input / stream.output buffers safely handle in-place commands (input == output). No GPU barriers or clamping paths are modified.
  3. Performance & Benchmarks: Worst-case 30 s stereo filter (1,407 partitions) measured at
**@⁠adriaespii** on GitHub · 2026-11-30 20:53 UTC · [original](https://github.com/monte-alt/vesper/pull/23#pullrequestreview-6120374114) · **approved these changes** Independent 6-point peer review (AGENTS.md Section 6): 1. **Claim & Scope:** Verified against VSP-17 / claim #21. Diff modifies only crates/vesper-hle/src/modules/dsp.rs (matches ROADMAP.md Primary Files) and does not touch the Maintainer Active Queue. 2. **Safety & Integrity:** Title IR reads go through ReadProcessMemory ( ead_samples) to avoid faulting on unreadable pointers; large allocations use ry_reserve_exact; non-finite IR bins are zeroed ( inite()) and output samples are guarded with is_finite() + .clamp(-1.0, 1.0); separate stream.input / stream.output buffers safely handle in-place commands (input == output). No GPU barriers or clamping paths are modified. 3. **Performance & Benchmarks:** Worst-case 30 s stereo filter (1,407 partitions) measured at
Author
Owner

@⁠monte-alt on GitHub · 2026-11-30 20:57 UTC · original

thank you for the audio fix. all 9 DSP tests passed here and i found the 19-partition filter in your log. both drives used the patched build, so i’d keep the claim to audio.

**@⁠monte-alt** on GitHub · 2026-11-30 20:57 UTC · [original](https://github.com/monte-alt/vesper/pull/23#issuecomment-7291721223) thank you for the audio fix. all 9 DSP tests passed here and i found the 19-partition filter in your log. both drives used the patched build, so i’d keep the claim to audio.
github-bot closed this pull request 2026-12-05 07:57:34 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.