[P1] Enable wide shader loads, tiered buffer lookup, and title priority cap (#276) #374

Merged
Androtim merged 1 commit from upstream-pr/374 into main 2026-12-03 07:20:05 +00:00
Androtim commented 2026-12-03 06:51:42 +00:00 (Migrated from github.com)

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


Adapts three pure CPU/GPU performance improvements cleanly onto main from GPL-3.0 upstream (linkoovosh/LinkoArts-build and TrustNo1/Darner) to address #276:

Summary

  1. Enable opt::WIDE (4-dword scalar buffer loads) in opt::DEFAULT (linkoovosh/LinkoArts-build fd9443e, GPL-3.0):
    • crates/victory-shader/src/emit/bitcode/opt.rs: change opt::DEFAULT from ALL & !WIDE (63) to ALL (127). VICTORY_SHADER_OPT=63 remains available as the clean opt-out toggle.
    • crates/victory-shader/src/emit/mod.rs: update shader_opt() docs and the_clean_up_switch_parses_or_runs_every_pass for DEFAULT == 127.
  2. Size-tiered BTreeMap buffer lookup in shadow.rs (linkoovosh/LinkoArts-build 93c6311, GPL-3.0):
    • crates/victory-gpu/src/shadow.rs: replace full bounded linear scans in BUFFERS with Buffers partitioned into TIERS = [4 << 10, 64 << 10, 1 << 20, 16 << 20] (each backed by BTreeMap<u64, Arc<ShadowBuffer>> + exact live count), preserving ReadMostly sharding and FOUND thread-local fast-path caching.
    • Added unit tests (tiered_lookup_tests::tiered_find_answers_as_the_full_scan, insert_overwrites_same_key_and_unregister_tightens_tier) proving exact equivalence against a full scan across all boundary sizes and shrink/removal edge cases.
  3. Cap non-time-critical title thread priorities (TrustNo1/Darner 2a8566e, GPL-3.0):
    • crates/victory-hle/src/modules/kernel.rs & apps/victory/src/play.rs: add VICTORY_TITLE_PRIORITY_MAX and default it to 0 (THREAD_PRIORITY_NORMAL) in play.rs SETTINGS, capping above-normal title worker threads while leaving THREAD_PRIORITY_TIME_CRITICAL audio/real-time threads untouched.
    • Added unit test priority_max_holds_all_but_time_critical.

(Note: TrustNo1/Darner f9d1276 KEPT_APART was inspected and omitted because MiniVI descriptor/host.rs already retires descriptor slabs via kept_raw + rtas_slots + crate::host::retire outside drop(guard).)

Verification (RTX 4060 Ti 8 GB / 32 GB RAM / active pagefile)

  • cargo xtask policy -> asset policy: 343 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings & --all-features --locked -- -D warnings -> 0 warnings
  • Targeted tests (--locked):
    • victory-hle --lib -- kernel: 11 passed, 0 failed (240 filtered out)
    • victory-shader --lib -- opt the_clean_up_switch scalar_buffer_loads: 13 passed, 0 failed (395 filtered out)
    • victory-gpu --lib -- tiered_lookup_tests shadow: 64 passed, 0 failed, 3 ignored (788 filtered out)
    • victory --bins: 47 passed, 0 failed
  • Clean shader cache 2-minute live gameplay verification (MiniVI.exe --res 4k --dlss quality & --res 1440 --dlss quality, Series X target):
    • 4K DLSS Quality: dedicated_mb peaked at 5962 MB vs min_budget_mb=6764 MB (6797 MB at end, max(ded-bud)=-835 MB, planned headroom 640 MB active), private_commit_mb stayed bounded (8644 -> 20994 MB, max_commit=21056), zero shader translation regressions (only the 5 existing wave64 compute shaders dropped), zero DRED/DeviceRemoved/panics, audio DSP/APU initialized cleanly (256 streams), last 12 steady samples averaged 5.44 fps (gpu_ms=98.39, settling to 51.7-95.2 ms on GPU after initial compile burst).
    • 1440p DLSS Quality: dedicated_mb peaked at 5691 MB vs min_budget_mb=6720 MB (6814 MB at end, max(ded-bud)=-1114 MB), private_commit_mb bounded (8048 -> 19918 MB), zero DRED/DeviceRemoved/panics, audio healthy, last 12 steady samples averaged 7.63 fps (prep_ms=23.8, settling at 7.8-8.5 fps once pipelines built).
    • Inspected 4K & 1440p screenshots confirm no blank white screen, no starburst glare, and normal rendered geometry/lighting.

Credits

  • linkoovosh/LinkoArts-build (fd9443e, 93c6311) — GPL-3.0
  • TrustNo1/Darner (2a8566e) — GPL-3.0
<!-- greyfinch-sync:Androtim/MiniVI:issue:5621527666 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/374). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T06:51:42Z. --- Adapts three pure CPU/GPU performance improvements cleanly onto `main` from GPL-3.0 upstream (`linkoovosh/LinkoArts-build` and `TrustNo1/Darner`) to address #276: ### Summary 1. **Enable `opt::WIDE` (4-dword scalar buffer loads) in `opt::DEFAULT` (`linkoovosh/LinkoArts-build` `fd9443e`, GPL-3.0):** - `crates/victory-shader/src/emit/bitcode/opt.rs`: change `opt::DEFAULT` from `ALL & !WIDE` (`63`) to `ALL` (`127`). `VICTORY_SHADER_OPT=63` remains available as the clean opt-out toggle. - `crates/victory-shader/src/emit/mod.rs`: update `shader_opt()` docs and `the_clean_up_switch_parses_or_runs_every_pass` for `DEFAULT == 127`. 2. **Size-tiered `BTreeMap` buffer lookup in `shadow.rs` (`linkoovosh/LinkoArts-build` `93c6311`, GPL-3.0):** - `crates/victory-gpu/src/shadow.rs`: replace full bounded linear scans in `BUFFERS` with `Buffers` partitioned into `TIERS = [4 << 10, 64 << 10, 1 << 20, 16 << 20]` (each backed by `BTreeMap<u64, Arc<ShadowBuffer>>` + exact live count), preserving `ReadMostly` sharding and `FOUND` thread-local fast-path caching. - Added unit tests (`tiered_lookup_tests::tiered_find_answers_as_the_full_scan`, `insert_overwrites_same_key_and_unregister_tightens_tier`) proving exact equivalence against a full scan across all boundary sizes and shrink/removal edge cases. 3. **Cap non-time-critical title thread priorities (`TrustNo1/Darner` `2a8566e`, GPL-3.0):** - `crates/victory-hle/src/modules/kernel.rs` & `apps/victory/src/play.rs`: add `VICTORY_TITLE_PRIORITY_MAX` and default it to `0` (`THREAD_PRIORITY_NORMAL`) in `play.rs` `SETTINGS`, capping above-normal title worker threads while leaving `THREAD_PRIORITY_TIME_CRITICAL` audio/real-time threads untouched. - Added unit test `priority_max_holds_all_but_time_critical`. *(Note: `TrustNo1/Darner` `f9d1276` `KEPT_APART` was inspected and omitted because `MiniVI` `descriptor/host.rs` already retires descriptor slabs via `kept_raw` + `rtas_slots` + `crate::host::retire` outside `drop(guard)`.)* ### Verification (RTX 4060 Ti 8 GB / 32 GB RAM / active pagefile) - `cargo xtask policy` -> `asset policy: 343 files ok` - `cargo clippy --workspace --all-targets --locked -- -D warnings` & `--all-features --locked -- -D warnings` -> 0 warnings - Targeted tests (`--locked`): - `victory-hle --lib -- kernel`: 11 passed, 0 failed (240 filtered out) - `victory-shader --lib -- opt the_clean_up_switch scalar_buffer_loads`: 13 passed, 0 failed (395 filtered out) - `victory-gpu --lib -- tiered_lookup_tests shadow`: 64 passed, 0 failed, 3 ignored (788 filtered out) - `victory --bins`: 47 passed, 0 failed - Clean shader cache 2-minute live gameplay verification (`MiniVI.exe` `--res 4k --dlss quality` & `--res 1440 --dlss quality`, Series X target): - **4K DLSS Quality**: `dedicated_mb` peaked at `5962 MB` vs `min_budget_mb=6764 MB` (`6797 MB` at end, `max(ded-bud)=-835 MB`, planned headroom `640 MB` active), `private_commit_mb` stayed bounded (`8644 -> 20994 MB`, `max_commit=21056`), zero shader translation regressions (only the 5 existing wave64 compute shaders dropped), zero DRED/`DeviceRemoved`/panics, audio DSP/APU initialized cleanly (`256` streams), last 12 steady samples averaged `5.44 fps` (`gpu_ms=98.39`, settling to `51.7-95.2 ms` on GPU after initial compile burst). - **1440p DLSS Quality**: `dedicated_mb` peaked at `5691 MB` vs `min_budget_mb=6720 MB` (`6814 MB` at end, `max(ded-bud)=-1114 MB`), `private_commit_mb` bounded (`8048 -> 19918 MB`), zero DRED/`DeviceRemoved`/panics, audio healthy, last 12 steady samples averaged `7.63 fps` (`prep_ms=23.8`, settling at `7.8-8.5 fps` once pipelines built). - Inspected 4K & 1440p screenshots confirm no blank white screen, no starburst glare, and normal rendered geometry/lighting. ### Credits - `linkoovosh/LinkoArts-build` (`fd9443e`, `93c6311`) — GPL-3.0 - `TrustNo1/Darner` (`2a8566e`) — GPL-3.0
Androtim commented 2026-12-03 07:02:19 +00:00 (Migrated from github.com)

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


