victory-simd: AVX2 kernels for changed_runs and the DSP convolution #4473

Closed
github-bot wants to merge 14 commits from github-bot/gh-4472 into main AGit
Owner

@⁠kewb on GitHub · 2026-11-30 20:46 UTC · original
kewb:avx2-acceleration → main · +2293 −873 · 48 files · 14 commits · closed without merging

What it changes

New crate victory-simd: AVX2 kernels with a scalar reference beside each, chosen once at run time.

  • shadow::changed_runs: byte scans 32 bytes per compare. Same runs as before.
  • dsp::convolve: multiply-accumulate, FFT butterflies and output scaling on AVX. Bit-exact to the scalar code; FMA is opt-in.
  • Switches: VICTORY_SIMD=auto|baseline|avx2, VICTORY_SIMD_MEMORY=0, VICTORY_SIMD_AUDIO=0, VICTORY_SIMD_FMA=1, VICTORY_SIMD_VERIFY=1 (see docs/simd.md).
  • Both CI clippy steps pass again (they fail on main): unused Shadow::ranged and copystat mb removed, Fft::run test-only, two lint fixes.
  • Benchmarks (#[ignore = "benchmark"]) for a convolution block and the byte scans.

How it was tested

  • cargo clippy both CI gates, -D warnings: clean.
  • cargo test -p victory-simd: every kernel against its reference (all lengths to a few vectors, unaligned starts, special floats).
  • cargo test -p victory-hle --lib convolve, cargo test -p victory-gpu --lib changed_runs: same output bit for bit on both kernel sets.
  • In game, ~7 min with VICTORY_SIMD_VERIFY=1 (scalar code run beside every AVX2 call): AVX2 kernels active for memory and audio, and their output matched the scalar code exactly on every call.
**@⁠kewb** on GitHub · 2026-11-30 20:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4472) `kewb:avx2-acceleration` → `main` · +2293 −873 · 48 files · 14 commits · closed without merging ## What it changes New crate `victory-simd`: AVX2 kernels with a scalar reference beside each, chosen once at run time. - `shadow::changed_runs`: byte scans 32 bytes per compare. Same runs as before. - `dsp::convolve`: multiply-accumulate, FFT butterflies and output scaling on AVX. Bit-exact to the scalar code; FMA is opt-in. - Switches: `VICTORY_SIMD=auto|baseline|avx2`, `VICTORY_SIMD_MEMORY=0`, `VICTORY_SIMD_AUDIO=0`, `VICTORY_SIMD_FMA=1`, `VICTORY_SIMD_VERIFY=1` (see `docs/simd.md`). - Both CI clippy steps pass again (they fail on main): unused `Shadow::ranged` and copystat `mb` removed, `Fft::run` test-only, two lint fixes. - Benchmarks (`#[ignore = "benchmark"]`) for a convolution block and the byte scans. ## How it was tested - `cargo clippy` both CI gates, `-D warnings`: clean. - `cargo test -p victory-simd`: every kernel against its reference (all lengths to a few vectors, unaligned starts, special floats). - `cargo test -p victory-hle --lib convolve`, `cargo test -p victory-gpu --lib changed_runs`: same output bit for bit on both kernel sets. - In game, ~7 min with `VICTORY_SIMD_VERIFY=1` (scalar code run beside every AVX2 call): AVX2 kernels active for memory and audio, and their output matched the scalar code exactly on every call.
New crate with runtime-dispatched SIMD kernels and scalar references:
- byte prefix scans, used by shadow::changed_runs (byte-exact)
- complex MAC, FFT butterflies and scaling, used by dsp::convolve
  (bit-exact; FMA opt-in)

Switches: VICTORY_SIMD=auto|baseline|avx2, VICTORY_SIMD_MEMORY,
VICTORY_SIMD_AUDIO, VICTORY_SIMD_FMA, VICTORY_SIMD_VERIFY.
See docs/simd.md. The Cargo.lock change invalidates shader caches once.

Also makes both CI clippy gates pass: unused Shadow::ranged and
copystat's mb removed, Fft::run test-only, is_multiple_of and
unwrap_or_default lint fixes, Lowered::loop_caps allowed as test
plumbing. Adds #[ignore = "benchmark"] timings for a convolution block
and the byte scans.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:53:01 +00:00
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:38 UTC · original

Two notes:

  • The one-line #[allow(dead_code, ...)] on Lowered::loop_caps in crates/victory-shader/src/emit/lower.rs is code, not a comment, so it changes the translator fingerprint (crates/victory-gpu/build.rs hashes victory-shader/src without comments). Merging it re-translates every user's shader cache, plus several minutes of warming pipelines again. It is needed for the clippy gate, but it would be worth bundling it with the next real translator change, or saying so in the release notes. (Adding victory-simd to Cargo.lock is fine: only victory-shader's own lock entries are hashed.)
  • changed_runs already compared equal stretches 512 and 8 bytes at a time with slice ==, which compiles to a vectorised memcmp, so most of the gain should be in the differing runs. On a Ryzen 5 5600X + RTX 3060 (Series S, DLSS Performance), merging the title's bytes under flights' writes costs 3-4 ms a frame on a submitting thread that is busy 44-54 ms of a 55-58 ms frame. A before/after of that stage in a game run would show whether the byte scans are a real part of it.
**@⁠IRennie74** on GitHub · 2026-11-30 22:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4472#issuecomment-7294119109) Two notes: - The one-line `#[allow(dead_code, ...)]` on `Lowered::loop_caps` in `crates/victory-shader/src/emit/lower.rs` is code, not a comment, so it changes the translator fingerprint (`crates/victory-gpu/build.rs` hashes `victory-shader/src` without comments). Merging it re-translates every user's shader cache, plus several minutes of warming pipelines again. It is needed for the clippy gate, but it would be worth bundling it with the next real translator change, or saying so in the release notes. (Adding `victory-simd` to `Cargo.lock` is fine: only `victory-shader`'s own lock entries are hashed.) - `changed_runs` already compared equal stretches 512 and 8 bytes at a time with slice `==`, which compiles to a vectorised `memcmp`, so most of the gain should be in the differing runs. On a Ryzen 5 5600X + RTX 3060 (Series S, DLSS Performance), merging the title's bytes under flights' writes costs 3-4 ms a frame on a submitting thread that is busy 44-54 ms of a 55-58 ms frame. A before/after of that stage in a game run would show whether the byte scans are a real part of it.
github-bot closed this pull request 2026-12-01 18:43:29 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:41 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4472#issuecomment-7321339149) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4473
No description provided.