Build: thin LTO, x86-64-v3 on Windows, xxh3 for texture change detection #3009

Open
0xkn0wh3r3 wants to merge 1 commit from upstream-pr/3011 into main
0xkn0wh3r3 commented 2026-11-26 03:24:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T03:24:40Z.


Three build-level changes for the CPU side, none of which changes behaviour.

Changes

  • Thin LTO for release builds (and diag, which inherits it). victory-gpu, victory-hle and victory-shader call each other on per-draw and per-page paths, and without LTO nothing inlines across those crate boundaries. codegen-units stays at its default to keep build times reasonable.
  • target-cpu=x86-64-v3 for the Windows target (.cargo/config.toml). The README already requires an AVX2 CPU, but the host code was built for baseline x86-64 (SSE2). x86-64-v3 is what every AVX2 CPU has: AVX2, BMI1/2, FMA, LZCNT, MOVBE. It's scoped to x86_64-pc-windows-msvc, so builds on other hosts are unaffected. Side effect: the AVX2 check in run.rs becomes always-true, so a CPU without AVX2 would crash instead of getting the message; such a CPU couldn't run the title anyway.
  • xxh3-128 instead of blake3 for texture change detection (texture.rs). Every sampled texture's memory is hashed at each refresh to see whether it changed; a comment there records 8 ms a frame for one case. That hash is never stored across runs, so a fast non-cryptographic 128-bit hash is enough. blake3 stays for the cache keys that are saved to disk. New dependency: xxhash-rust (BSL-1.0, pure Rust).

Testing

  • cargo check --workspace --all-targets --target x86_64-pc-windows-msvc passes.
  • victory-gpu's unit tests, cross-compiled in release with these flags and run under Wine: the texture tests give the same results as on unmodified main.
  • Not measured on Windows hardware yet, so I don't have frame-time numbers for this.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6618821462 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3011). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T03:24:40Z. --- Three build-level changes for the CPU side, none of which changes behaviour. ## Changes - **Thin LTO for release builds** (and `diag`, which inherits it). `victory-gpu`, `victory-hle` and `victory-shader` call each other on per-draw and per-page paths, and without LTO nothing inlines across those crate boundaries. `codegen-units` stays at its default to keep build times reasonable. - **`target-cpu=x86-64-v3` for the Windows target** (`.cargo/config.toml`). The README already requires an AVX2 CPU, but the host code was built for baseline x86-64 (SSE2). x86-64-v3 is what every AVX2 CPU has: AVX2, BMI1/2, FMA, LZCNT, MOVBE. It's scoped to `x86_64-pc-windows-msvc`, so builds on other hosts are unaffected. Side effect: the AVX2 check in `run.rs` becomes always-true, so a CPU without AVX2 would crash instead of getting the message; such a CPU couldn't run the title anyway. - **xxh3-128 instead of blake3 for texture change detection** (`texture.rs`). Every sampled texture's memory is hashed at each refresh to see whether it changed; a comment there records 8 ms a frame for one case. That hash is never stored across runs, so a fast non-cryptographic 128-bit hash is enough. blake3 stays for the cache keys that are saved to disk. New dependency: `xxhash-rust` (BSL-1.0, pure Rust). ## Testing - `cargo check --workspace --all-targets --target x86_64-pc-windows-msvc` passes. - `victory-gpu`'s unit tests, cross-compiled in release with these flags and run under Wine: the `texture` tests give the same results as on unmodified `main`. - Not measured on Windows hardware yet, so I don't have frame-time numbers for this.
fuzeofficlal commented 2026-11-26 04:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:38:36Z.

Review: CHANGES_REQUESTED


Code review on 8c4b2f77 (static source inspection; no builds or runtime tests executed):

  • P2 — Enabling target-cpu=x86-64-v3 globally for x86_64-pc-windows-msvc defeats the runtime CPU check and can fault on CLI commands (.cargo/config.toml:12-13, apps/victory/src/run.rs:29-35, 50-52):
    • Compiling the entire Windows target with -C target-cpu=x86-64-v3 allows LLVM/rustc to emit AVX2/BMI/FMA/MOVBE instructions in startup code, victory inspect/config, and before check_cpu_features() runs — and is_x86_feature_detected!("avx2") can compile down to a constant true under x86-64-v3, breaking the user-facing check/skip path in run.rs.
    • Additionally, an AVX2-only runtime check does not verify the other x86-64-v3 features (FMA, BMI1/2, LZCNT, MOVBE) on constrained/virtualized CPUs.
    • Suggest keeping the default target at baseline and using runtime feature dispatch for hot routines (or shipping an opt-in v3 profile/build rather than forcing x86-64-v3 globally in .cargo/config.toml).
  • The xxhash-rust (xxh3) in-memory texture change-detection switch (leaving persistent BLAKE3 cache keys untouched), Cargo.lock, and ThinLTO profile look clean.
