fix(gpu,formats,hle): stage cross-family BC copies, fix BCPack edges, and hold active decompression uploads #294

Merged
Androtim merged 1 commit from upstream-pr/294 into main 2026-12-01 21:40:42 +00:00
Androtim commented 2026-12-01 21:30:30 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T21:30:30Z.


Summary

Three root-cause visual and texture correctness fixes made default-on (zero opt-in toggles):

  1. Cross-family block-compressed texture copy staging (crates/victory-gpu/src/list.rs, host/place.rs):

    • Stages texture-to-texture copies between distinct BC families with equal 4x4 block byte sizes (e.g. BC3_TYPELESS -> BC7_TYPELESS) through a pooled temporary buffer via HostList::between, avoiding D3D12 CopyTextureRegion format-family refusal that fails command list close / loses the device.
    • Added unit test (list::tests::bc_family_identifies_block_compressed_families_and_sizes) and live D3D12 debug-layer test (list::bc_copy_tests::a_copy_between_bc_families_closes).
  2. BCPack rANS fragment-end & finished-lane edge fixes (crates/victory-formats/src/bcpack.rs):

    • Preserves carried state refills at fragment boundaries (Lane::step_slow) and holds payload refills that leave x < LOW for one drain step before requesting the next fragment header.
    • Prevents a lane that already delivered its final symbol with an empty payload (done & bit != 0 && lane.left == 0) from consuming a trailing header byte intended for a peer lane during the final symbol round (lanes_strip).
    • Updated
      ef_oracle and added targeted unit tests ( ragment_end_refill_below_low_is_kept_and_drained, inished_lane_with_empty_payload_does_not_steal_peer_byte_on_final_symbol).
  3. Default-on DirectStorage write-in-flight texture hold (crates/victory-gpu/src/ds_hold.rs, draw.rs, lib.rs, crates/victory-hle/src/modules/dstorage.rs):

    • Tracks active decompression write ranges (PendingTitleWrite RAII guard) and defers overlapping placed descriptor uploads in draw.rs for one frame at a time (bounded to DS_HOLD_MOST = 16 consecutive holds per write generation and DS_PENDING_MS = 1000 ms; VICTORY_DS_HOLD=0 kill-switch).
    • Prevents partially initialized or stale pages from being uploaded concurrently while decompression is still writing them.

Static & Unit Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: PASS (319 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-formats --lib bcpack::: 17 passed, 0 failed (3 ignored benchmarks/external)
  • cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu --lib list::: 21 passed, 0 failed (including live D3D12 _copy_between_bc_families_closes with debug layer clean)
  • cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu --lib ds_hold::: 2 passed, 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-hle --lib modules::dstorage::: 31 passed, 0 failed (1 ignored benchmark)
  • Dual workspace clippy --workspace --locked --all-targets -- -D warnings (default & --features diagnostics): PASS (0 warnings)
  • objdump -p: standard Windows DLLs only

Paired 60s Plain --release A/B Benchmark (1440p, -PlayParity -LowVram -DlssMode quality) vs main (81661aff)

Metric main (81661aff) PR Branch Delta
Median FPS 13.6 fps (73.5 ms) 14.1 fps (70.9 ms) +0.50 fps (-2.6 ms)
Preparing (median) 34.4 ms 30.4 ms -4.0 ms
Copyback (median) 13.8 ms 13.2 ms -0.6 ms
Max VRAM / Budget min 6012 / 6566 MB (over=0) 5988 / 6624 MB (over=0) -24 MB
oom=false ratio
<!-- greyfinch-sync:Androtim/MiniVI:issue:5594908829 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/294). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-01T21:30:30Z. --- ### Summary Three root-cause visual and texture correctness fixes made default-on (zero opt-in toggles): 1. **Cross-family block-compressed texture copy staging (crates/victory-gpu/src/list.rs, host/place.rs)**: - Stages texture-to-texture copies between distinct BC families with equal 4x4 block byte sizes (e.g. BC3_TYPELESS -> BC7_TYPELESS) through a pooled temporary buffer via HostList::between, avoiding D3D12 CopyTextureRegion format-family refusal that fails command list close / loses the device. - Added unit test (list::tests::bc_family_identifies_block_compressed_families_and_sizes) and live D3D12 debug-layer test (list::bc_copy_tests::a_copy_between_bc_families_closes). 2. **BCPack rANS fragment-end & finished-lane edge fixes (crates/victory-formats/src/bcpack.rs)**: - Preserves carried state refills at fragment boundaries (Lane::step_slow) and holds payload refills that leave x < LOW for one drain step before requesting the next fragment header. - Prevents a lane that already delivered its final symbol with an empty payload (done & bit != 0 && lane.left == 0) from consuming a trailing header byte intended for a peer lane during the final symbol round (lanes_strip). - Updated ef_oracle and added targeted unit tests ( ragment_end_refill_below_low_is_kept_and_drained, inished_lane_with_empty_payload_does_not_steal_peer_byte_on_final_symbol). 3. **Default-on DirectStorage write-in-flight texture hold (crates/victory-gpu/src/ds_hold.rs, draw.rs, lib.rs, crates/victory-hle/src/modules/dstorage.rs)**: - Tracks active decompression write ranges (PendingTitleWrite RAII guard) and defers overlapping placed descriptor uploads in draw.rs for one frame at a time (bounded to DS_HOLD_MOST = 16 consecutive holds per write generation and DS_PENDING_MS = 1000 ms; VICTORY_DS_HOLD=0 kill-switch). - Prevents partially initialized or stale pages from being uploaded concurrently while decompression is still writing them. ### Static & Unit Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: **PASS** (319 files ok) - `cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-formats --lib bcpack::`: **17 passed, 0 failed** (3 ignored benchmarks/external) - `cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu --lib list::`: **21 passed, 0 failed** (including live D3D12 _copy_between_bc_families_closes with debug layer clean) - `cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu --lib ds_hold::`: **2 passed, 0 failed** - `cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-hle --lib modules::dstorage::`: **31 passed, 0 failed** (1 ignored benchmark) - Dual workspace `clippy --workspace --locked --all-targets -- -D warnings` (default & `--features diagnostics`): **PASS (0 warnings)** - `objdump -p`: standard Windows DLLs only ### Paired 60s Plain `--release` A/B Benchmark (1440p, -PlayParity -LowVram -DlssMode quality) vs main (81661aff) | Metric | main (81661aff) | PR Branch | Delta | | --- | ---: | ---: | ---: | | Median FPS | 13.6 fps (73.5 ms) | **14.1 fps (70.9 ms)** | **+0.50 fps (-2.6 ms)** | | Preparing (median) | 34.4 ms | **30.4 ms** | **-4.0 ms** | | Copyback (median) | 13.8 ms | **13.2 ms** | **-0.6 ms** | | Max VRAM / Budget min | 6012 / 6566 MB (over=0) | **5988 / 6624 MB** (over=0) | **-24 MB** | | oom=false ratio |
Androtim commented 2026-12-01 21:40:38 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T21:40:38Z.


