gpu/shadow: saturate parallel compare first cut at span start #37

Merged
Androtim merged 1 commit from upstream-pr/37 into main 2026-11-28 13:16:15 +00:00
Androtim commented 2026-11-28 10:58:55 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T10:58:55Z.


Summary

Port rustno1-coder/VIctory-NVIDIA 78e99b9 (from kelvaroq 009-shadow-compare.patch / xceless/victory-fork PR #1407 81d54b0):

  • In crates/victory-gpu/src/shadow.rs, extract scan_boundary(start, from, at) using t.saturating_sub((start + at) % PIECE).max(from) for multi-threaded shadow copyback comparison so unaligned span starts (start % PIECE != 0, rom == 0) do not underflow in release builds and skip the first piece.
  • Added unit test shadow::difference_tests::unaligned_parallel_scan_covers_the_first_piece.

Rig Specs Tested On

  • CPU: 13th Gen Intel(R) Core(TM) i7-13700F
  • GPU & VRAM: NVIDIA GeForce RTX 4060 Ti (8 GiB VRAM)
  • System RAM: 32 GiB
  • OS & GPU Driver: Windows 11 Home (Build 26300) / Driver 32.0.16.2124

Run Settings & Profile

  • Build & Commit SHA:
    elease (and
    elease --features diagnostics) @ $sha
  • Console Profile & Internal Resolution / Scale: series-s (Quality scale .6666667, title output 960x540)
  • Ray Tracing: off
  • Upscaling: DLSS quality (Streamline 2.14.16)
  • Frame Generation: off
  • Launcher Command / Preset & Extra VICTORY_ Overrides:* erify-world.ps1 play.rs SETTINGS preset + VICTORY_CARD_ACCOUNTING=1, VICTORY_D3D12_DRED=light, VICTORY_SKIP_BINK=1 (pr37-shadow-scan-boundary)
  • Scene / Area & Session Length: Mission-1 golden save (coastal world / balcony), 75s in-world after world entry (draws >= 500, 16 windows)

Measurements & Verification

  • Base FPS (without Frame Gen): median 11.3 fps (mean 10.02 fps, steady balcony 10.7–12.3 fps across final 12 windows) vs 8.9 fps baseline (+2.40 fps); rame-8102.png & rame-9134.png visually clean (luma=103.33, edge_energy=7.21,
    ear_black=0.0%, magenta=0.0%)
  • Frame-Gen FPS (if enabled): off
  • VRAM / RAM Usage: peak 5972 MB / min budget 6939 MB ( MB over budget; 5965 MB VRAM + 5388 MB shared in final copystat line), inal_waiting=1562 (vs 7121 baseline)
  • Crashes / DRED Resets: (crashes=0,
    o_host_texture_errors=0)
  • Automated Checks:
    • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy (sset policy: 294 files ok)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask (6 passed; 0 failed)
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features victory-gpu/diagnostics -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- --test-threads=1 (449 passed; 0 failed; 36 ignored, including unaligned_parallel_scan_covers_the_first_piece)
    • cargo +1.98.1-x86_64-pc-windows-gnu build --release -p victory & --release --features diagnostics -p victory + objdump -p (0 non-system MinGW DLLs)
    • erify-world.ps1 (pr37-shadow-scan-boundary, 75s): 11/11 verifier gates PASS
<!-- greyfinch-sync:Androtim/MiniVI:issue:5539405980 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/37). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T10:58:55Z. --- ## Summary Port rustno1-coder/VIctory-NVIDIA 78e99b9 (from kelvaroq 009-shadow-compare.patch / xceless/victory-fork PR #1407 81d54b0): - In crates/victory-gpu/src/shadow.rs, extract scan_boundary(start, from, at) using t.saturating_sub((start + at) % PIECE).max(from) for multi-threaded shadow copyback comparison so unaligned span starts (start % PIECE != 0, rom == 0) do not underflow in release builds and skip the first piece. - Added unit test shadow::difference_tests::unaligned_parallel_scan_covers_the_first_piece. ## Rig Specs Tested On - **CPU:** 13th Gen Intel(R) Core(TM) i7-13700F - **GPU & VRAM:** NVIDIA GeForce RTX 4060 Ti (8 GiB VRAM) - **System RAM:** 32 GiB - **OS & GPU Driver:** Windows 11 Home (Build 26300) / Driver 32.0.16.2124 ## Run Settings & Profile - **Build & Commit SHA:** elease (and elease --features diagnostics) @ $sha - **Console Profile & Internal Resolution / Scale:** series-s (Quality scale .6666667, title output 960x540) - **Ray Tracing:** off - **Upscaling:** DLSS quality (Streamline 2.14.16) - **Frame Generation:** off - **Launcher Command / Preset & Extra VICTORY_* Overrides:** erify-world.ps1 play.rs SETTINGS preset + VICTORY_CARD_ACCOUNTING=1, VICTORY_D3D12_DRED=light, VICTORY_SKIP_BINK=1 (pr37-shadow-scan-boundary) - **Scene / Area & Session Length:** Mission-1 golden save (coastal world / balcony), 75s in-world after world entry (draws >= 500, 16 windows) ## Measurements & Verification - **Base FPS (without Frame Gen):** median 11.3 fps (mean 10.02 fps, steady balcony 10.7–12.3 fps across final 12 windows) vs 8.9 fps baseline (+2.40 fps); rame-8102.png & rame-9134.png visually clean (luma=103.33, edge_energy=7.21, ear_black=0.0%, magenta=0.0%) - **Frame-Gen FPS (if enabled):** off - **VRAM / RAM Usage:** peak 5972 MB / min budget 6939 MB ( MB over budget; 5965 MB VRAM + 5388 MB shared in final copystat line), inal_waiting=1562 (vs 7121 baseline) - **Crashes / DRED Resets:** (crashes=0, o_host_texture_errors=0) - **Automated Checks:** - [x] cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy (sset policy: 294 files ok) - [x] cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask (6 passed; 0 failed) - [x] cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings (0 warnings) - [x] cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features victory-gpu/diagnostics -- -D warnings (0 warnings) - [x] cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- --test-threads=1 (449 passed; 0 failed; 36 ignored, including unaligned_parallel_scan_covers_the_first_piece) - [x] cargo +1.98.1-x86_64-pc-windows-gnu build --release -p victory & --release --features diagnostics -p victory + objdump -p (0 non-system MinGW DLLs) - [x] erify-world.ps1 (pr37-shadow-scan-boundary, 75s): **11/11 verifier gates PASS**
Androtim commented 2026-11-28 11:02:57 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T11:02:57Z.