<!-- greyfinch-sync:Marvisak/VIctory:review:6068226987 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3011#pullrequestreview-6068226987). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T03:38:36Z. **Review:** CHANGES_REQUESTED --- Code review on `8c4b2f77` (static source inspection; no builds or runtime tests executed): - **P2 — Enabling `target-cpu=x86-64-v3` globally for `x86_64-pc-windows-msvc` defeats the runtime CPU check and can fault on CLI commands (`.cargo/config.toml:12-13`, `apps/victory/src/run.rs:29-35, 50-52`)**: - Compiling the entire Windows target with `-C target-cpu=x86-64-v3` allows LLVM/rustc to emit AVX2/BMI/FMA/MOVBE instructions in startup code, `victory inspect`/`config`, and before `check_cpu_features()` runs — and `is_x86_feature_detected!("avx2")` can compile down to a constant `true` under `x86-64-v3`, breaking the user-facing check/skip path in `run.rs`. - Additionally, an AVX2-only runtime check does not verify the other `x86-64-v3` features (FMA, BMI1/2, LZCNT, MOVBE) on constrained/virtualized CPUs. - Suggest keeping the default target at baseline and using runtime feature dispatch for hot routines (or shipping an opt-in v3 profile/build rather than forcing `x86-64-v3` globally in `.cargo/config.toml`). - The `xxhash-rust` (`xxh3`) in-memory texture change-detection switch (leaving persistent BLAKE3 cache keys untouched), `Cargo.lock`, and ThinLTO profile look clean.
futurepro62 commented 2026-11-26 04:06:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T03:53:34Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 8c4b2f7 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 866 passed, 0 failed, 10 ignored.
  • No new #[test] functions in the diff.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7182113448 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3011#issuecomment-7182113448). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T03:53:34Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `8c4b2f7` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **866 passed, 0 failed, 10 ignored**. - No new `#[test]` functions in the diff. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
kotekompotek commented 2026-11-26 05:03:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T04:39:47Z.

Review: APPROVED


LGTM — v3 is justified (README already requires AVX2); scoped to msvc target so other hosts unaffected. xxhash-rust 0.8.21 is a stable release, fine for non-persistent change detection; thin LTO reasonable.

<!-- greyfinch-sync:Marvisak/VIctory:review:6068630146 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3011#pullrequestreview-6068630146). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T04:39:47Z. **Review:** APPROVED --- LGTM — v3 is justified (README already requires AVX2); scoped to msvc target so other hosts unaffected. xxhash-rust 0.8.21 is a stable release, fine for non-persistent change detection; thin LTO reasonable.
Marvisak commented 2026-11-26 07:01:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:17:37Z.


Automated triage for the maintainers.

Thanks for the plan. The head is unchanged, so the verdict stays needs work; needs the maintainer's decision (new dependency, .cargo/config.toml, LTO). The split you describe, with numbers for the hash swap and the AVX2 message kept reachable, would let each piece be judged on its own.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184285809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3011#issuecomment-7184285809). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:17:37Z. --- <!-- victory-triage v1 head=a48fb0a63ba6d81506470bd6e57c7d355ddd5578 verdict=needs-work at=2026-11-26T07:19:56Z --> Automated triage for the maintainers. Thanks for the plan. The head is unchanged, so the verdict stays **needs work; needs the maintainer's decision** (new dependency, `.cargo/config.toml`, LTO). The split you describe, with numbers for the hash swap and the AVX2 message kept reachable, would let each piece be judged on its own. --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 07:01:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T06:43:33Z.


Agreed on all four points. Next steps:

  • Split: the three changes are independent, so they'll go in three PRs. The LTO and CPU-target ones are yours to decide as build-config changes. The hash one comes with numbers.
  • AVX2: x86-64-v3 for the whole binary makes the run.rs check unreachable, and a CPU without AVX2 crashes with an illegal instruction instead of getting the message. The CPU-target PR will either drop the global flag or keep the check in code built for baseline x86-64, so the message still appears. Otherwise I'll leave that change out.
  • Hash: before/after numbers for the texture refresh from a diagnostics run on Windows, so the xxh3 swap is judged on a profile, not on the comment's 8 ms.
  • Test report: a fresh one for the new heads.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7184719225 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3011#issuecomment-7184719225). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T06:43:33Z. --- Agreed on all four points. Next steps: - **Split:** the three changes are independent, so they'll go in three PRs. The LTO and CPU-target ones are yours to decide as build-config changes. The hash one comes with numbers. - **AVX2:** `x86-64-v3` for the whole binary makes the `run.rs` check unreachable, and a CPU without AVX2 crashes with an illegal instruction instead of getting the message. The CPU-target PR will either drop the global flag or keep the check in code built for baseline x86-64, so the message still appears. Otherwise I'll leave that change out. - **Hash:** before/after numbers for the texture refresh from a diagnostics run on Windows, so the xxh3 swap is judged on a profile, not on the comment's 8 ms. - **Test report:** a fresh one for the new heads.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3011:upstream-pr/3011'
git switch 'upstream-pr/3011'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3011'
git switch 'upstream-pr/3011'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3011'
git switch 'upstream-pr/3011'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3011'
git switch 'main'
git merge --squash 'upstream-pr/3011'
git switch 'main'
git merge --ff-only 'upstream-pr/3011'
git switch 'main'
git merge 'upstream-pr/3011'
git push origin 'main'
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!3009
No description provided.