perf: CPU-side optimizations (BCPack, detiling, inflate, hashing, write-watch journal, DSP) #623

Closed
depaolaluigi123 wants to merge 2 commits from upstream-pr/623 into main
depaolaluigi123 commented 2026-11-28 01:56:31 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by depaolaluigi123 on 2026-11-28T01:56:31Z.


This pull request is a set of performance optimizations across several parts of the layer: BCPack, texture detiling, DirectStorage inflate, texture hashing, the write-watch journal, and the DSP convolution.

How it was made and tested. All of this was written on Linux. None of it has been tested on Windows. I don't own a copy of the game, so every measurement comes from benchmarks on synthetic data made up for the purpose: made-up textures, BCPack streams, memory journals and impulse responses. They ran on one core of an Intel i7-13620H (AVX2, VAES, F16C, no AVX-512). Every change was checked against the original code, with byte-identical output wherever the result has to be exact.

Two commits, split by depth.

  • Commit 1 (perf: faster BCPack, detiling, inflate, hashing, DSP) holds the less invasive changes: local rewrites of hot functions and data structures that keep the same interfaces.
  • Commit 2 (perf: two-level write-watch journal, fused copy+digest asm, BCPack in C, f16 reverb) holds the deeper ones. It replaces a core data structure, adds assembly with its own fault-handling labels, adds C code to a crate that had none, and adds an approximate (opt-in) reverb.

They were kept as two commits so that they can be reviewed, tested and reverted separately.

These changes need testing by the maintainers on Windows to see whether they actually improve performance there and are worth keeping. The numbers below come from isolated benchmarks, not from the running application.

Changes since the first version of this PR

Rebased on main at f9dfb76, and reworked after the reports in this thread:

  • Detiling bug with the XOR modes, fixed. Since main's #932 the pipe/bank XOR swizzles are addressable(), and the transposed detiling took them, but their addresses are not "a row's part plus a column's". They now take the general path. The column offsets use checked_sub as well. A new test detiles every XOR mode of both consoles into 64-byte-aligned rows, the case that made xor_modes_tile_where_offset_points fail now and then; it fails without the fix.
  • Write-watch journal, worst case fixed. The first version went through every chunk number of a range. A range over terabytes of addresses on a sparse journal took milliseconds (up to 4.7 ms a question in a benchmark). Now each chunk also keeps a word of bits marking which of its bit words are in use, and a range over more chunks than there are goes through the chunks there are. That case is now a few microseconds. This is one possible contributor to the hitches reported above, but I could not confirm that from here.
  • Shader translator changes removed. Against the new main they measured no gain (same output, same time), so FxHash in the translator, the DXIL optimiser's dominance table and speed_bench.rs are gone. This PR no longer touches victory-shader.
  • Reverb in half floats is now opt-in (VICTORY_DSP_HALF=1). Its error is up to 1.6e-4 on a_mono_convolution_is_computed's input, over the 1e-4 that test allows. Off by default, that test passes unchanged.
  • Asset policy: "c" added to ALLOWED_EXTENSIONS in xtask/src/policy.rs, for crates/victory-formats/csrc/bcpack_lanes.c. That is your call: if C files should stay out, the C version can be dropped and the Rust lanes() from commit 1 kept.
  • watch.rs is ported onto main's newer ask_rest locking (it holds only the pages it asks about) and onto main's owner-told memory (owned()), and draw.rs keeps main's own heap_buffer_pass rework. memory.rs keeps main's fault budget (Faults), with AddressHash for its tables.

Commit 1: less invasive changes

Area Change Measured (synthetic data, one core)
victory-gpu watch.rs: ranges asked ahead Kept sorted, with a running maximum of the ends, and answered by binary search instead of a linear walk on every writes/asked/nothing_new/ask_more 5,000 lookups: 7x faster (50 ranges), 49x (500), 173x (2,000). Equivalence test included
victory-gpu: per-frame maps The existing AddressHash instead of SipHash in draw.rs, descriptor/host.rs, texture.rs, memory.rs Lookups 3.7-4.4x faster (8-17 → 2-5 ns)
victory-gpu texture.rs digest AES rounds: VAES on 256 bits, AES-NI fallback giving the same value, the old code without AES 2.4-3.3x on data in cache, 1.5-1.7x from RAM. 4,000 variants (zero runs, swaps, single-bit flips) all distinct; test added
victory-hle dstorage.rs inflate libdeflate (C, MIT, whole-buffer decompressor) instead of main's reused zlib-rs state 1.33-1.40x on meshes, text, packed and sparse data, in 64 KiB and 1 MiB chunks. Every case of the existing test holds, plus trailing bytes and a bad checksum
victory-hle dsp/convolve.rs Real-input FFT (realfft) instead of a 2048-point complex one (8x). The partition sum register-blocked with AVX2+FMA (1.3-2.1x). Spectrum rows 64-byte aligned Whole block 1.6-7.6x faster, depending on the response length. Output within about 1e-6 of the original
victory-formats bcpack.rs BC7 block rebuilding: a compile-time nibble table, anchors as a bit mask, a bit writer on two u64. Lane decoding in two passes per round BC7 rebuilding 1.6x (150 → 94 ns/block, all 8 modes, identical on 80,000 blocks). Lanes 1.11x; about 1.3x for BC7 overall
victory-formats texture.rs detiling Standard (S) micro tiles treated as column-major matrices of 16-byte cells: transposed in registers (vperm2i128) and written as whole 64-byte rows, with streaming stores when the destination is 64-byte aligned, as D3D12 upload memory is. Checked against Layout::offset; XOR modes and anything else take the general path Against the new main's general path, 2048² textures: 64KB_S 1.73x (8-byte elements), 2.20x (16), 2.46x (4); 4KB_S 1.92x; D modes unchanged. Tests over 6 swizzle modes × 6 formats, mips, slices, aligned/unaligned destinations, and the XOR modes

