fix: BC7 dictionary indexing, HDR NaN scrub, and thin-list bake ordering #293

Merged
Androtim merged 1 commit from upstream-pr/293 into main 2026-12-01 20:39:57 +00:00
Androtim commented 2026-12-01 20:29:09 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T20:29:09Z.


Addresses Issue #276 priority item #2 (#150 visual artifacts: wrong/speckled BC7 textures, HDR NaN white spikes, and out-of-order decoration bakes).

Summary of Changes

  1. BC7 dictionary index alignment (crates/victory-formats/src/bcpack.rs):

    • Read all 32 dictionary slots starting right after widths in Tables::parse and RefTables::parse, matching native decoder indexing (instead of skipping one u16 and truncating to 31 slots).
    • Updated bc7_dictionary_indices_line_up unit test accordingly.
    • Adapted from Slaktarn700/SlaktarnVI commit 1afad58 (GPL-3.0).
  2. HDR pixel output NaN -> 0.0 scrub (crates/victory-shader/src/emit/hdr.rs, bitcode.rs, lower_tests.rs):

    • Updated Lower::clamp_hdr (VICTORY_HDR_CLAMP, default-on) so NaN selects 0.0 instead of HDR_MAX (+65024.0), eliminating white crystalline blowout spikes on shaded skin/surfaces while keeping [-65024, 65024] clamping.
    • Added Module::select_true_float helper and pixel_hdr_clamp_scrubs_nan_to_zero unit test.
    • Note on scouted raw-load clamp (lobomfz/VIctory-xmem@245c4a7): does not apply here because crates/victory-shader/src/emit/lower.rs (raw_dwords) uses hardware-bounded D3D12 rawBufferLoad.f32 per 4-dword vector with no self.based whole-load clamp.
  3. Cross-list decoration-bake ordering barrier (crates/victory-gpu/src/pipeline.rs, draw.rs, list/thin.rs):

    • Added pipeline::shaders_any and draw::bake_pipeline to identify decoration-bake pipelines when bound.
    • When VICTORY_THIN=1 binds a bake pipeline (VICTORY_THIN_BAKE: 2 default drains all other live recordings + self; 1 drains self chunks; 0 kill-switch disables), Front::bound flushes queued chunks, unparks any VICTORY_THIN_GATE-held recordings via Recording::caught_up(), and translates bake calls inline synchronously (Recording::translate_one) until unbound.
    • Tracked live begun recordings in LIVE (Weak<Recording>) and signaled crate::queue::line_moved() only after dropping Recording::inner so Lane::wake never nests under Recording::inner (inverse of Lane::unfold -> Recording::back).
    • Adapted from Slaktarn700/SlaktarnVI commit 1afad58 (GPL-3.0), with unit tests bake_pipeline_drains_prior_recordings_and_translates_inline and caught_up_unparks_held_back_recording.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: PASS (318 files ok)
  • Targeted unit tests (--locked):
    • victory-formats --lib bcpack::: 15 passed, 0 failed, 3 ignored
    • victory-shader --lib pixel_hdr_clamp_scrubs_nan_to_zero: 1 passed, 0 failed
    • victory-gpu --lib list::thin::: 11 passed, 0 failed
    • victory-gpu --lib draw::: 11 passed, 0 failed, 1 ignored
  • Dual clippy --workspace --locked --all-targets -- -D warnings (default and --features diagnostics): PASS (0 warnings)
  • objdump -p: standard Windows DLLs only

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

Metric origin/main (40567147) This PR Delta
Median FPS 10.0 fps (100.25 ms) 14.75 fps (67.85 ms) +4.75 fps (+47.5%)
Preparing (median) 37.6 ms 30.4 ms -7.2 ms
Copyback (median) 13.95 ms 12.35 ms -1.6 ms
Max VRAM / Budget min 6379 / 6637 MB (over=0) 6198 / 6668 MB (over=0) -181 MB
room=false ratio 25.0% 0.0% -25.0 pp
Final waiting textures 7612 3755 -3857
Dropped draws (no pipeline) 1363.0 333.0 -1030.0
Crashes / DRED / panics 0 0 0
  • Inline bake translation verified active in log (bake draws translated inline per frame (VICTORY_THIN_BAKE=2): 0.8, waited 2.13 ms catching up prior lists, bakes=16, sources=226, failed=0).

90s --features diagnostics 1440p Visual Check

  • All 6 verifier gates PASSED: crashes=0, used_max=6164 MB (over=0 MB, room_false=0.0%), final_waiting=4007, bakes=8, sources=88, failed=0, pngs=24, lit=21/24, luma=98.19, near_black=0.05%, edge_energy=7.54, magenta=0.0%.
  • Inspected multiple captured world PNG frames (frame-2345.png, frame-2389.png, frame-2425.png, frame-2433.png): crisp world/character geometry and foliage, no BC7 dictionary specks, no white NaN blowout spikes, and no decoration-bake noise.