Automated triage for the maintainers (not an approval).

Verdict: merge-candidate · CI (check): pending

Review Summary

Clean, tightly scoped arithmetic bug fix in crates/victory-gpu/src/shadow.rs.

  • Root cause verified in main: In Shadow::differing (crates/victory-gpu/src/shadow.rs:3785-3791), when threads >= 2 (to - from >= 32 MiB), the first cut (i == 0, at == from) computes (at - (start + at) % PIECE).max(from). Whenever from < (start + from) % PIECE (e.g. from == 0 with an unaligned start), this underflows usize—panicking in debug builds or wrapping in release builds so thread 0 receives a >= b and skips its entire initial slice [from, cut(1)).
  • Fix: Extracting scan_boundary(start, from, at) using at.saturating_sub((start + at) % PIECE).max(from) prevents the underflow, guarantees cut(0) == from, and preserves PIECE-aligned interior cuts for 1 <= i < threads (since (to - from) / threads >= 16 MiB >> PIECE).
  • Tests: shadow::difference_tests::unaligned_parallel_scan_covers_the_first_piece exercises aligned and unaligned start/from combinations and verifies monotonic, piece-aligned cuts.

Verdict

merge-candidate (pending CI completion). Pure CPU-side slice boundary arithmetic; no real-GPU smoke test is needed beyond CI.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7238292597 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/37#issuecomment-7238292597). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T11:02:57Z. --- <!-- minivi-triage v1 head=e1b55cb3162dcfba13e410d5fd8c9535ce29f8f2 verdict=merge-candidate ci=pending at=2026-11-28T11:03:24Z --> Automated triage for the maintainers (not an approval). **Verdict:** `merge-candidate` · **CI (`check`):** `pending` ### Review Summary Clean, tightly scoped arithmetic bug fix in `crates/victory-gpu/src/shadow.rs`. - **Root cause verified in `main`:** In `Shadow::differing` (`crates/victory-gpu/src/shadow.rs:3785-3791`), when `threads >= 2` (`to - from >= 32 MiB`), the first cut (`i == 0`, `at == from`) computes `(at - (start + at) % PIECE).max(from)`. Whenever `from < (start + from) % PIECE` (e.g. `from == 0` with an unaligned `start`), this underflows `usize`—panicking in debug builds or wrapping in release builds so thread 0 receives `a >= b` and skips its entire initial slice `[from, cut(1))`. - **Fix:** Extracting `scan_boundary(start, from, at)` using `at.saturating_sub((start + at) % PIECE).max(from)` prevents the underflow, guarantees `cut(0) == from`, and preserves `PIECE`-aligned interior cuts for `1 <= i < threads` (since `(to - from) / threads >= 16 MiB >> PIECE`). - **Tests:** `shadow::difference_tests::unaligned_parallel_scan_covers_the_first_piece` exercises aligned and unaligned `start`/`from` combinations and verifies monotonic, piece-aligned cuts. ### Verdict `merge-candidate` (pending CI completion). Pure CPU-side slice boundary arithmetic; no real-GPU smoke test is needed beyond CI. --- _Generated with Antigravity CLI (`agy`)._
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!37
No description provided.