Commit 2: deeper changes

Area Change Measured Switch
victory-gpu write-watch journal New watch/pages.rs replaces the journal's BTreeMap with a two-level page table: chunks of 4,096 pages made on first use, each with dense askings, a bit per written page and a bit per word in use. Only words in use are visited: sparse words with tzcnt, dense words compared with AVX2. A range over more chunks than there are goes through the chunks there are Against the BTreeMap, journals of 2,000 and 200,000 pages: ranges of 16 pages 4.3-5.1x; 4,096 pages 0.95-1.7x; a whole full journal 1.05x; a whole sparse journal a few µs, 2.5-3x slower than the tree. Notes 19-28x. Equivalence test against a BTreeMap —
victory-gpu copy + digest in one pass safecopy.rs victory_safe_copy_hash: copies 128-byte blocks of title memory and runs the VAES digest round on them, reading the source once. The source loads sit inside new fault labels; on any fault the caller falls back to copy_mapped + digest. Uses only ymm0-ymm5. texture.rs copy_digest() uses it for view-memory texture refreshes and fingerprint() 1.16-1.39x faster than the safe copy (rep movsb) followed by the VAES digest. Same bytes and same digest for every length. New Windows test: a decommitted page fails cleanly VICTORY_COPY_DIGEST=0
victory-formats BCPack in C csrc/bcpack_lanes.c, built with cc from a new build.rs: the same two-pass schedule, with Rust lanes() kept as reference and fallback decode() 1.17-1.20x on top of commit 1 (BC1 82 → 98 MB/s, BC4 76 → 89, BC7 50.5 → 59.4). Same records as Rust on every layout and on truncated streams VICTORY_BCPACK_C=0
victory-hle reverb in half floats (opt-in) The impulse response stored as f16 (F16C), widened on load: half the memory traffic per block 1.03x (0.2 s response), 1.15x (1 s), 1.97x (3 s), 1.82x (6 s). An approximation: about -73 dB of the peak, bounded at -60 dB by a test VICTORY_DSP_HALF=1

Expected effect

Estimates from the isolated measurements, to be confirmed on Windows:

  • Streaming and loading: about 25% less CPU for zlib inflate, roughly 1.3x (commit 1) then another 1.17-1.2x (commit 2) less for BCPack decoding, and 1.7-2.5x faster detiling of S-mode textures.
  • Submission thread, in CPU-bound scenes: smaller savings from the journal, the map hashing, the ahead index, the texture digest and the fused copy. Very roughly 0.5-2 ms a frame together, but that depends on per-frame counts I could not measure.
  • Audio thread: a convolution stream costs a fraction of what it did.

