perf(shader,gpu): port interp-live, stream-bound loose windows, and segment-tight list recycling #404

Merged
Androtim merged 8 commits from upstream-pr/404 into main 2026-12-03 22:22:33 +00:00
Androtim commented 2026-12-03 17:50:34 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T17:50:34Z.


Summary

Ports three verified GPL-3.0 / GPL-3.0-or-later GPU shader and low-VRAM optimizations into MiniVI while maintaining strict D3D12 lifetime safety, DXIL soundness, and clean-room asset policy compliance:

  1. Exact first-half pixel interpolation liveness (VICTORY_OPT_INTERP_LIVE, default on):

    • Ported from Bebrik229/VIctory-Ultra 57f9202 (GPL-3.0-or-later).
    • Adds victory_shader::io::raise_structured (wired across emit entrypoints and TRANSLATOR_ENV_KEYS in shader_cache.rs) using Structured::bools ROBDD checks and is_full_vgpr_overwrite to prove when a folded v_interp_p1* temp VGPR is only kept by dead inactive-lane old-destination reads, keeping FP16 pixel inputs on hardware interpolation instead of promoting to SV_Barycentrics + AttributeAtVertex.
    • Hardens is_full_vgpr_overwrite to reject v_permlane16_b32/v_permlanex16_b32 (which preserve inactive lanes when opsel & 2 == 0), Fields::Image { d16, tfe }, Fields::Buffer { lds, tfe }, Fields::Flat { lds }, and Fields::Ds { gds }, and keeps Halves lazy when Structured is absent.
  2. Stream-bounded loose buffer windows (VICTORY_STREAM_BOUND, default on) + sub-cell defaults:

    • Ported from SandBar-developer/VIctory-SandBar e414204 and 9de6e35 (GPL-3.0).
    • Tracks active staged textures in texture::LIVE (next_texture_after) and adds shadow::find_stream (gated on stream_bound() && window() < WINDOW) so unsized root SRV stream lookups stop at the next live texture in the cell (minimum 64 KiB) rather than spanning adjacent textures.
    • Routes draw.rs root SRV lookups (including USER_VIEW_BIAS and diagnostic logging when the slot is in stage.root_srvs) through find_stream so biased streams cannot allocate a second full-cell loose window.
    • Enables VICTORY_WINDOW_KB=256, VICTORY_WINDOW_TAILS=1, and VICTORY_STREAM_BOUND=1 in apps/victory/src/play.rs and scripts/play-minivi.ps1.
  3. WDDM aperture segment back-off (VICTORY_SEGMENT_TIGHT) and immediate landed list recycling:

    • Ported from caiocpl/victory-low-end 58f3e23, b084391, 6fa8ab7, and 8382649 (GPL-3.0).
    • Adds victory_gpu::host::segments (using windows feature Wdk_Graphics_Direct3D + &raw mut q) polling D3DKMTQueryStatistics every 100 ms with 80% on / 70% off hysteresis using u128 overflow-safe math.
    • While an aperture segment is tight, Host::send_late settles flights in the air and trims oldest idle HostLists past 64 off-thread via list::trim_idle (host::drop_aside).
    • Adds Host::Held + HostList::take_held and list::recycle_landed so landed command lists and allocators reset and return to IDLE immediately (landed_lag defaults to 0), while GPU-referenced deferred state, upload memory, descriptor state, host textures, twins, async refreshes, and indirect runs remain retired across bury_lag.

Verification