Architect Read-Only Code Audit (3c336ef6, CI 47053295053 GREEN, allowlisted):

  • Code quality: VERIFIED CLEAN (0 bugs found across all 544 lines):
    • shadow.rs Buffers tiered BTreeMap (TIERS = [4 KiB, 64 KiB, 1 MiB, 16 MiB]): exact equivalence to full scan (32,000-query fuzz test + overwrite/shrink test), preserves ReadMostly sharding & FOUND TLS cache, and switches near() from write lock to buffers_read().
    • kernel.rs + play.rs VICTORY_TITLE_PRIORITY_MAX=0: cleanly clamps non-TIME_CRITICAL title worker priorities to THREAD_PRIORITY_NORMAL, skips redundant STARTUP_RAISED tracking, preserves TIME_CRITICAL (15) audio threads, and allows opt-out (off/2).
    • opt.rs + emit/mod.rs (opt::DEFAULT = ALL = 127, VICTORY_SHADER_OPT=63 opt-out): recursive victory-gpu/build.rs (from #372) auto-invalidates pre-#374 disk cache cleanly.
  • One gate before merge (triage: needs gpu test): The posted 2-min runs were clean-cache single-arm runs (7.63 fps 1440p / 5.44 fps 4K including initial shader compile). Please post a quick warm-cache plain --release A/B vs main (15d97184) (1440p and/or 4K) confirming zero FPS/preparing regression on warm cache (especially verifying opt::WIDE + VICTORY_TITLE_PRIORITY_MAX=0 is net-positive/neutral on MiniVI) -> ready to merge immediately once posted!
<!-- greyfinch-sync:Androtim/MiniVI:comment:7370521637 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/374#issuecomment-7370521637). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T07:02:19Z. --- Architect Read-Only Code Audit (`3c336ef6`, CI `47053295053` **GREEN**, allowlisted): - **Code quality: VERIFIED CLEAN (0 bugs found across all 544 lines):** - `shadow.rs` `Buffers` tiered `BTreeMap` (`TIERS = [4 KiB, 64 KiB, 1 MiB, 16 MiB]`): exact equivalence to full scan (32,000-query fuzz test + overwrite/shrink test), preserves `ReadMostly` sharding & `FOUND` TLS cache, and switches `near()` from write lock to `buffers_read()`. - `kernel.rs` + `play.rs` `VICTORY_TITLE_PRIORITY_MAX=0`: cleanly clamps non-`TIME_CRITICAL` title worker priorities to `THREAD_PRIORITY_NORMAL`, skips redundant `STARTUP_RAISED` tracking, preserves `TIME_CRITICAL` (`15`) audio threads, and allows opt-out (`off`/`2`). - `opt.rs` + `emit/mod.rs` (`opt::DEFAULT = ALL` = `127`, `VICTORY_SHADER_OPT=63` opt-out): recursive `victory-gpu/build.rs` (from `#372`) auto-invalidates pre-`#374` disk cache cleanly. - **One gate before merge (`triage: needs gpu test`):** The posted 2-min runs were **clean-cache single-arm runs** (`7.63 fps` 1440p / `5.44 fps` 4K including initial shader compile). Please post a quick **warm-cache plain `--release` A/B vs `main` (`15d97184`)** (1440p and/or 4K) confirming zero FPS/`preparing` regression on warm cache (especially verifying `opt::WIDE` + `VICTORY_TITLE_PRIORITY_MAX=0` is net-positive/neutral on MiniVI) -> ready to merge immediately once posted!
Androtim commented 2026-12-03 07:15:26 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T07:15:26Z.


Deep Static Logic Audit — Pass #8 (3c336ef6): VERIFIED CLEAN (Green Light) — 0 [P0], 0 [P1] blockers (full verdict table posted to Androtim/MiniVI#282).
Verified opt::WIDE (opt::DEFAULT=127, 4B alignment, raw-SRV OOB zeroing, VICTORY_TRANSLATOR + shader_opt() + v2 cache isolation, Wave32/RDNA 4 Wave64 safety), shadow.rs tiered BTreeMap equivalence & ReadMostly/FOUND lock safety, and VICTORY_TITLE_PRIORITY_MAX=0 preserving both victory XMA decoder (HIGHEST=2) and title TIME_CRITICAL (15) audio threads.
Verified descriptor/host.rs already retires kept_raw/kept_pins outside slot & next locks (KEPT_APART omission safe), with full GPL-3.0 credits (linkoovosh/LinkoArts-build, TrustNo1/Darner) and clean-room hygiene.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7370778466 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/374#issuecomment-7370778466). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T07:15:26Z. --- **Deep Static Logic Audit — Pass #8 (`3c336ef6`): VERIFIED CLEAN (Green Light)** — **0 `[P0]`**, **0 `[P1]`** blockers (full verdict table posted to `Androtim/MiniVI#282`). Verified `opt::WIDE` (`opt::DEFAULT=127`, 4B alignment, raw-SRV OOB zeroing, `VICTORY_TRANSLATOR` + `shader_opt()` + `v2` cache isolation, Wave32/RDNA 4 Wave64 safety), `shadow.rs` tiered `BTreeMap` equivalence & `ReadMostly`/`FOUND` lock safety, and `VICTORY_TITLE_PRIORITY_MAX=0` preserving both `victory XMA decoder` (`HIGHEST=2`) and title `TIME_CRITICAL` (`15`) audio threads. Verified `descriptor/host.rs` already retires `kept_raw`/`kept_pins` outside slot & `next` locks (`KEPT_APART` omission safe), with full GPL-3.0 credits (`linkoovosh/LinkoArts-build`, `TrustNo1/Darner`) and clean-room hygiene.
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!374
No description provided.