Checks done here, and what is left

  • On Linux: victory-formats tests pass (59). victory-gpu and victory-hle no longer build on Linux, so the journal and convolution tests were run from copies of the same files.
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc, with and without --all-features: no errors, and no warnings in the files this PR changes. (With -D warnings the build currently stops on a manual_checked_div lint in main's crates/victory-shader/src/emit/lower.rs, which this PR does not touch.)
    • For this check on Linux, the C builds (libdeflate, BCPack) used a stand-in compiler, so they still need a real MSVC build.
  • xtask's asset policy test passes for this PR's files. On main it currently fails on crates/victory-shader/src/emit/lower.rs (over the size limit), independently of this PR.
  • Still to do, on Windows:
    • cargo test --workspace: the safecopy fault test and watch.rs's tests only run there;
    • a real build with MSVC;
    • a before/after comparison of performance, ideally with the switches above one at a time.

Benchmarks to reproduce the BCPack numbers: cargo test --release -p victory-formats bcpack_throughput -- --ignored --nocapture, with and without VICTORY_BCPACK_C=0.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5535579344 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/623). Originally posted by [depaolaluigi123](https://github.com/depaolaluigi123) on 2026-11-28T01:56:31Z. --- This pull request is a set of performance optimizations across several parts of the layer: BCPack, texture detiling, DirectStorage inflate, texture hashing, the write-watch journal, and the DSP convolution. **How it was made and tested.** All of this was written on Linux. **None of it has been tested on Windows.** I don't own a copy of the game, so every measurement comes from benchmarks on synthetic data made up for the purpose: made-up textures, BCPack streams, memory journals and impulse responses. They ran on one core of an Intel i7-13620H (AVX2, VAES, F16C, no AVX-512). Every change was checked against the original code, with byte-identical output wherever the result has to be exact. **Two commits, split by depth.** - **Commit 1** (`perf: faster BCPack, detiling, inflate, hashing, DSP`) holds the less invasive changes: local rewrites of hot functions and data structures that keep the same interfaces. - **Commit 2** (`perf: two-level write-watch journal, fused copy+digest asm, BCPack in C, f16 reverb`) holds the deeper ones. It replaces a core data structure, adds assembly with its own fault-handling labels, adds C code to a crate that had none, and adds an approximate (opt-in) reverb. They were kept as two commits so that they can be reviewed, tested and reverted separately. **These changes need testing by the maintainers on Windows** to see whether they actually improve performance there and are worth keeping. The numbers below come from isolated benchmarks, not from the running application. ## Changes since the first version of this PR Rebased on `main` at `f9dfb76`, and reworked after the reports in this thread: - **Detiling bug with the XOR modes, fixed.** Since main's #932 the pipe/bank XOR swizzles are `addressable()`, and the transposed detiling took them, but their addresses are not "a row's part plus a column's". They now take the general path. The column offsets use `checked_sub` as well. A new test detiles every XOR mode of both consoles into 64-byte-aligned rows, the case that made `xor_modes_tile_where_offset_points` fail now and then; it fails without the fix. - **Write-watch journal, worst case fixed.** The first version went through every chunk number of a range. A range over terabytes of addresses on a sparse journal took milliseconds (up to 4.7 ms a question in a benchmark). Now each chunk also keeps a word of bits marking which of its bit words are in use, and a range over more chunks than there are goes through the chunks there are. That case is now a few microseconds. This is one possible contributor to the hitches reported above, but I could not confirm that from here. - **Shader translator changes removed.** Against the new `main` they measured no gain (same output, same time), so FxHash in the translator, the DXIL optimiser's dominance table and `speed_bench.rs` are gone. This PR no longer touches `victory-shader`. - **Reverb in half floats is now opt-in** (`VICTORY_DSP_HALF=1`). Its error is up to 1.6e-4 on `a_mono_convolution_is_computed`'s input, over the 1e-4 that test allows. Off by default, that test passes unchanged. - **Asset policy:** `"c"` added to `ALLOWED_EXTENSIONS` in `xtask/src/policy.rs`, for `crates/victory-formats/csrc/bcpack_lanes.c`. That is your call: if C files should stay out, the C version can be dropped and the Rust `lanes()` from commit 1 kept. - `watch.rs` is ported onto main's newer `ask_rest` locking (it holds only the pages it asks about) and onto main's owner-told memory (`owned()`), and `draw.rs` keeps main's own `heap_buffer_pass` rework. `memory.rs` keeps main's fault budget (`Faults`), with `AddressHash` for its tables. ## Commit 1: less invasive changes | Area | Change | Measured (synthetic data, one core) | |---|---|---| | **victory-gpu** `watch.rs`: ranges asked ahead | Kept sorted, with a running maximum of the ends, and answered by binary search instead of a linear walk on every `writes`/`asked`/`nothing_new`/`ask_more` | 5,000 lookups: 7x faster (50 ranges), 49x (500), 173x (2,000). Equivalence test included | | **victory-gpu**: per-frame maps | The existing `AddressHash` instead of SipHash in `draw.rs`, `descriptor/host.rs`, `texture.rs`, `memory.rs` | Lookups **3.7-4.4x** faster (8-17 → 2-5 ns) | | **victory-gpu** `texture.rs` `digest` | AES rounds: VAES on 256 bits, AES-NI fallback giving the same value, the old code without AES | **2.4-3.3x** on data in cache, 1.5-1.7x from RAM. 4,000 variants (zero runs, swaps, single-bit flips) all distinct; test added | | **victory-hle** `dstorage.rs` `inflate` | libdeflate (C, MIT, whole-buffer decompressor) instead of main's reused zlib-rs state | **1.33-1.40x** on meshes, text, packed and sparse data, in 64 KiB and 1 MiB chunks. Every case of the existing test holds, plus trailing bytes and a bad checksum | | **victory-hle** `dsp/convolve.rs` | Real-input FFT (`realfft`) instead of a 2048-point complex one (8x). The partition sum register-blocked with AVX2+FMA (1.3-2.1x). Spectrum rows 64-byte aligned | Whole block **1.6-7.6x** faster, depending on the response length. Output within about 1e-6 of the original | | **victory-formats** `bcpack.rs` | BC7 block rebuilding: a compile-time nibble table, anchors as a bit mask, a bit writer on two u64. Lane decoding in two passes per round | BC7 rebuilding **1.6x** (150 → 94 ns/block, all 8 modes, identical on 80,000 blocks). Lanes 1.11x; about 1.3x for BC7 overall | | **victory-formats** `texture.rs` detiling | Standard (S) micro tiles treated as column-major matrices of 16-byte cells: transposed in registers (`vperm2i128`) and written as whole 64-byte rows, with streaming stores when the destination is 64-byte aligned, as D3D12 upload memory is. Checked against `Layout::offset`; XOR modes and anything else take the general path | Against the new main's general path, 2048² textures: 64KB_S **1.73x** (8-byte elements), **2.20x** (16), **2.46x** (4); 4KB_S **1.92x**; D modes unchanged. Tests over 6 swizzle modes × 6 formats, mips, slices, aligned/unaligned destinations, and the XOR modes | ## Commit 2: deeper changes | Area | Change | Measured | Switch | |---|---|---|---| | **victory-gpu** write-watch journal | New `watch/pages.rs` replaces the journal's `BTreeMap` with a two-level page table: chunks of 4,096 pages made on first use, each with dense askings, a bit per written page and a bit per word in use. Only words in use are visited: sparse words with `tzcnt`, dense words compared with AVX2. A range over more chunks than there are goes through the chunks there are | Against the `BTreeMap`, journals of 2,000 and 200,000 pages: ranges of 16 pages **4.3-5.1x**; 4,096 pages **0.95-1.7x**; a whole full journal 1.05x; a whole sparse journal a few µs, **2.5-3x slower** than the tree. Notes 19-28x. Equivalence test against a `BTreeMap` | — | | **victory-gpu** copy + digest in one pass | `safecopy.rs` `victory_safe_copy_hash`: copies 128-byte blocks of title memory and runs the VAES digest round on them, reading the source once. The source loads sit inside new fault labels; on any fault the caller falls back to `copy_mapped` + `digest`. Uses only ymm0-ymm5. `texture.rs` `copy_digest()` uses it for view-memory texture refreshes and `fingerprint()` | **1.16-1.39x** faster than the safe copy (`rep movsb`) followed by the VAES digest. Same bytes and same digest for every length. New Windows test: a decommitted page fails cleanly | `VICTORY_COPY_DIGEST=0` | | **victory-formats** BCPack in C | `csrc/bcpack_lanes.c`, built with `cc` from a new `build.rs`: the same two-pass schedule, with Rust `lanes()` kept as reference and fallback | `decode()` **1.17-1.20x** on top of commit 1 (BC1 82 → 98 MB/s, BC4 76 → 89, BC7 50.5 → 59.4). Same records as Rust on every layout and on truncated streams | `VICTORY_BCPACK_C=0` | | **victory-hle** reverb in half floats (**opt-in**) | The impulse response stored as f16 (F16C), widened on load: half the memory traffic per block | **1.03x** (0.2 s response), **1.15x** (1 s), **1.97x** (3 s), **1.82x** (6 s). An approximation: about -73 dB of the peak, bounded at -60 dB by a test | `VICTORY_DSP_HALF=1` | ## Expected effect Estimates from the isolated measurements, to be confirmed on Windows: - **Streaming and loading**: about 25% less CPU for zlib inflate, roughly 1.3x (commit 1) then another 1.17-1.2x (commit 2) less for BCPack decoding, and 1.7-2.5x faster detiling of S-mode textures. - **Submission thread, in CPU-bound scenes**: smaller savings from the journal, the map hashing, the ahead index, the texture digest and the fused copy. Very roughly 0.5-2 ms a frame together, but that depends on per-frame counts I could not measure. - **Audio thread**: a convolution stream costs a fraction of what it did. ## Checks done here, and what is left - On Linux: `victory-formats` tests pass (59). `victory-gpu` and `victory-hle` no longer build on Linux, so the journal and convolution tests were run from copies of the same files. - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc`, with and without `--all-features`: no errors, and no warnings in the files this PR changes. (With `-D warnings` the build currently stops on a `manual_checked_div` lint in main's `crates/victory-shader/src/emit/lower.rs`, which this PR does not touch.) - For this check on Linux, the C builds (libdeflate, BCPack) used a stand-in compiler, so they still need a real MSVC build. - xtask's asset policy test passes for this PR's files. On main it currently fails on `crates/victory-shader/src/emit/lower.rs` (over the size limit), independently of this PR. - **Still to do, on Windows:** - `cargo test --workspace`: the safecopy fault test and `watch.rs`'s tests only run there; - a real build with MSVC; - a before/after comparison of performance, ideally with the switches above one at a time. Benchmarks to reproduce the BCPack numbers: `cargo test --release -p victory-formats bcpack_throughput -- --ignored --nocapture`, with and without `VICTORY_BCPACK_C=0`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
vladbondarenko97 commented 2026-11-28 03:02:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by vladbondarenko97 on 2026-11-28T03:02:05Z.


Measured on a real Windows PC with a real copy of the game, since the PR says none of this has been tested
on Windows — and one thing that blocks testing it together with the other open performance PRs.

It does not merge with #614. Both rewrite crates/victory-gpu/src/watch.rs, and git merge fails with a
content conflict there (a clean ort merge on the other three files: draw.rs merged automatically). So
#614 and #623 cannot both be applied to main as they stand — worth deciding which one lands first, or
reworking one to sit on top of the other.

The rest of this is a single-run observation, not a verdict, and I would not want it read as one:

  • Environment: RTX 3080 Ti 12 GB (driver 610.60), Windows 11 build 26300, i7-12700KF (20 logical), 64 GB,
    title v1.0.2.1, Series S profile, release build, 240 s per run, median of 5-second world windows.
  • I built origin/main + #630 + #614 + #603 + #620 + #632 (everything except this PR) and ran it with this
    fork's own launcher switch block: 18.0 fps p50 / 55.7 ms against 18.7 fps / 53.5 ms on 64d4931
    with the same block. Copyback improved as #614 advertises (11.5 -> 9.4 ms), which suggests the CPU work it
    removes is real.
  • Caveats that make those numbers weak evidence: #603's x86-64-v3 flags change the translated host shaders,
    so the pipeline cache for that build was cold, and one run per setting is inside the ~9 % run-to-run spread
    reported elsewhere in this project. I have not re-measured it warmed.

So: not a claim that these optimizations are wrong — the copyback figure says otherwise — only that on this
machine, cold, they did not show up in rendered fps, and that the merge conflict is the more useful thing to
know about.

Filed with an AI assistant's help; the figures are from this PC's own run logs.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7232750612 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/623#issuecomment-7232750612). Originally posted by [vladbondarenko97](https://github.com/vladbondarenko97) on 2026-11-28T03:02:05Z. --- Measured on a real Windows PC with a real copy of the game, since the PR says none of this has been tested on Windows — and one thing that blocks testing it together with the other open performance PRs. **It does not merge with #614.** Both rewrite `crates/victory-gpu/src/watch.rs`, and `git merge` fails with a content conflict there (a clean `ort` merge on the other three files: `draw.rs` merged automatically). So #614 and #623 cannot both be applied to `main` as they stand — worth deciding which one lands first, or reworking one to sit on top of the other. The rest of this is a single-run observation, **not a verdict**, and I would not want it read as one: - Environment: RTX 3080 Ti 12 GB (driver 610.60), Windows 11 build 26300, i7-12700KF (20 logical), 64 GB, title v1.0.2.1, Series S profile, release build, 240 s per run, median of 5-second world windows. - I built `origin/main` + #630 + #614 + #603 + #620 + #632 (everything except this PR) and ran it with this fork's own launcher switch block: **18.0 fps p50 / 55.7 ms** against **18.7 fps / 53.5 ms** on `64d4931` with the same block. Copyback improved as #614 advertises (11.5 -> 9.4 ms), which suggests the CPU work it removes is real. - Caveats that make those numbers weak evidence: #603's `x86-64-v3` flags change the translated host shaders, so the pipeline cache for that build was cold, and one run per setting is inside the ~9 % run-to-run spread reported elsewhere in this project. I have not re-measured it warmed. So: not a claim that these optimizations are wrong — the copyback figure says otherwise — only that on this machine, cold, they did not show up in rendered fps, and that the merge conflict is the more useful thing to know about. Filed with an AI assistant's help; the figures are from this PC's own run logs.
depaolaluigi123 commented 2026-11-28 03:27:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by depaolaluigi123 on 2026-11-28T03:27:21Z.


Thanks for taking the time to build and measure this on Windows, and for flagging the conflict.

On the numbers: as you noted, the build you measured includes the other open performance PRs but not this one, so it doesn't tell us yet how these changes behave on Windows. A warm-cache run of main vs main + #623 (or with the per-change switches listed in the description) would be the most useful comparison, if anyone has the chance.

On the conflict with #614: both PRs touch crates/victory-gpu/src/watch.rs — this one replaces the write-watch journal (second commit), #614 changes the refresh path around it. I'm happy to rebase this PR on top of #614 if that one lands first, or to rework the watch.rs part so the two fit together, whichever the maintainers prefer.

Also a heads-up: this PR currently conflicts with main as well — a one-line overlap in crates/victory-hle/src/modules/dsp/convolve.rs, where upstream made the same is_multiple_of change in the meantime. I'll update the branch shortly to resolve it.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233085783 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/623#issuecomment-7233085783). Originally posted by [depaolaluigi123](https://github.com/depaolaluigi123) on 2026-11-28T03:27:21Z. --- Thanks for taking the time to build and measure this on Windows, and for flagging the conflict. On the numbers: as you noted, the build you measured includes the other open performance PRs but not this one, so it doesn't tell us yet how these changes behave on Windows. A warm-cache run of `main` vs `main` + #623 (or with the per-change switches listed in the description) would be the most useful comparison, if anyone has the chance. On the conflict with #614: both PRs touch `crates/victory-gpu/src/watch.rs` — this one replaces the write-watch journal (second commit), #614 changes the refresh path around it. I'm happy to rebase this PR on top of #614 if that one lands first, or to rework the `watch.rs` part so the two fit together, whichever the maintainers prefer. Also a heads-up: this PR currently conflicts with `main` as well — a one-line overlap in `crates/victory-hle/src/modules/dsp/convolve.rs`, where upstream made the same `is_multiple_of` change in the meantime. I'll update the branch shortly to resolve it.
lordnyx0 commented 2026-11-28 04:42:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by lordnyx0 on 2026-11-28T04:42:59Z.


Setup

  • Title v1.0.2.1, Xbox Series S profile, -SeriesS -Dlss off -Build release
    (scripts/play-nvidia.ps1), i.e. the title's FidelityFX upscaler, no Streamline.
  • Hardware: Intel Xeon E5-2680 v4 @ 2.40 GHz (14 cores / 28 threads), RTX 3060 12 GB,
    driver 32.0.16.1656, 32 GB RAM, Windows 11 Pro build 26100.
  • Sample: steady in-world frames only (draws > 1000, 5 s frame-log windows).
  • Build tested: local main = PR head 644ed02 plus four fixes that were needed to make it
    build and pass CI here: HashSet::default() in wave64_tests.rs:642 (E0599 after your rebase),
    f16-aware tolerance in a_mono_convolution_is_computed, c added to the asset-policy allowlist
    for bcpack_lanes.c, and four pre-existing clippy lints. Without the first two, cargo test --workspace
    fails on the unmodified PR head. cargo test --workspace --locked then passed (1131 tests, 0 failed)
    and both CI clippy commands were clean.

Before vs after (medians)

Metric Before (n=53) After (n=38)
FPS 14.0 14.4
ms/frame 71.6 69.3
Preparing (submitting thread) 56.1 ms 54.3 ms
├ copies 28.9 ms / 84.9 MB 27.2 ms / 86.0 MB
├ textures 2.2 ms / 20.3 MB 1.8 ms / 20.2 MB
└ copy-back 15.4 ms / 21.7 MB 15.3 ms / 21.7 MB
Draws/frame 4389 4404

Reading it: about 2.3 ms/frame (~3%) better, almost all of it in copies and texture refresh;
copy-back and its traffic are unchanged. That is inside the ~9% run-to-run spread reported in this
repo, so this is not a clear win from these optimizations — but it is also not a regression.
Caveats: one run per build, scenes were not captured at an identical checkpoint, and both had been
running long enough to warm the pipeline/shader caches. A warm A/B with the per-change switches
(VICTORY_BCPACK_C=0, VICTORY_COPY_DIGEST=0, VICTORY_DSP_HALF=0) would be needed to attribute
the 2 ms to any single change.

AI Assisted: Open Code. || commit 2: testing

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7234214072 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/623#issuecomment-7234214072). Originally posted by [lordnyx0](https://github.com/lordnyx0) on 2026-11-28T04:42:59Z. --- **Setup** - Title v1.0.2.1, Xbox **Series S** profile, `-SeriesS -Dlss off -Build release` (`scripts/play-nvidia.ps1`), i.e. the title's FidelityFX upscaler, no Streamline. - Hardware: Intel **Xeon E5-2680 v4** @ 2.40 GHz (14 cores / 28 threads), **RTX 3060 12 GB**, driver 32.0.16.1656, 32 GB RAM, Windows 11 Pro build 26100. - Sample: steady in-world frames only (draws > 1000, 5 s frame-log windows). - Build tested: local `main` = PR head `644ed02` **plus four fixes** that were needed to make it build and pass CI here: `HashSet::default()` in `wave64_tests.rs:642` (E0599 after your rebase), f16-aware tolerance in `a_mono_convolution_is_computed`, `c` added to the asset-policy allowlist for `bcpack_lanes.c`, and four pre-existing clippy lints. Without the first two, `cargo test --workspace` fails on the unmodified PR head. `cargo test --workspace --locked` then passed (1131 tests, 0 failed) and both CI clippy commands were clean. **Before vs after (medians)** | Metric | Before (n=53) | After (n=38) | |---|---:|---:| | FPS | 14.0 | 14.4 | | ms/frame | 71.6 | 69.3 | | Preparing (submitting thread) | 56.1 ms | 54.3 ms | | ├ copies | 28.9 ms / 84.9 MB | 27.2 ms / 86.0 MB | | ├ textures | 2.2 ms / 20.3 MB | 1.8 ms / 20.2 MB | | └ copy-back | 15.4 ms / 21.7 MB | 15.3 ms / 21.7 MB | | Draws/frame | 4389 | 4404 | **Reading it:** about 2.3 ms/frame (~3%) better, almost all of it in copies and texture refresh; copy-back and its traffic are unchanged. That is inside the ~9% run-to-run spread reported in this repo, so this is not a clear win from these optimizations — but it is also not a regression. Caveats: one run per build, scenes were not captured at an identical checkpoint, and both had been running long enough to warm the pipeline/shader caches. A warm A/B with the per-change switches (`VICTORY_BCPACK_C=0`, `VICTORY_COPY_DIGEST=0`, `VICTORY_DSP_HALF=0`) would be needed to attribute the 2 ms to any single change. AI Assisted: Open Code. || commit 2: testing
SkylerizMe commented 2026-11-28 21:40:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by SkylerizMe on 2026-11-28T21:40:43Z.


Windows, warm cache: main 923e38c against 923e38c + this PR, and a bug to fix when you rebase

PC: Ryzen 9 9950X3D, RTX 5080 16 GB (driver 621.10), 32 GB RAM, Windows 11, 3440x1440.
Settings (both builds): Series S 960x540, DLSS Performance, DLSS frame generation 2x, no frame cap, ray tracing off.
Both builds carry our own additions on top of 923e38c: #1444, #592, the XMA decoder thread at highest priority (from #446), and three commits from KyleS98/VIctory-Neo (write faults ask about one page; a retired-object queue per thread; VICTORY_OWN_CPUS, left off). The only difference between the two builds is this PR.

1. A bug after main's #932. Since #932, addressable() is true for the pipe/bank XOR swizzles, so detile_transposed now takes them. Its "row part + column part" address model doesn't hold for XOR modes: main's own texture::tests::xor_modes_tile_where_offset_points panics with an overflow on v - origin in the col_at line, and in a release build the wrapped offsets would likely scramble textures. What we did: return false on self.desc.swizzle.xor(), and checked_sub(origin) for the column part. After that, all 58 victory-formats tests pass.

2. It doesn't apply cleanly on 923e38c, so this is a hand merge, not your exact code:

  • watch.rs ask_rest: kept main's newer locking (holds only the pages it asks about, reads the journal's ahead without taking it), with your Ahead::holds and the sorted largest-end containment inside it. ask_more uses holds; Ahead derives Clone.
  • bitcode/opt.rs: kept main's version whole. Main reworked the same value-numbering walk today (memory, lane and shared-memory tables), so the dominance-span table is left out.
  • draw.rs, lower.rs: main's fields with your hashers. lds::analyze takes a set with any hasher.