Verified in MiniVI-wt-eco-vram with C:\msys64\mingw64\bin;C:\msys64\ucrt64\bin; on PATH and RUSTUP_TOOLCHAIN=1.98.1-x86_64-pc-windows-gnu:

  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)
  • cargo xtask policy: passed (355 files ok)
  • cargo test -p victory-gpu --locked -- --test-threads=1: 873 passed; 0 failed; 39 ignored (including new tests for segments, list::drain_idle_excess, host::held_tests, texture::live_tests, shadow::stream_tests, and shader_cache)
  • cargo test -p victory-shader --locked -- --test-threads=1: 419 passed; 3 failed; 6 ignored — all 5 new tests in io::tests and emit::barycentric_tests::fp16_interp_live_eliminates_weighted_and_validates_with_dxil passed (including dxil.dll validation); the 3 failing tests (first_half_values_render_on_hardware_and_warp, rectangles_are_drawn_whole, the_rectangle_stage_is_a_geometry_shader) fail identically on baseline main (21fcafd) against the local Windows SDK 10.0.22000.0\x64\dxil.dll (101.6.2104.33) PSV0 check
  • cargo test -p xtask -p victory --locked: victory 48 passed; 0 failed (census 2 passed; 0 failed), xtask 8 passed; 0 failed
  • cargo test -p victory-core -p victory-formats -p victory-game -p victory-hle -p victory-pe -p victory-pipeline -p victory-loader --lib --locked: all library test suites passed (victory-core 15, victory-formats 69/7 ignored, victory-game 3, victory-hle 249/3 ignored + 1 subprocess, victory-loader lib 66, victory-pe 36, victory-pipeline 13; note victory-loader --test load_probe was excluded from lib run because its nested hle-probe build passes MSVC-only /DELAYLOAD: under the GNU linker)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5631928927 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/404). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T17:50:34Z. --- ## Summary Ports three verified GPL-3.0 / GPL-3.0-or-later GPU shader and low-VRAM optimizations into MiniVI while maintaining strict D3D12 lifetime safety, DXIL soundness, and clean-room asset policy compliance: 1. **Exact first-half pixel interpolation liveness (`VICTORY_OPT_INTERP_LIVE`, default on):** - Ported from **`Bebrik229/VIctory-Ultra` `57f9202`** (GPL-3.0-or-later). - Adds `victory_shader::io::raise_structured` (wired across `emit` entrypoints and `TRANSLATOR_ENV_KEYS` in `shader_cache.rs`) using `Structured::bools` ROBDD checks and `is_full_vgpr_overwrite` to prove when a folded `v_interp_p1*` temp VGPR is only kept by dead inactive-lane old-destination reads, keeping FP16 pixel inputs on hardware interpolation instead of promoting to `SV_Barycentrics` + `AttributeAtVertex`. - Hardens `is_full_vgpr_overwrite` to reject `v_permlane16_b32`/`v_permlanex16_b32` (which preserve inactive lanes when `opsel & 2 == 0`), `Fields::Image { d16, tfe }`, `Fields::Buffer { lds, tfe }`, `Fields::Flat { lds }`, and `Fields::Ds { gds }`, and keeps `Halves` lazy when `Structured` is absent. 2. **Stream-bounded loose buffer windows (`VICTORY_STREAM_BOUND`, default on) + sub-cell defaults:** - Ported from **`SandBar-developer/VIctory-SandBar` `e414204` and `9de6e35`** (GPL-3.0). - Tracks active staged textures in `texture::LIVE` (`next_texture_after`) and adds `shadow::find_stream` (gated on `stream_bound() && window() < WINDOW`) so unsized root SRV stream lookups stop at the next live texture in the cell (minimum 64 KiB) rather than spanning adjacent textures. - Routes `draw.rs` root SRV lookups (including `USER_VIEW_BIAS` and diagnostic logging when the slot is in `stage.root_srvs`) through `find_stream` so biased streams cannot allocate a second full-cell loose window. - Enables `VICTORY_WINDOW_KB=256`, `VICTORY_WINDOW_TAILS=1`, and `VICTORY_STREAM_BOUND=1` in `apps/victory/src/play.rs` and `scripts/play-minivi.ps1`. 3. **WDDM aperture segment back-off (`VICTORY_SEGMENT_TIGHT`) and immediate landed list recycling:** - Ported from **`caiocpl/victory-low-end` `58f3e23`, `b084391`, `6fa8ab7`, and `8382649`** (GPL-3.0). - Adds `victory_gpu::host::segments` (using `windows` feature `Wdk_Graphics_Direct3D` + `&raw mut q`) polling `D3DKMTQueryStatistics` every 100 ms with 80% on / 70% off hysteresis using `u128` overflow-safe math. - While an aperture segment is tight, `Host::send_late` settles flights in the air and trims oldest idle `HostList`s past 64 off-thread via `list::trim_idle` (`host::drop_aside`). - Adds `Host::Held` + `HostList::take_held` and `list::recycle_landed` so landed command lists and allocators reset and return to `IDLE` immediately (`landed_lag` defaults to `0`), while GPU-referenced deferred state, upload memory, descriptor state, host textures, twins, async refreshes, and indirect runs remain retired across `bury_lag`. ## Verification Verified in `MiniVI-wt-eco-vram` with `C:\msys64\mingw64\bin;C:\msys64\ucrt64\bin;` on `PATH` and `RUSTUP_TOOLCHAIN=1.98.1-x86_64-pc-windows-gnu`: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed (0 warnings) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed (0 warnings) - `cargo xtask policy`: passed (`355 files ok`) - `cargo test -p victory-gpu --locked -- --test-threads=1`: `873 passed; 0 failed; 39 ignored` (including new tests for `segments`, `list::drain_idle_excess`, `host::held_tests`, `texture::live_tests`, `shadow::stream_tests`, and `shader_cache`) - `cargo test -p victory-shader --locked -- --test-threads=1`: `419 passed; 3 failed; 6 ignored` — all 5 new tests in `io::tests` and `emit::barycentric_tests::fp16_interp_live_eliminates_weighted_and_validates_with_dxil` passed (including `dxil.dll` validation); the 3 failing tests (`first_half_values_render_on_hardware_and_warp`, `rectangles_are_drawn_whole`, `the_rectangle_stage_is_a_geometry_shader`) fail identically on baseline `main` (`21fcafd`) against the local Windows SDK `10.0.22000.0\x64\dxil.dll` (`101.6.2104.33`) PSV0 check - `cargo test -p xtask -p victory --locked`: `victory` `48 passed; 0 failed` (`census` `2 passed; 0 failed`), `xtask` `8 passed; 0 failed` - `cargo test -p victory-core -p victory-formats -p victory-game -p victory-hle -p victory-pe -p victory-pipeline -p victory-loader --lib --locked`: all library test suites passed (`victory-core` 15, `victory-formats` 69/7 ignored, `victory-game` 3, `victory-hle` 249/3 ignored + 1 subprocess, `victory-loader` lib 66, `victory-pe` 36, `victory-pipeline` 13; note `victory-loader --test load_probe` was excluded from lib run because its nested `hle-probe` build passes MSVC-only `/DELAYLOAD:` under the GNU linker)