<!-- greyfinch-sync:Androtim/MiniVI:issue:5593953963 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/293). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-01T20:29:09Z. --- Addresses Issue #276 priority item #2 (`#150` visual artifacts: wrong/speckled BC7 textures, HDR NaN white spikes, and out-of-order decoration bakes). ### Summary of Changes 1. **BC7 dictionary index alignment (`crates/victory-formats/src/bcpack.rs`)**: - Read all 32 dictionary slots starting right after `widths` in `Tables::parse` and `RefTables::parse`, matching native decoder indexing (instead of skipping one `u16` and truncating to 31 slots). - Updated `bc7_dictionary_indices_line_up` unit test accordingly. - Adapted from `Slaktarn700/SlaktarnVI` commit `1afad58` (GPL-3.0). 2. **HDR pixel output `NaN -> 0.0` scrub (`crates/victory-shader/src/emit/hdr.rs`, `bitcode.rs`, `lower_tests.rs`)**: - Updated `Lower::clamp_hdr` (`VICTORY_HDR_CLAMP`, default-on) so `NaN` selects `0.0` instead of `HDR_MAX` (`+65024.0`), eliminating white crystalline blowout spikes on shaded skin/surfaces while keeping `[-65024, 65024]` clamping. - Added `Module::select_true_float` helper and `pixel_hdr_clamp_scrubs_nan_to_zero` unit test. - Note on scouted raw-load clamp (`lobomfz/VIctory-xmem@245c4a7`): does not apply here because `crates/victory-shader/src/emit/lower.rs` (`raw_dwords`) uses hardware-bounded D3D12 `rawBufferLoad.f32` per 4-dword vector with no `self.based` whole-load clamp. 3. **Cross-list decoration-bake ordering barrier (`crates/victory-gpu/src/pipeline.rs`, `draw.rs`, `list/thin.rs`)**: - Added `pipeline::shaders_any` and `draw::bake_pipeline` to identify decoration-bake pipelines when bound. - When `VICTORY_THIN=1` binds a bake pipeline (`VICTORY_THIN_BAKE`: `2` default drains all other live recordings + self; `1` drains self chunks; `0` kill-switch disables), `Front::bound` flushes queued chunks, unparks any `VICTORY_THIN_GATE`-held recordings via `Recording::caught_up()`, and translates bake calls inline synchronously (`Recording::translate_one`) until unbound. - Tracked live begun recordings in `LIVE` (`Weak<Recording>`) and signaled `crate::queue::line_moved()` only after dropping `Recording::inner` so `Lane::wake` never nests under `Recording::inner` (inverse of `Lane::unfold` -> `Recording::back`). - Adapted from `Slaktarn700/SlaktarnVI` commit `1afad58` (GPL-3.0), with unit tests `bake_pipeline_drains_prior_recordings_and_translates_inline` and `caught_up_unparks_held_back_recording`. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: PASS (`318 files ok`) - Targeted unit tests (`--locked`): - `victory-formats --lib bcpack::`: 15 passed, 0 failed, 3 ignored - `victory-shader --lib pixel_hdr_clamp_scrubs_nan_to_zero`: 1 passed, 0 failed - `victory-gpu --lib list::thin::`: 11 passed, 0 failed - `victory-gpu --lib draw::`: 11 passed, 0 failed, 1 ignored - Dual `clippy --workspace --locked --all-targets -- -D warnings` (default and `--features diagnostics`): PASS (0 warnings) - `objdump -p`: standard Windows DLLs only #### Paired 60s Plain `--release` A/B Benchmark (`1440p`, `-PlayParity -LowVram -DlssMode quality`) vs `origin/main` (`40567147`) | Metric | `origin/main` (`40567147`) | This PR | Delta | | --- | ---: | ---: | ---: | | Median FPS | `10.0 fps` (`100.25 ms`) | `14.75 fps` (`67.85 ms`) | **`+4.75 fps` (`+47.5%`)** | | Preparing (median) | `37.6 ms` | `30.4 ms` | **`-7.2 ms`** | | Copyback (median) | `13.95 ms` | `12.35 ms` | **`-1.6 ms`** | | Max VRAM / Budget min | `6379 / 6637 MB` (`over=0`) | `6198 / 6668 MB` (`over=0`) | **`-181 MB`** | | `room=false` ratio | `25.0%` | `0.0%` | **`-25.0 pp`** | | Final waiting textures | `7612` | `3755` | **`-3857`** | | Dropped draws (no pipeline) | `1363.0` | `333.0` | **`-1030.0`** | | Crashes / DRED / panics | `0` | `0` | `0` | - Inline bake translation verified active in log (`bake draws translated inline per frame (VICTORY_THIN_BAKE=2): 0.8, waited 2.13 ms catching up prior lists`, `bakes=16`, `sources=226`, `failed=0`). #### 90s `--features diagnostics` 1440p Visual Check - **All 6 verifier gates PASSED**: `crashes=0`, `used_max=6164 MB` (`over=0 MB`, `room_false=0.0%`), `final_waiting=4007`, `bakes=8`, `sources=88`, `failed=0`, `pngs=24`, `lit=21/24`, `luma=98.19`, `near_black=0.05%`, `edge_energy=7.54`, `magenta=0.0%`. - Inspected multiple captured world PNG frames (`frame-2345.png`, `frame-2389.png`, `frame-2425.png`, `frame-2433.png`): crisp world/character geometry and foliage, no BC7 dictionary specks, no white NaN blowout spikes, and no decoration-bake noise.
Androtim commented 2026-12-01 20:39:53 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T20:39:53Z.