3. Results: about 5 minutes each in the opening, world time only, each build after its own warm-up.

main + our additions + this PR
Median fps 36.5 36.0
After the first 2 minutes 38.7 37.2
Slowest 10%, after 2 minutes 30.9 26.8
Frames over 100 ms (incl. one load freeze each) 9 26
Longest while playing 184 ms 574 ms
Preparing per frame (median) 18.8 ms 17.7 ms

The extra hitches came as 300–570 ms freezes in clusters, about once a minute. No pipelines were being made at those moments, so it isn't a warm-up gap. We didn't find the cause and didn't try the per-change switches one by one. DLSS frame generation reset its frame timer 21 times, against 5. An earlier run on an older base, with only 8 of the CPU's 32 processors enabled, was also choppier: 75 against 10 frames over 100 ms in about 2.5 minutes.

(Written with Claude; numbers are from this PC's logs.)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7246191839 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/623#issuecomment-7246191839). Originally posted by [SkylerizMe](https://github.com/SkylerizMe) on 2026-11-28T21:40:43Z. --- Windows, warm cache: main `923e38c` against `923e38c` + this PR, and a bug to fix when you rebase **PC:** Ryzen 9 9950X3D, RTX 5080 16 GB (driver 621.10), 32 GB RAM, Windows 11, 3440x1440. **Settings (both builds):** Series S 960x540, DLSS Performance, DLSS frame generation 2x, no frame cap, ray tracing off. **Both builds carry our own additions** on top of `923e38c`: #1444, #592, the XMA decoder thread at highest priority (from #446), and three commits from KyleS98/VIctory-Neo (write faults ask about one page; a retired-object queue per thread; `VICTORY_OWN_CPUS`, left off). The only difference between the two builds is this PR. **1. A bug after main's #932.** Since #932, `addressable()` is true for the pipe/bank XOR swizzles, so `detile_transposed` now takes them. Its "row part + column part" address model doesn't hold for XOR modes: main's own `texture::tests::xor_modes_tile_where_offset_points` panics with an overflow on `v - origin` in the `col_at` line, and in a release build the wrapped offsets would likely scramble textures. What we did: return false on `self.desc.swizzle.xor()`, and `checked_sub(origin)` for the column part. After that, all 58 victory-formats tests pass. **2. It doesn't apply cleanly on `923e38c`, so this is a hand merge, not your exact code:** - `watch.rs` `ask_rest`: kept main's newer locking (holds only the pages it asks about, reads the journal's `ahead` without taking it), with your `Ahead::holds` and the sorted largest-end containment inside it. `ask_more` uses `holds`; `Ahead` derives `Clone`. - `bitcode/opt.rs`: kept main's version whole. Main reworked the same value-numbering walk today (memory, lane and shared-memory tables), so the dominance-span table is left out. - `draw.rs`, `lower.rs`: main's fields with your hashers. `lds::analyze` takes a set with any hasher. **3. Results:** about 5 minutes each in the opening, world time only, each build after its own warm-up. | | main + our additions | + this PR | |---|---:|---:| | Median fps | 36.5 | 36.0 | | After the first 2 minutes | 38.7 | 37.2 | | Slowest 10%, after 2 minutes | 30.9 | 26.8 | | Frames over 100 ms (incl. one load freeze each) | 9 | 26 | | Longest while playing | 184 ms | 574 ms | | Preparing per frame (median) | 18.8 ms | 17.7 ms | The extra hitches came as 300–570 ms freezes in clusters, about once a minute. No pipelines were being made at those moments, so it isn't a warm-up gap. We didn't find the cause and didn't try the per-change switches one by one. DLSS frame generation reset its frame timer 21 times, against 5. An earlier run on an older base, with only 8 of the CPU's 32 processors enabled, was also choppier: 75 against 10 frames over 100 ms in about 2.5 minutes. (Written with Claude; numbers are from this PC's logs.)
depaolaluigi123 commented 2026-11-28 23:19:09 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by depaolaluigi123 on 2026-11-28T23:19:09Z.


Thanks @lordnyx0 and @SkylerizMe for the detailed Windows runs. They found real problems, and the branch is now updated (rebased on main at d4b5d51):

  • XOR detiling bug: fixed as you suggested. detile_transposed returns false for XOR layouts, and the column offsets use checked_sub. A new test detiles every XOR mode of both consoles into 64-byte-aligned rows, and it fails without the fix.
  • wave64_tests.rs E0599: gone, because this PR no longer touches victory-shader. Against the new main the translator changes measured no gain, so I removed them. That also matches what you did with opt.rs.
  • a_mono_convolution_is_computed: the f16 reverb is now opt-in (VICTORY_DSP_HALF=1), so that test passes unchanged with the default settings.
  • Asset policy: "c" is added to the allowlist for bcpack_lanes.c and called out in the description as the maintainers' decision.

About the 300–570 ms freezes, I can't reproduce them here, so I can't say what causes them. One thing I did find: on a sparse journal, the first version of the two-level journal (watch/pages.rs) took milliseconds to answer a range spanning terabytes of addresses (up to 4.7 ms per query in a benchmark). It now visits only the chunks that exist, which takes a few microseconds. That may or may not be related.

If you get the chance, a warm run of the new head (ba9ebf1) on Windows would be really useful, ideally also one with each of these off:

  • VICTORY_COPY_DIGEST=0: fused copy+digest
  • VICTORY_BCPACK_C=0: BCPack in C

That would show whether the hitches are still there and whether one of these changes is behind them.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247349893 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/623#issuecomment-7247349893). Originally posted by [depaolaluigi123](https://github.com/depaolaluigi123) on 2026-11-28T23:19:09Z. --- Thanks @lordnyx0 and @SkylerizMe for the detailed Windows runs. They found real problems, and the branch is now updated (rebased on `main` at `d4b5d51`): - **XOR detiling bug:** fixed as you suggested. `detile_transposed` returns false for XOR layouts, and the column offsets use `checked_sub`. A new test detiles every XOR mode of both consoles into 64-byte-aligned rows, and it fails without the fix. - **`wave64_tests.rs` E0599:** gone, because this PR no longer touches `victory-shader`. Against the new `main` the translator changes measured no gain, so I removed them. That also matches what you did with `opt.rs`. - **`a_mono_convolution_is_computed`:** the f16 reverb is now opt-in (`VICTORY_DSP_HALF=1`), so that test passes unchanged with the default settings. - **Asset policy:** `"c"` is added to the allowlist for `bcpack_lanes.c` and called out in the description as the maintainers' decision. **About the 300–570 ms freezes**, I can't reproduce them here, so I can't say what causes them. One thing I did find: on a sparse journal, the first version of the two-level journal (`watch/pages.rs`) took milliseconds to answer a range spanning terabytes of addresses (up to 4.7 ms per query in a benchmark). It now visits only the chunks that exist, which takes a few microseconds. That may or may not be related. If you get the chance, a warm run of the new head (`ba9ebf1`) on Windows would be really useful, ideally also one with each of these off: - `VICTORY_COPY_DIGEST=0`: fused copy+digest - `VICTORY_BCPACK_C=0`: BCPack in C That would show whether the hitches are still there and whether one of these changes is behind them.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!623
No description provided.