Skip to content

DSP: convolution streams play the title's IRs (phones, TVs, radios): its IR layout on top of #2483 - #3332

Open
thebigredder wants to merge 6 commits into
Marvisak:mainfrom
thebigredder:dsp-title-ir-layout
Open

thebigredder wants to merge 6 commits into
Marvisak:mainfrom
thebigredder:dsp-title-ir-layout

Conversation

@thebigredder

Copy link
Copy Markdown

What

Phone calls, videos played on the in-game phone, TVs and radios placed in the world are silent: the title plays them through the audio DSP's convolution streams (chad.dll, XDspActivate / XDspSubmitCommand), and dsp.rs returns zeros for those. #240 (by @Quat3rnion), rebased as #2483 (by @kais7654), adds a host convolver; with it alone the title's convolution output is infinite in every sample (loud crackling, and the rest of the mix lost). This PR stacks on #2483's three commits, rebased onto current main, and adds what makes it work with the title's own IRs.

The fixes

  1. The IR's last partition is not a filter. Every IR the title hands over (build 1.0.2.1) ends in one partition of 2 * block floats that starts with the word 0xfffface1, a NaN as a float: 51,200 floats with it at 49,152; 40,960 at 38,912; 83,968 at 81,920. Fed to the convolver, that one NaN makes every output sample non-finite. The filter is now the partitions before the first such one, and any other non-finite word counts as zero. omonkeyz/xbox-emulator (crates/compat/chad, GPL-3.0) independently treats the same word as an IR metadata marker; no code is taken from it.
  2. The partitions are 2-block windows a block apart. Read back from the title's memory while it runs and inverse-transformed, each partition's second half holds the same energy as the next partition's first half (e.g. 4.173e-7 and 4.166e-7; 3.547e-7 and 3.544e-7; 1.896e-7 and 1.896e-7). The overlap-add assumed block samples zero-padded, so every overlap counted twice: a click at each block boundary (a constant crackle). Each window is now cut to its first half, zero-padded; the next partition holds the rest.
  3. Stereo IRs and stream slots, as in JMAN730/project-flamingo 645abbeb: ir_floats is one channel's length, so a stereo-IR activation sliced half the IR and was refused, and each refused activation kept its slot reserved (128 slots, then every activation failed).
  4. shortcut: the convolver's output is kept finite and clamped to [-1, 1], so an IR in a layout not seen yet cannot blast the mix. A refused convolution stream logs a warning.

FFT and IFFT streams still return silence, as in #2483.

Testing

  • In game, Windows 11, RTX 3090 (Series S profile): phone calls, phone videos, TVs and world radios play clean, the rest of the audio unchanged, confirmed by ear over several sessions. Logged convolution output: finite, peaks about 0.01 to 0.15, nothing clipped; before, every sample was infinite. This was on a downstream tree (TaynanGT/Vice-Tay) whose dsp.rs and dsp_convolve.rs match this PR's apart from temporary diagnostics, which are left out here.
  • The same build under Wine / vkd3d-proton (Linux, same card): phone calls and videos play.
  • Unit tests (victory-hle, dsp): 9 pass, among them a new one, the_title_s_ir_layout_convolves_exactly, which encodes an IR as the title lays it out (2-block windows and the trailing marker partition) and checks against direct convolution. With fix 2 taken out it fails (largest error 3.3 against under 0.02 with it), so it tests the fix. Run on Windows binaries under Wine.
  • cargo clippy -p victory-hle --all-targets: no warnings.

Not done: a check against reference output from console hardware; only the title's IRs and its audio by ear.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R8b3MamTtfh5yW9Go2svhi

Quat3rnion and others added 5 commits November 26, 2026 18:35
The console supplies reverb impulse responses as partitioned frequency-domain complex pairs. Decode that layout into a portable partitioned convolver so convolution streams return wet audio instead of silence. FFT/IFFT streams still return silence. Add seven unit tests for the convolver and an end-to-end test through XDspActivate and XDspSubmitCommand.

(cherry picked from commit c3b3c64)
…ccount

The descriptor and memory tests assert a host heap of every slot a
shader indexes (HEAP_VIEWS, HEAP_SAMPLERS) and a copy's views in the
pair range past the dynamic slots — both gone where the host caps its
shader-visible heaps (NVIDIA, HostHeap::new's shortcut): the heap is
smaller and the pair range is empty, so the pairs come from the
dynamic slots and both tests failed on a machine the runtime itself
runs fine on (Marvisak#1744). The size and pair-range assertions say so and
skip there; WARP and every other machine keeps them.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

(cherry picked from commit 945d5b7)
The reverb convolver's build carried five clippy warnings the check
turns into errors (clippy -D warnings): the reset and encode-IR helpers
have their only callers in the tests and are cfg(test) now, the block's
input and spectrum loops read through iterators, the IR slice's SAFETY
note sits next to its unsafe block, and a closure dropped a doubled cast
and its extra parentheses. The convolution itself is untouched: the
seven convolver tests and the two API end-to-end ones pass on Windows.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

(cherry picked from commit 22bfa49)
…1 partition, cut 2-block windows to their first half), stereo IRs whole, a refused stream keeps no slot, output finite and clamped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R8b3MamTtfh5yW9Go2svhi

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested on Windows against origin/main (63bcca4).

The DSP convolution changes look solid and pass all checks:

  • cargo test -p victory-hle --lib modules::dsp -- --test-threads=1: 9 passed, 0 failed.
  • cargo clippy -p victory-hle -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

One scope issue to clean up before merge: this PR also includes unrelated changes in crates/victory-gpu/src/descriptor/host.rs (pair_base + heap-cap test skip) and crates/victory-gpu/src/memory.rs (which appear to belong to a separate GPU/NVIDIA heap-cap PR). Dropping those two victory-gpu files from the branch would keep this PR cleanly scoped to DSP convolution.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@cloph-dsp

Copy link
Copy Markdown

Independent local verification of PR #3332 (DSP: convolution streams play the title's IRs), head ce9cf32.

  • Windows, Rust 1.100.0/MSVC, cargo test --locked, CARGO_BUILD_JOBS=2, per-worktree CARGO_TARGET_DIR (D:\Victory-Contrib\target-3332).
  • cargo test --locked -p victory-hle --lib -- --exact modules::dsp_convolve::tests::the_title_s_ir_layout_convolves_exactly modules::dsp::tests::convolution_through_the_api_returns_wet_audio -> 2 passed, 0 failed, 158 filtered, exit 0.
  • git diff --check origin/main HEAD -> clean.
  • Negative control: both test names are absent from the merge base 63bcca4..., so they are genuinely added by this PR.
  • Both tests are CPU/synthetic (no title audio files); the in-game IR confirmation reported by the author was not independently reproduced. The two victory-gpu files in this PR were outside the tests I exercised.

AI-assisted (Hy4 flash). GPU/driver: N/A for these CPU tests. No game data used.

…bb33): not part of the DSP fix

This reverts commit 2b6bb33 (GPU: the descriptor-heap tests take a host that caps its heaps into account).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R8b3MamTtfh5yW9Go2svhi
@thebigredder

Copy link
Copy Markdown
Author

Thanks @Dukestar69, right: the two victory-gpu files came from #2483's descriptor-heap test commit (2b6bb33), which this branch carried along with #2483's DSP commits. Reverted in a6cf62e; the PR's diff against main is now dsp.rs, dsp_convolve.rs and modules/mod.rs only. Thanks also @cloph-dsp for the independent run.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants