victory-shader: prioritize zero operands in v_div_fixup_f32 #18

Merged
Androtim merged 1 commit from upstream-pr/18 into main 2026-11-28 18:44:20 +00:00
Androtim commented 2026-11-28 05:58:09 +00:00 (Migrated from github.com)

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


Summary

Port upstream trustno1-coder/VIctory-NVIDIA feb90ad (originally 6e6f87993f661dd592e21bbbde5e6e4589a2af17) into crates/victory-shader/src/emit/lower.rs and crates/victory-shader/src/emit/mod.rs:

  • Resolve n_zero / d_inf and n_inf / d_zero before applying q_nan -> signed_inf in v_div_fixup_f32 lowering so division fixup corner cases with a NaN intermediate quotient prioritize zero and infinity operands accurately.
  • Add div_fixup_corner_fixture(), div_fixup_corner_program_lowers_without_gpu, and div_fixup_corner_program_executes_on_gpu covering 12 (q, den, num, expected) edge cases including q=NaN with num=+-0 and den=+-Inf.

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) / NVIDIA Driver 32.0.16.2124

Run Settings & Profile

  • Build & Commit SHA: Unit & hardware GPU shader compute dispatch tests @ 2932c16690cb41e56ed1ad8ea77c6a123041daa5 (no separate live game binary test run for this isolated 5-line instruction fix; CI validates full workspace build + victory-shader + victory-gpu)
  • Console Profile & Internal Resolution / Scale: Direct D3D12 compute shader test harness on NVIDIA RTX 4060 Ti
  • Ray Tracing: N/A (unit / GPU shader harness)
  • Upscaling: N/A
  • Frame Generation: N/A
  • Launcher Command / Preset & Extra VICTORY_* Overrides: cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader div_fixup_corner_program_executes_on_gpu -- --ignored --test-threads=1
  • Scene / Area & Session Length: 12 synthetic IEEE-754 v_div_fixup_f32 corner-case inputs dispatched on hardware GPU

Measurements & Verification

  • Base FPS (without Frame Gen): N/A (shader instruction lowering & hardware compute verification; full CI build & suite pending/watched on PR)
  • Frame-Gen FPS (if enabled): off
  • VRAM / RAM Usage: N/A (unit / single-dispatch compute test)
  • Crashes / DRED Resets: 0
  • Automated Checks:
    • cargo +1.98.1-x86_64-pc-windows-gnu xtask 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-shader div_fixup -- --test-threads=1 (1 passed; 0 failed; 1 ignored)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader div_fixup_corner_program_executes_on_gpu -- --ignored --test-threads=1 (1 passed; 0 failed)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader valu_div_f32_sequence_executes_on_gpu -- --test-threads=1 (1 passed; 0 failed)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5537266100 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/18). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T05:58:09Z. --- ## Summary Port upstream `trustno1-coder/VIctory-NVIDIA` `feb90ad` (originally `6e6f87993f661dd592e21bbbde5e6e4589a2af17`) into [`crates/victory-shader/src/emit/lower.rs`](https://github.com/Androtim/MiniVI/blob/2932c16690cb41e56ed1ad8ea77c6a123041daa5/crates/victory-shader/src/emit/lower.rs) and [`crates/victory-shader/src/emit/mod.rs`](https://github.com/Androtim/MiniVI/blob/2932c16690cb41e56ed1ad8ea77c6a123041daa5/crates/victory-shader/src/emit/mod.rs): - Resolve `n_zero` / `d_inf` and `n_inf` / `d_zero` before applying `q_nan -> signed_inf` in `v_div_fixup_f32` lowering so division fixup corner cases with a NaN intermediate quotient prioritize zero and infinity operands accurately. - Add `div_fixup_corner_fixture()`, `div_fixup_corner_program_lowers_without_gpu`, and `div_fixup_corner_program_executes_on_gpu` covering 12 `(q, den, num, expected)` edge cases including `q=NaN` with `num=+-0` and `den=+-Inf`. ## 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)` / NVIDIA Driver `32.0.16.2124` ## Run Settings & Profile - **Build & Commit SHA:** Unit & hardware GPU shader compute dispatch tests @ `2932c16690cb41e56ed1ad8ea77c6a123041daa5` (no separate live game binary test run for this isolated 5-line instruction fix; `CI` validates full workspace build + `victory-shader` + `victory-gpu`) - **Console Profile & Internal Resolution / Scale:** Direct D3D12 compute shader test harness on NVIDIA RTX 4060 Ti - **Ray Tracing:** `N/A` (unit / GPU shader harness) - **Upscaling:** `N/A` - **Frame Generation:** `N/A` - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader div_fixup_corner_program_executes_on_gpu -- --ignored --test-threads=1` - **Scene / Area & Session Length:** 12 synthetic IEEE-754 `v_div_fixup_f32` corner-case inputs dispatched on hardware GPU ## Measurements & Verification - **Base FPS (without Frame Gen):** `N/A` (shader instruction lowering & hardware compute verification; full CI build & suite pending/watched on PR) - **Frame-Gen FPS (if enabled):** `off` - **VRAM / RAM Usage:** `N/A` (unit / single-dispatch compute test) - **Crashes / DRED Resets:** `0` - **Automated Checks:** - [x] `cargo +1.98.1-x86_64-pc-windows-gnu xtask 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-shader div_fixup -- --test-threads=1` (`1 passed; 0 failed; 1 ignored`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader div_fixup_corner_program_executes_on_gpu -- --ignored --test-threads=1` (`1 passed; 0 failed`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader valu_div_f32_sequence_executes_on_gpu -- --test-threads=1` (`1 passed; 0 failed`)
Androtim commented 2026-11-28 06:03:10 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T06:03:10Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

The v_div_fixup_f32 lowering fix in crates/victory-shader/src/emit/lower.rs is clean and matches AMD ISA V_DIV_FIXUP_F32 precedence rules:

  • Bug fixed: Previously, make_inf OR'd q_nan with n_inf | d_zero and was selected after make_zero, causing q = NaN to override num = ±0 or den = ±Inf and return signed_inf instead of signed zero (sign).
  • New precedence (highest to lowest): n_nan -> n_qnan, d_nan -> d_qnan, invalid (both_inf | both_zero) -> kneg_qnan, make_inf (n_inf | d_zero) -> signed_inf, make_zero (d_inf | n_zero) -> sign, q_nan -> signed_inf, else signed_q. Since make_inf and make_zero are mutually exclusive whenever invalid is false, this resolves all zero/infinity operands before falling back to q_nan -> signed_inf.
  • Tests (crates/victory-shader/src/emit/mod.rs): div_fixup_corner_fixture() correctly encodes v_div_fixup_f32 v1, v1, v2, v3 (0xD55F_0001, 0x040E_0501) across 12 lanes covering q=NaN with ±0/±Inf, 0/0, Inf/Inf, and sNaN quieting.
  • Why needs-gpu-test: CI is passing, but div_fixup_corner_program_executes_on_gpu is marked #[ignore] and does not execute in CI; because this changes DXIL shader lowering in victory-shader, it warrants running the hardware D3D12 compute dispatch test locally before merging.

Local GPU Verification

cargo test -p victory-shader div_fixup_corner_program_executes_on_gpu -- --ignored --test-threads=1
cargo test -p victory-shader valu_div_f32_sequence_executes_on_gpu -- --test-threads=1

Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7235048814 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/18#issuecomment-7235048814). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T06:03:10Z. --- <!-- minivi-triage v1 head=2932c16690cb41e56ed1ad8ea77c6a123041daa5 verdict=needs-gpu-test ci=passing at=2026-11-28T07:04:42Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary The `v_div_fixup_f32` lowering fix in `crates/victory-shader/src/emit/lower.rs` is clean and matches AMD ISA `V_DIV_FIXUP_F32` precedence rules: - **Bug fixed:** Previously, `make_inf` OR'd `q_nan` with `n_inf | d_zero` and was selected after `make_zero`, causing `q = NaN` to override `num = ±0` or `den = ±Inf` and return `signed_inf` instead of signed zero (`sign`). - **New precedence (highest to lowest):** `n_nan -> n_qnan`, `d_nan -> d_qnan`, `invalid (both_inf | both_zero) -> kneg_qnan`, `make_inf (n_inf | d_zero) -> signed_inf`, `make_zero (d_inf | n_zero) -> sign`, `q_nan -> signed_inf`, else `signed_q`. Since `make_inf` and `make_zero` are mutually exclusive whenever `invalid` is false, this resolves all zero/infinity operands before falling back to `q_nan -> signed_inf`. - **Tests (`crates/victory-shader/src/emit/mod.rs`):** `div_fixup_corner_fixture()` correctly encodes `v_div_fixup_f32 v1, v1, v2, v3` (`0xD55F_0001, 0x040E_0501`) across 12 lanes covering `q=NaN` with `±0`/`±Inf`, `0/0`, `Inf/Inf`, and sNaN quieting. - **Why `needs-gpu-test`:** CI is passing, but `div_fixup_corner_program_executes_on_gpu` is marked `#[ignore]` and does not execute in CI; because this changes DXIL shader lowering in `victory-shader`, it warrants running the hardware D3D12 compute dispatch test locally before merging. ### Local GPU Verification ```powershell cargo test -p victory-shader div_fixup_corner_program_executes_on_gpu -- --ignored --test-threads=1 cargo test -p victory-shader valu_div_f32_sequence_executes_on_gpu -- --test-threads=1 ``` --- _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!18
No description provided.