Architect & Strict-Gate Review (eda88bd6, CI passing, zero file overlap with #292, clean leaf-locked RAII PendingTitleWrite, live D3D12 debug-layer a_copy_between_bc_families_closes verified, zero opt-in VICTORY_* toggles — VICTORY_DS_HOLD=0 kill-switch only):

Cleanly lands three Wave 2 visual/texture correctness fixes (srmooon/sixmoon cross-family BC staging + crbns/victory-tapin BCPack rANS edge fixes & DS_HOLD) while winning every strict plain --release 60s 1440p gate vs 81661aff:

  • Median FPS: 13.6 -> 14.1 fps (+0.50 fps, -2.6 ms/frame)
  • Preparing / Copyback: 34.4 -> 30.4 ms (-4.0 ms) / 13.8 -> 13.2 ms (-0.6 ms)
  • VRAM & Queue: 6,012 -> 5,988 MB (-24 MB, over = 0 MB, room_false = 0.0%), uploaded 59,304 -> 67,676 (+8,372), final_waiting 2,171 -> 1,977 (-194)
  • Visuals & Stability: 0 crashes/DRED, untranslated = 6 -> 6, 17 bcpack:: + 21 list:: + 2 ds_hold:: + 31 dstorage:: tests pass; 90s --features diagnostics late in-world PNGs directly verified crisp and clean (luma = 98.67, near_black = 0.05%, edge_energy = 7.58, magenta = 0.0%, failed = 0).

Squash-merging into main (will tag v2026.12.01.03 shipping #291 + #293 + #292 + #294 once main CI passes cleanly).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7326619726 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/294#issuecomment-7326619726). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-01T21:40:38Z. --- Architect & Strict-Gate Review (`eda88bd6`, CI passing, zero file overlap with `#292`, clean leaf-locked RAII `PendingTitleWrite`, live D3D12 debug-layer `a_copy_between_bc_families_closes` verified, zero opt-in `VICTORY_*` toggles — `VICTORY_DS_HOLD=0` kill-switch only): Cleanly lands three Wave 2 visual/texture correctness fixes (`srmooon/sixmoon` cross-family BC staging + `crbns/victory-tapin` BCPack rANS edge fixes & `DS_HOLD`) while winning every strict plain `--release` 60s 1440p gate vs `81661aff`: - **Median FPS:** `13.6 -> 14.1 fps` (**`+0.50 fps`**, `-2.6 ms/frame`) - **Preparing / Copyback:** `34.4 -> 30.4 ms` (**`-4.0 ms`**) / `13.8 -> 13.2 ms` (**`-0.6 ms`**) - **VRAM & Queue:** `6,012 -> 5,988 MB` (**`-24 MB`, `over = 0 MB`, `room_false = 0.0%`**), **`uploaded` `59,304 -> 67,676` (`+8,372`)**, **`final_waiting` `2,171 -> 1,977` (`-194`)** - **Visuals & Stability:** `0` crashes/DRED, `untranslated = 6 -> 6`, `17` `bcpack::` + `21` `list::` + `2` `ds_hold::` + `31` `dstorage::` tests pass; 90s `--features diagnostics` late in-world PNGs directly verified crisp and clean (`luma = 98.67`, `near_black = 0.05%`, `edge_energy = 7.58`, `magenta = 0.0%`, `failed = 0`). Squash-merging into `main` (will tag **`v2026.12.01.03`** shipping `#291` + `#293` + `#292` + `#294` once `main` CI passes cleanly).
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
Androtim/MiniVI!294
No description provided.