shader: NVIDIA float forms as the card's own (VICTORY_HOST_FLOAT, off) #153

Open
github-bot wants to merge 1 commit from github-bot/gh-152 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 17:55 UTC · original
SovietBearz0r:nvidia-host-float → main · +230 −11 · 9 files · 1 commits · open

On an NVIDIA host, write the console float instructions as the card's own form instead of the spelled-out shared form — the same approach VICTORY_RDNA_FLOAT already does for RDNA. Off by default (VICTORY_HOST_FLOAT), NVIDIA-only, from longroad's measured work.

What

  • host_float()/HOST_FLOAT_ALL/parse_host_float in emit/mod.rs beside rdna_float(); new exactness bit rdna::ZERO_SIGN = 16 (ALL stays 15); float_forms()/host_key() in lower/settings.rs.
  • The four f32 sites in lower/operands.rs (max_min, med3, fract, legacy_mul) now ask float_forms(): FMax/FMin without the -0-ordering fix-up, med3 between ordered constants as min(max(...)), legacy product as one multiply + one factor test, plus ZERO_SIGN making the legacy-product zero sign exact for two finite factors (the Exact form asks the factors first instead of the fa&&fb/not_zero early return). host_rdna() still drives the wave code and the f16 half-conversion; native f16 max/min untouched. FRACT can never be enabled (never the host's Frc).
  • Cache key: host_settings()[3] = host_key() — RDNA bits key exactly as before (asserted by test), NVIDIA off keys 0, NVIDIA on keys bits << 8, so existing caches keep serving and turning it on rebuilds once.
  • Defaults: unset/empty/0 = spelled-out forms (byte-identical translations to main), 1 = all forms, any decimal/0x value = those bits masked to HOST_FLOAT_ALL.
  • App plumbing where equivalent: set_host_nvidia detection (already existed in victory-gpu/src/host.rs) now logs the active bits; VICTORY_HOST_NVIDIA=1 added to translate/replay for modelling an NVIDIA host offline. Launcher NVIDIA default deliberately not changed until our own bit-test/in-game pass; README documents the switch.

Verification

  • cargo test -p victory-shader --lib: 326 passed, 0 failed, 2 ignored; new tests: switch parsing/off-unless-set, forms in the cache key (distinct key, RDNA key unchanged), and NVIDIA forms emitted on a modelled NVIDIA host (the four instructions change, fract never, ZERO_SIGN aliasing cases). The existing hardware test rdna_forms_give_what_the_spelled_out_ones_give ran on this machine's real RDNA card and passed → RDNA path unchanged.
  • cargo check -p victory; cargo xtask policy 439 files; clippy: only main's 2 pre-existing warnings in emit/host.rs, none from changed lines; git show --check clean.
  • Needs NVIDIA hardware: (1) our own on-card equivalence test (upstream: 0/2,925 results differ on an RTX 5080; also matched on 3090 Ti/3080 Ti/4080/5070 Ti); (2) in-game A/B with RT (upstream measured RTX 5080 4K DLSS Quality: 23.5→26.2 fps, 1% low 8.7→10.3, GPU 37.1→34.1 ms, same picture). Only then should the launcher NVIDIA profile turn it on.
  • Conflict note vs open #120 (MOVREL/exact rewrites): #121 already needs a rebase on current main in emit/valu_tests.rs (keep #136's DPP/SDWA test block, then mod cost_checks;); after that rebase this branch merges cleanly (git merge-tree reported no conflicts; the auto-merged operands.rs ordering is safe: #121 rewrites sit after the form early-returns, unreachable when the bit is on, untouched when off).
  • Risk: forms are bit-verified upstream on NVIDIA only; gating is on detected vendor (host_nvidia()), so forcing VICTORY_NVIDIA=1 on AMD does not enable them.

Source: longroad 630bdb4 (Lesloo/longroad).

**@⁠SovietBearz0r** on GitHub · 2026-12-05 17:55 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/152) `SovietBearz0r:nvidia-host-float` → `main` · +230 −11 · 9 files · 1 commits · open On an NVIDIA host, write the console float instructions as the card's own form instead of the spelled-out shared form — the same approach `VICTORY_RDNA_FLOAT` already does for RDNA. Off by default (`VICTORY_HOST_FLOAT`), NVIDIA-only, from longroad's measured work. ## What - `host_float()`/`HOST_FLOAT_ALL`/`parse_host_float` in `emit/mod.rs` beside `rdna_float()`; new exactness bit `rdna::ZERO_SIGN = 16` (`ALL` stays 15); `float_forms()`/`host_key()` in `lower/settings.rs`. - The four f32 sites in `lower/operands.rs` (`max_min`, `med3`, `fract`, `legacy_mul`) now ask `float_forms()`: FMax/FMin without the `-0`-ordering fix-up, `med3` between ordered constants as `min(max(...))`, legacy product as one multiply + one factor test, plus `ZERO_SIGN` making the legacy-product zero sign exact for two finite factors (the `Exact` form asks the factors first instead of the `fa&&fb`/`not_zero` early return). `host_rdna()` still drives the wave code and the f16 half-conversion; native f16 max/min untouched. `FRACT` can never be enabled (never the host's `Frc`). - Cache key: `host_settings()[3] = host_key()` — RDNA bits key exactly as before (asserted by test), NVIDIA off keys 0, NVIDIA on keys `bits << 8`, so existing caches keep serving and turning it on rebuilds once. - Defaults: unset/empty/`0` = spelled-out forms (byte-identical translations to main), `1` = all forms, any decimal/`0x` value = those bits masked to `HOST_FLOAT_ALL`. - App plumbing where equivalent: `set_host_nvidia` detection (already existed in `victory-gpu/src/host.rs`) now logs the active bits; `VICTORY_HOST_NVIDIA=1` added to `translate`/`replay` for modelling an NVIDIA host offline. Launcher NVIDIA default deliberately **not** changed until our own bit-test/in-game pass; README documents the switch. ## Verification - `cargo test -p victory-shader --lib`: **326 passed, 0 failed, 2 ignored**; new tests: switch parsing/off-unless-set, forms in the cache key (distinct key, RDNA key unchanged), and NVIDIA forms emitted on a modelled NVIDIA host (the four instructions change, `fract` never, `ZERO_SIGN` aliasing cases). The existing hardware test `rdna_forms_give_what_the_spelled_out_ones_give` ran on this machine's real RDNA card and passed → RDNA path unchanged. - `cargo check -p victory`; `cargo xtask policy` 439 files; clippy: only main's 2 pre-existing warnings in `emit/host.rs`, none from changed lines; `git show --check` clean. - **Needs NVIDIA hardware**: (1) our own on-card equivalence test (upstream: 0/2,925 results differ on an RTX 5080; also matched on 3090 Ti/3080 Ti/4080/5070 Ti); (2) in-game A/B with RT (upstream measured RTX 5080 4K DLSS Quality: 23.5→26.2 fps, 1% low 8.7→10.3, GPU 37.1→34.1 ms, same picture). Only then should the launcher NVIDIA profile turn it on. - Conflict note vs open **#120** (MOVREL/exact rewrites): #121 already needs a rebase on current main in `emit/valu_tests.rs` (keep #136's DPP/SDWA test block, then `mod cost_checks;`); after that rebase this branch merges cleanly (`git merge-tree` reported no conflicts; the auto-merged `operands.rs` ordering is safe: #121 rewrites sit after the form early-returns, unreachable when the bit is on, untouched when off). - Risk: forms are bit-verified upstream on NVIDIA only; gating is on detected vendor (`host_nvidia()`), so forcing `VICTORY_NVIDIA=1` on AMD does not enable them. Source: longroad `630bdb4` (`Lesloo/longroad`).
On an NVIDIA host, and only when VICTORY_HOST_FLOAT asks (1: all; or a set of
bits), the console's float instructions are written as the one host operation
the card makes of them where it gives the console's result to the bit: FMax and
FMin without the code that orders -0 below +0, med3 of a value between two
constants as a min of a max, and the legacy product (0 x anything = +0) as a
plain product with one test of its factors; with ZERO_SIGN (16) that test is
asked of the factors even where both are finite, so a product that rounds to -0
stays -0 as on the console. Never the host's Frc.

