CLI: check for AVX2 before running a title (VICTORY_SKIP_CPU_CHECK=1 to bypass) #238

Merged
dpalacios69 merged 1 commit from upstream-pr/238 into main 2026-11-25 00:08:16 +00:00
dpalacios69 commented 2026-11-24 01:42:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dpalacios69 on 2026-11-24T01:42:41Z.


victory run --execute on a CPU without AVX2 currently starts the title and dies with 0xc000001d (illegal instruction) at the title's first VEX instruction (seen here on a Xeon X5675, which has no AVX). The crash report does not say why. This adds a pre-flight check so the user gets a clear message before any title code runs. It does not touch the AMD-only instruction emulation (clzero, clwb, ...) in the loader.

Change

apps/victory/src/run.rs (+73 lines, one file):

  • When --execute is passed (a plain run without it is unaffected), run() checks is_x86_feature_detected!("avx2") and fails with: this CPU does not support AVX2, which Xbox Series titles require.
  • VICTORY_SKIP_CPU_CHECK=1 bypasses it, for people running under CPU emulation (e.g. Intel SDE). Only the exact value 1 bypasses.
  • The decision is a pure function (check_cpu_features_with) so it is tested without depending on the host CPU.

Tests

4 new unit tests: AVX2 present passes; missing AVX2 fails with an error naming AVX2, Xbox Series and the env var (for unset, "", 0, true); =1 bypasses; the real host check agrees with the detected feature.

  • rustfmt --edition 2024 --check: clean. cargo clippy -p victory --tests (windows-msvc): 0 warnings.
  • cargo xtask policy: ok.
  • cargo test -p victory, cross-built for x86_64-pc-windows-msvc on Linux and run under Wine 11.21: 5 passed, 0 failed.

Not tested

  • A title run with the check enabled: the bypass is covered by unit tests only. The development machine has no AVX2 (Xeon X5675), so the "has AVX2" path was exercised through the host-detection test and the pure function, not on an AVX2 CPU.
  • Non-Windows hosts: the check lives under cfg(windows), like the rest of run.

No game data used. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572678894 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/238). Originally posted by [dpalacios69](https://github.com/dpalacios69) on 2026-11-24T01:42:41Z. --- `victory run --execute` on a CPU without AVX2 currently starts the title and dies with `0xc000001d` (illegal instruction) at the title's first VEX instruction (seen here on a Xeon X5675, which has no AVX). The crash report does not say why. This adds a pre-flight check so the user gets a clear message before any title code runs. It does not touch the AMD-only instruction emulation (clzero, clwb, ...) in the loader. ## Change `apps/victory/src/run.rs` (+73 lines, one file): - When `--execute` is passed (a plain `run` without it is unaffected), `run()` checks `is_x86_feature_detected!("avx2")` and fails with: this CPU does not support AVX2, which Xbox Series titles require. - `VICTORY_SKIP_CPU_CHECK=1` bypasses it, for people running under CPU emulation (e.g. Intel SDE). Only the exact value `1` bypasses. - The decision is a pure function (`check_cpu_features_with`) so it is tested without depending on the host CPU. ## Tests 4 new unit tests: AVX2 present passes; missing AVX2 fails with an error naming AVX2, Xbox Series and the env var (for unset, `""`, `0`, `true`); `=1` bypasses; the real host check agrees with the detected feature. - `rustfmt --edition 2024 --check`: clean. `cargo clippy -p victory --tests` (windows-msvc): 0 warnings. - `cargo xtask policy`: ok. - `cargo test -p victory`, cross-built for `x86_64-pc-windows-msvc` on Linux and run under Wine 11.21: 5 passed, 0 failed. ## Not tested - A title run with the check enabled: the bypass is covered by unit tests only. The development machine has no AVX2 (Xeon X5675), so the "has AVX2" path was exercised through the host-detection test and the pure function, not on an AVX2 CPU. - Non-Windows hosts: the check lives under `cfg(windows)`, like the rest of `run`. No game data used. AI-assisted (Claude Code).
MisaXz commented 2026-11-24 06:55:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MisaXz on 2026-11-24T02:27:08Z.


Test report on real Windows with an AVX2 CPU (the description's runs were under Wine on a CPU without AVX2).

Tested

  • Ryzen 7 9800X3D (has AVX2); Windows 11 Pro 26300 (native); Rust 1.98.1; debug
  • This PR at 397005f (base d2a4bae): cargo test --workspace --no-fail-fast: 268 passed, 0 failed, 4 ignored.
  • cargo test -p victory: 5 passed, 0 failed, including run::tests::cpu_feature_check_matches_host, which here takes the "has AVX2" side on real hardware.

Not tested

  • victory run --execute itself: no title was run (no game files used), so the check's place in run() is covered by the unit tests only.
  • A CPU without AVX2, a release build.

AI use

  • Claude Code (Claude Fable 5.2) ran the tests and wrote this report from their output.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7120156434 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/238#issuecomment-7120156434). Originally posted by [MisaXz](https://github.com/MisaXz) on 2026-11-24T02:27:08Z. --- Test report on real Windows with an AVX2 CPU (the description's runs were under Wine on a CPU without AVX2). **Tested** - Ryzen 7 9800X3D (has AVX2); Windows 11 Pro 26300 (native); Rust 1.98.1; debug - This PR at `397005f` (base `d2a4bae`): `cargo test --workspace --no-fail-fast`: 268 passed, 0 failed, 4 ignored. - `cargo test -p victory`: 5 passed, 0 failed, including `run::tests::cpu_feature_check_matches_host`, which here takes the "has AVX2" side on real hardware. **Not tested** - `victory run --execute` itself: no title was run (no game files used), so the check's place in `run()` is covered by the unit tests only. - A CPU without AVX2, a release build. **AI use** - Claude Code (Claude Fable 5.2) ran the tests and wrote this report from their output.
mercuryVM commented 2026-11-24 09:43:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:43:28Z.

Review: APPROVED


Tested 397005f on Windows 11, RTX 5070, MSVC: the workspace passes (199 outside victory-shader; victory-shader --lib single-threaded: 69), including the four new CPU-check tests and the host check.

  • The check runs only for --execute, before any title code, so victory run without it, and inspect/translate, still work on any CPU. is_x86_feature_detected!("avx2") is the right probe, since Zen 2 titles use VEX/AVX2 freely.
  • An exact "1" bypass for emulators such as Intel SDE is a reasonable escape hatch. Putting the decision in check_cpu_features_with lets the tests run regardless of the host CPU.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6036900389 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/238#pullrequestreview-6036900389). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T09:43:28Z. **Review:** APPROVED --- Tested 397005f on Windows 11, RTX 5070, MSVC: the workspace passes (199 outside `victory-shader`; `victory-shader --lib` single-threaded: 69), including the four new CPU-check tests and the host check. - The check runs only for `--execute`, before any title code, so `victory run` without it, and `inspect`/`translate`, still work on any CPU. `is_x86_feature_detected!("avx2")` is the right probe, since Zen 2 titles use VEX/AVX2 freely. - An exact `"1"` bypass for emulators such as Intel SDE is a reasonable escape hatch. Putting the decision in `check_cpu_features_with` lets the tests run regardless of the host CPU. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:03:08 +00:00
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
Marvisak/VIctory!238
No description provided.