Architect & Strict-Gate Review (fe068304, CI passing, zero new unsafe, lock-order safety verified: LIVE dropped before caught_up() and line_moved() called outside Recording::inner, zero opt-in VICTORY_* toggles):

Directly resolves [USER PRIORITY] #7 (#150 BC7 32-slot dictionary alignment, HDR NaN -> 0.0 blowout scrub, and cross-list decoration-bake ordering barrier with VICTORY_THIN_BAKE=0 kill-switch):

  • All 6 --features diagnostics 90s verifier gates PASSED: crashes = 0, VRAM = 6,164/6,670 MB (over = 0 MB, room_false = 0.0%), final_waiting = 4,007, mapped_rate = 3.56 ms/s, bakes = 8, failed = 0, luma = 98.19, near_black = 0.05%, edge_energy = 7.54, magenta = 0.0%; late in-world PNGs directly verified crisp and clean (detailed skin, clothing, wood, water, foliage, zero speckles/white blowouts).
  • Paired Plain --release 60s 1440p A/B vs 40567147:
    • Median FPS: 10.0 -> 14.75 fps (+47.5%)
    • Preparing / Copyback: 37.6 -> 30.4 ms (-7.2 ms) / 13.95 -> 12.35 ms (-1.6 ms)
    • VRAM & Queue: 6,379 -> 6,198 MB (-181 MB, over = 0 MB, room_false 25.0% -> 0.0%), final_waiting 7,612 -> 3,755 (-3,857), dropped draws 1,363 -> 333 (-1,030), 0 crashes.

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

<!-- greyfinch-sync:Androtim/MiniVI:comment:7325067754 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/293#issuecomment-7325067754). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-01T20:39:53Z. --- Architect & Strict-Gate Review (`fe068304`, CI passing, zero new `unsafe`, lock-order safety verified: `LIVE` dropped before `caught_up()` and `line_moved()` called outside `Recording::inner`, zero opt-in `VICTORY_*` toggles): Directly resolves `[USER PRIORITY]` #7 (`#150` BC7 32-slot dictionary alignment, HDR `NaN -> 0.0` blowout scrub, and cross-list decoration-bake ordering barrier with `VICTORY_THIN_BAKE=0` kill-switch): - **All 6 `--features diagnostics` 90s verifier gates PASSED:** `crashes = 0`, `VRAM = 6,164/6,670 MB` (`over = 0 MB`, `room_false = 0.0%`), `final_waiting = 4,007`, `mapped_rate = 3.56 ms/s`, `bakes = 8`, `failed = 0`, `luma = 98.19`, `near_black = 0.05%`, `edge_energy = 7.54`, `magenta = 0.0%`; late in-world PNGs directly verified crisp and clean (detailed skin, clothing, wood, water, foliage, zero speckles/white blowouts). - **Paired Plain `--release` 60s 1440p A/B vs `40567147`:** - **Median FPS:** `10.0 -> 14.75 fps` (**`+47.5%`**) - **Preparing / Copyback:** `37.6 -> 30.4 ms` (**`-7.2 ms`**) / `13.95 -> 12.35 ms` (**`-1.6 ms`**) - **VRAM & Queue:** `6,379 -> 6,198 MB` (`-181 MB`, `over = 0 MB`, `room_false 25.0% -> 0.0%`), `final_waiting 7,612 -> 3,755` (**`-3,857`**), dropped draws `1,363 -> 333` (`-1,030`), `0` crashes. Squash-merging into `main` (will tag **`v2026.12.01.03`** shipping both `#291` and `#293` 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!293
No description provided.