The forms are the ones AMD hosts already get (VICTORY_RDNA_FLOAT); only the
four float instructions ask for them (float_forms), the wave code and the
16-bit float shortcut still ask host_rdna whether the host is RDNA. The shader
cache keys NVIDIA's bits apart from an RDNA host's (host_key), and with the
switch off as before. Off by default: unset or 0 writes the spelled-out forms.
The launcher's NVIDIA profile does not set it until our own NVIDIA bit test and
in-game A/B are done; README documents the switch.

From Lesloo/longroad 630bdb4 (LONGROAD_HOST_FLOAT, off; GPL-3.0), itself from
HUAXIANs/VIctory-RTX 7ef45ba4 (DARNER_HOST_FLOAT, on Darner), readmet3xt-lab/
foxhound 9b11fac5 via KyleS98/VIctory-Neo e23accf and Corgansm/victory-corgi
f9cf4cb3. Measured there on an RTX 4070 SUPER: CS_GatherRaymarchedLocalLights
Classified30 5.0 -> 1.2 ms, TL_PS_NoDir 4.1 -> 0.2 ms, the title's pipelines
50.7 -> 40.3 and 44.4 -> 36.5 ms in two of four replays; on an RTX 5080, 4K
DLSS Quality with RT, 23.5 -> 26.2 fps and 1% low 8.7 -> 10.3, the same
picture, and the bit test 0 of 2,925 cases different.

Tests: the switch's parsing and the cache key are checked without a card, and
an NVIDIA host is modelled on the test thread (TEST_FORMS) for the four float
instructions and for ZERO_SIGN asking the legacy product's factors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 17:56:03 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/153/head:github-bot/gh-152'
git switch 'github-bot/gh-152'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-152'
git switch 'github-bot/gh-152'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-152'
git switch 'github-bot/gh-152'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-152'
git switch 'main'
git merge --squash 'github-bot/gh-152'
git switch 'main'
git merge --ff-only 'github-bot/gh-152'
git switch 'main'
git merge 'github-bot/gh-152'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.