Androtim commented 2026-12-03 18:03:47 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T18:03:47Z.


Triage (226628d9, CI check PASS):

  • Clean, 100% title-neutral 3-part port (+1,505/-80, 14 files) with zero opt-in toggles (VICTORY_OPT_INTERP_LIVE, VICTORY_STREAM_BOUND + VICTORY_WINDOW_KB=256/VICTORY_WINDOW_TAILS=1 in play.rs/play-minivi.ps1, and VICTORY_SEGMENT_TIGHT = 80 default / 0 disables). Directly attacks Directive #40 Rank 3 (shadow::LOOSE 4 MiB window slack).
  • Holding auto-merge for Gate 2 Deep Reasoning Audit (#282) + Gate 3 live GPU verification:
    • Gate 2 focus: (a) raise_structured / is_full_vgpr_overwrite soundness on FP16 pixel inputs, (b) texture::LIVE + shadow::find_stream stream bounds (no truncated root SRVs or stale LIVE entries), (c) D3DKMTQueryStatistics aperture polling + Host::Held / list::recycle_landed (landed_lag = 0) GPU-lifetime safety.
    • Gate 3 focus: plain---release 1440p & 4K A/B vs main (21fcafdc) (verify RAM/VRAM drop, FPS, copyback, 0 crashes/DRED) + --features diagnostics visual PNGs.
  • Overlap note: touches apps/victory/src/play.rs, scripts/play-minivi.ps1, host.rs, and list.rs (shared with #403 and #400) — merge sequentially.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7387537638 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/404#issuecomment-7387537638). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T18:03:47Z. --- Triage (`226628d9`, **CI `check` PASS**): - Clean, 100% title-neutral 3-part port (`+1,505/-80`, 14 files) with **zero opt-in toggles** (`VICTORY_OPT_INTERP_LIVE`, `VICTORY_STREAM_BOUND` + `VICTORY_WINDOW_KB=256`/`VICTORY_WINDOW_TAILS=1` in `play.rs`/`play-minivi.ps1`, and `VICTORY_SEGMENT_TIGHT` = `80` default / `0` disables). Directly attacks **Directive #40 Rank 3** (`shadow::LOOSE` 4 MiB window slack). - Holding auto-merge for **Gate 2 Deep Reasoning Audit (`#282`)** + **Gate 3 live GPU verification**: - **Gate 2 focus:** (a) `raise_structured` / `is_full_vgpr_overwrite` soundness on FP16 pixel inputs, (b) `texture::LIVE` + `shadow::find_stream` stream bounds (no truncated root SRVs or stale `LIVE` entries), (c) `D3DKMTQueryStatistics` aperture polling + `Host::Held` / `list::recycle_landed` (`landed_lag = 0`) GPU-lifetime safety. - **Gate 3 focus:** plain-`--release` 1440p & 4K A/B vs `main` (`21fcafdc`) (verify RAM/VRAM drop, FPS, `copyback`, `0` crashes/DRED) + `--features diagnostics` visual PNGs. - *Overlap note:* touches `apps/victory/src/play.rs`, `scripts/play-minivi.ps1`, `host.rs`, and `list.rs` (shared with `#403` and `#400`) — merge sequentially.
Androtim commented 2026-12-03 19:02:19 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T19:02:19Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-rebase · CI (check): none

This PR no longer merges cleanly into main.

To change the verdict: Rebase onto current main and resolve conflicts; CI and triage will run again automatically.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7389059586 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/404#issuecomment-7389059586). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T19:02:19Z. --- <!-- minivi-triage v1 head=8415763885666f39bcab1a5f3faff7d7f0b30403 verdict=needs-rebase ci=none at=2026-12-03T19:02:59Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-rebase` · **CI (`check`):** `none` This PR no longer merges cleanly into `main`. **To change the verdict:** Rebase onto current `main` and resolve conflicts; CI and triage will run again automatically. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-03 19:02:40 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T19:02:40Z.


Marking triage: needs rebase after #400 merged onto main (c59a8027). Once rebased with green CI, ready for Gate 2 re-signoff + Gate 3 GPU A/B.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7389068133 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/404#issuecomment-7389068133). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T19:02:40Z. --- Marking `triage: needs rebase` after `#400` merged onto `main` (`c59a8027`). Once rebased with green CI, ready for Gate 2 re-signoff + Gate 3 GPU A/B.
Androtim commented 2026-12-03 20:01:42 +00:00 (Migrated from github.com)

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


Verified clean merge with main (d09133a4) and CI check PASS. Swapped label to triage: needs gpu test — awaiting Gate 2 re-signoff + Gate 3 1440p/4K plain --release A/B + --features diagnostics PNGs.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7390602893 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/404#issuecomment-7390602893). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T20:01:42Z. --- Verified clean merge with main (d09133a4) and CI check PASS. Swapped label to triage: needs gpu test — awaiting Gate 2 re-signoff + Gate 3 1440p/4K plain --release A/B + --features diagnostics PNGs.
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!404
No description provided.