Audio DSP: compute the convolutions (TVs, phone calls, reverb) #66

Manually merged
github merged 3 commits from github-bot/gh-66 into gh-pr/66/base 2026-12-01 09:58:25 +00:00 AGit
Owner

@⁠NotBalkanus on GitHub · 2026-12-01 09:41 UTC · original
NotBalkanus:audio-dsp-world-speakers → main · +892 −41 · 8 files · 3 commits · merged 2026-12-01 09:56 UTC

The title sends the sound of the world's speakers (TVs, phone calls) through the audio DSP alone, and its
reverb sends through it too; the DSP's outputs were zeros, so they were silent and the reverb dry
(fxceless/victory-fork#1470). Commit 1 is trustno1 eca45ac (VIctory-NVIDIA), cherry-picked: the response
layout and the overlap-save algorithm; mono 1024-frame convolutions computed; everything the coprocessor
computes that we leave silent fails loudly at activation, counted (crate::loud).

Commit 2 builds on it for the rules here and for the game:

  • Deferred completion — the status block is built for it: the title checks it one block later and counts
    a late command as an overrun. The title's audio thread copies the input block into the stream's queue and
    moves on; a worker thread per stream computes the block and publishes the completion after the output
    (a release fence, then the volatile store the title polls). Before this the compute ran on the title's
    audio thread: mean 1.2-1.4 ms and up to 4.6 ms per block over ~9-10 streams (~40 % duty), and the audio
    broke up.
  • The convolution is built on the worker (rule 11): the response is copied at activation (the title may
    free or reuse its buffer once activation returns) and the parse plus the ~4·parts·4 KB of allocations run
    on the worker's first task, not on the audio thread. Early submits queue behind the build; their
    completions are late — the overrun the title already counts.
  • AVX2+FMA MAC (1.7x over the auto-vectorised scalar loop; the loop is memory-bound; the launcher
    requires AVX2), with a scalar fallback for other builds. Per-block compute time is logged every ~470
    blocks (audio DSP convolve:) against the 21.3 ms block budget.
  • Textbook gain: the fork's by-ear 2.0 was refused (rule 15); the default is 1/2048 with the doubt
    recorded, and VICTORY_DSP_GAIN stays as the A/B until the schedule block's 0xFFFFACE1 word settles
    the hardware's scaling.
  • A command with a null output now completes (loudly) instead of wedging the status poll, and the status
    block is one raw pointer, never borrowed twice.

Verification (rule 27): the crate's tests pass under the Proton wine (tools/proton-run.sh as cargo's
runner; docs/tools.md): 169 passed, the NTFS link-limit test fails as it always does under wine, 2 ignored,
the three integration tests pass. In the game: TVs, a phone call and reverb audible; mean 110-220 µs a block
on the workers, max 2.1 ms (~10 % aggregate duty), no worker failures. The remaining slight breakup is not
this change's: its four F9 marks all landed on 57-237 ms frame stalls (one 655 ms into a frame) while the
convolution compute stayed at or under 2 ms everywhere, and an 85 ms PipeWire buffer (4096/48000) changed
nothing — it belongs to the slow-frame and streaming topics.

Findings: #65 (victory-hle is outside the policy walk; ~40 unlisted VICTORY_* switches).

Note for the squash: commit 1 is Yve's (trustno1-coder) work — please keep the attribution.

**@⁠NotBalkanus** on GitHub · 2026-12-01 09:41 UTC · [original](https://github.com/vktory6/VKtory/pull/66) `NotBalkanus:audio-dsp-world-speakers` → `main` · +892 −41 · 8 files · 3 commits · merged 2026-12-01 09:56 UTC The title sends the sound of the world's speakers (TVs, phone calls) through the audio DSP alone, and its reverb sends through it too; the DSP's outputs were zeros, so they were silent and the reverb dry (fxceless/victory-fork#1470). Commit 1 is trustno1 eca45ac (VIctory-NVIDIA), cherry-picked: the response layout and the overlap-save algorithm; mono 1024-frame convolutions computed; everything the coprocessor computes that we leave silent fails loudly at activation, counted (`crate::loud`). Commit 2 builds on it for the rules here and for the game: - **Deferred completion** — the status block is built for it: the title checks it one block later and counts a late command as an overrun. The title's audio thread copies the input block into the stream's queue and moves on; a worker thread per stream computes the block and publishes the completion after the output (a release fence, then the volatile store the title polls). Before this the compute ran on the title's audio thread: mean 1.2-1.4 ms and up to 4.6 ms per block over ~9-10 streams (~40 % duty), and the audio broke up. - **The convolution is built on the worker** (rule 11): the response is copied at activation (the title may free or reuse its buffer once activation returns) and the parse plus the ~4·parts·4 KB of allocations run on the worker's first task, not on the audio thread. Early submits queue behind the build; their completions are late — the overrun the title already counts. - **AVX2+FMA MAC** (1.7x over the auto-vectorised scalar loop; the loop is memory-bound; the launcher requires AVX2), with a scalar fallback for other builds. Per-block compute time is logged every ~470 blocks (`audio DSP convolve:`) against the 21.3 ms block budget. - **Textbook gain**: the fork's by-ear 2.0 was refused (rule 15); the default is 1/2048 with the doubt recorded, and `VICTORY_DSP_GAIN` stays as the A/B until the schedule block's `0xFFFFACE1` word settles the hardware's scaling. - A command with a null output now completes (loudly) instead of wedging the status poll, and the status block is one raw pointer, never borrowed twice. **Verification** (rule 27): the crate's tests pass under the Proton wine (`tools/proton-run.sh` as cargo's runner; docs/tools.md): 169 passed, the NTFS link-limit test fails as it always does under wine, 2 ignored, the three integration tests pass. In the game: TVs, a phone call and reverb audible; mean 110-220 µs a block on the workers, max 2.1 ms (~10 % aggregate duty), no worker failures. The remaining slight breakup is not this change's: its four F9 marks all landed on 57-237 ms frame stalls (one 655 ms into a frame) while the convolution compute stayed at or under 2 ms everywhere, and an 85 ms PipeWire buffer (4096/48000) changed nothing — it belongs to the slow-frame and streaming topics. Findings: #65 (victory-hle is outside the policy walk; ~40 unlisted `VICTORY_*` switches). Note for the squash: commit 1 is Yve's (trustno1-coder) work — please keep the attribution.
The title sends the sound of speakers in the world (TVs, phone calls) through
the audio DSP alone, and its reverb sends through it too. The DSP's outputs
were zeros, so those were silent and reverb was dry (fxceless/victory-fork#1470).

The impulse responses the title passes to XDspActivate are blocks of 2048
floats: the unscaled 2048-point FFT of a 2048-sample window of the response,
window k covering samples (k-1)*1024..(k+1)*1024, bins 0-1023 interleaved
re/im, then a schedule block that starts with 0xFFFFACE1. Every block of the
title's responses matches its neighbours under that reading. An input block
zero-padded to 2048 samples times window k gives that block's part of the
output k blocks later, in the second half of the inverse FFT.

All the streams the title opened in a session with TVs, a phone call and
reverb were mono convolutions of 1024-frame blocks; those are computed now.
Stereo and 512-frame convolutions and the other transforms still give zeros.
VICTORY_DSP_CONVOLVE=0 turns it off; VICTORY_DSP_GAIN scales it (default 2:
the hardware's scaling is not known, and 1/2048 alone sounded quiet).

(cherry picked from commit eca45ac2fd7280230740992d02f8bf43bf15d3eb)
(trustno1-coder/VIctory-NVIDIA; carried in the foxhound v0.8 squash 4349ab56e)
The convolutions computed in the previous commit cost mean 1.2-1.4 ms and up
to 4.6 ms per block on the title's audio thread (~40 % duty over ~6-7 streams
in a session) and broke the audio up. A computed stream now completes its
commands the way the status block's contract allows: the title's audio thread
copies the input block into the stream's queue and moves on; a worker thread
per stream (victory-dsp-convolve) computes the block and publishes the
completion after the output, with a release fence before the volatile store
the title polls. The input is copied at submit because the title may reuse
its buffer once the command is queued.

The impulse response is copied at activation and parsed, together with the
~4 parts x 4 KB of convolution allocations, on the worker's first task, so a
stream's creation no longer allocates ~23 MB and scans ~11 MB on the audio
thread; the audio thread only copies the response. Submits that arrive
before the build finishes queue behind it (blocks are 21.3 ms apart), and
their completions are simply late - the overrun the title already counts.

The complex multiply-accumulate runs eight bins at a time under AVX2+FMA
(1.7x over the auto-vectorised scalar loop; it is memory-bound, the two
2048-point FFTs are ~30 us of a block). The launcher requires AVX2
(apps/victory run.rs), so the game always takes the wide path; the scalar
path keeps other builds honest. Per-block compute time is logged every ~470
blocks (`audio DSP convolve:`) against the 21.3 ms block budget (rule 19).

What the coprocessor computes and we leave silent fails loudly at activation,
counted (rule 9): stereo and 512-frame convolutions, other block transforms,
an impulse response not in the coprocessor's layout. Non-finite words in a
response or a block's input are zeroed and counted (the hardware's behaviour
is unknown, and a NaN spread through the mix would silence everything). GAIN
defaults to the textbook 1/2048 (the fork's by-ear 2.0 refused, rule 15);
VICTORY_DSP_GAIN stays as the A/B.

Measured in the game (2026-11-30 23:39 and 2026-12-01 09:21, ~9-10 streams):
mean 110-220 us per block on the workers, ~10 % aggregate duty, max 2.1 ms,
no worker failures; TVs, a phone call and reverb audible. The remaining
slight breakup is not this change's: its four F9 marks all landed on
57-237 ms frame stalls (one 655 ms into a frame) while the convolution
compute stayed at or under 2 ms everywhere, and an 85 ms PipeWire buffer
(4096/48000) changed nothing - it belongs to the slow-frame and streaming
topics.

Tests: the crate's suite passes under the Proton wine (tools/proton-run.sh
as cargo's runner; docs/tools.md): 169 passed, the NTFS link-limit test
fails as it always does under wine, 2 ignored, the three integration tests
pass.

Docs: docs/learnings/dsp-convolve.md (the response layout, the algorithm,
the scaling doubt, the verification state), TASKS.md, fork-compare.md,
docs/tools.md (the victory-hle test recipe now runs through proton-run),
and the toggles.txt note that victory-hle is outside the policy walk
(reported: ~40 unlisted switches).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 09:42:34 +00:00
github-bot changed target branch from main to gh-pr/66/base 2026-12-01 09:58:24 +00:00
github manually merged commit ea9f6061cd into gh-pr/66/base 2026-12-01 09:58:25 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 09:57 UTC · original

Merged, thanks to both of you! Yve's commit keeps the attribution (co-author on the squash). It does exactly what was missing: in phone calls the caller's side was silent, and our task and README had that the wrong way round (corrected now). The approach is right: the layout is checked against a direct convolution, the work runs off the title's audio thread on the status block's own tolerance, and refusing the by-ear 2.0 is what the rules ask.

One commit of mine on top (ea9f606):

  • No fallback paths (rule 36): the scalar MAC path goes, because the launcher requires AVX2 (Convolver::new now checks FMA too and is deliberately unhandled without it); the scalar loop stays as the test's reference. The compute-on-the-title's-thread path for a worker that cannot start goes too: that case is loud and silent now.
  • The gain's next step: the task said "A/B 1.0 against 2.0 by ear". It now says to settle it from the hardware (the 0xFFFFACE1 schedule word or a console reference), then make it a constant and drop VICTORY_DSP_GAIN (rule 15).
  • Clippy: is_multiple_of in Convolver::new (the new CI's -D warnings).

Check on the reference system (RX 9070 XT): the PE build and clippy pass, and the house-scene validation run shows no new error. In that run the convolutions took 130 µs a block on average, at most 0.8 ms, against the 21.3 ms budget.

**@⁠vktory6** on GitHub · 2026-12-01 09:57 UTC · [original](https://github.com/vktory6/VKtory/pull/66#issuecomment-7307461318) Merged, thanks to both of you! Yve's commit keeps the attribution (co-author on the squash). It does exactly what was missing: in phone calls the caller's side was silent, and our task and README had that the wrong way round (corrected now). The approach is right: the layout is checked against a direct convolution, the work runs off the title's audio thread on the status block's own tolerance, and refusing the by-ear 2.0 is what the rules ask. One commit of mine on top (ea9f606): - **No fallback paths (rule 36):** the scalar MAC path goes, because the launcher requires AVX2 (`Convolver::new` now checks FMA too and is deliberately unhandled without it); the scalar loop stays as the test's reference. The compute-on-the-title's-thread path for a worker that cannot start goes too: that case is loud and silent now. - **The gain's next step:** the task said "A/B 1.0 against 2.0 by ear". It now says to settle it from the hardware (the 0xFFFFACE1 schedule word or a console reference), then make it a constant and drop `VICTORY_DSP_GAIN` (rule 15). - **Clippy:** `is_multiple_of` in `Convolver::new` (the new CI's `-D warnings`). Check on the reference system (RX 9070 XT): the PE build and clippy pass, and the house-scene validation run shows no new error. In that run the convolutions took 130 µs a block on average, at most 0.8 ms, against the 21.3 ms budget.
This discussion has been locked. Commenting is limited to contributors.
No description provided.