Shaders: f16 arithmetic in native half on hosts with 16-bit operations (37x on an RTX 5070 Ti; for #2384) #2825

Open
github-bot wants to merge 5 commits from github-bot/gh-2825 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 21:33 UTC · original
0xkn0wh3r3:shader/native-f16 → main · +918 −48 · 18 files · 5 commits · open

For #2384, following the measurement in #2806.

The translator does every console f16 operation in f32 and rounds each result to f16 in integer code (Lower::narrow16, about 40 operations). #2806 measured that at 34x the host's own half2 math on an RTX 5070 Ti. This PR adds a native path behind a host capability check.

What changes

  • emit::Options::native16 (new). When it is set and the program rounds 16-bit results to nearest even (mode16 is Some(0), or None, which narrow16 also rounds to nearest even), these become DXIL half arithmetic: v_add/sub/subrev/mul_f16, v_fma/fmac_f16, v_min/max/min3/max3/med3_f16 and v_pk_add/mul/fma/fmac/min/max_f16. Sources are read as bits: the abs/neg modifiers flip the sign bit, then trunc and bitcast give a half. Results are bitcast back and written into the destination half as before. The -0/+0 order of min/max and the clamp (+0 for NaN and for -0, as semantics_tests models the console) are decided on the bits, not left to the host.
  • These stay on the f32 path: programs that round toward zero (mode16 == Some(3), which the title sets around its 16-bit interpolation) or toward an infinity; conversions (v_cvt_*, where the host's own conversion rounds as it likes); interpolation; v_mad/mac_f16 (whether the console rounds the product is not settled; #1598); v_fma_mix*; and the transcendental and rounding operations.
  • DXIL: a half type in the bitcode writer, and Uses::native16 for any live half or i16 value. When it is set, the module gets the 16-bit data layout, the shader flags LowPrecisionPresent | UseNativeLowPrecision, and SFI0's native 16-bit ops bit. A module without live 16-bit values is unchanged.
  • victory-gpu: host::native16() asks once. It requires three things: the device reports Native16BitShaderOpsSupported (D3D12 OPTIONS4; SM 6.6 is required anyway); the device rounds a 16-bit FMad once (Host::rounds_f16_fmad_once dispatches #2384's case 3c01·3e00+8001 and expects 3e01, run once at startup like fuses_fmad); and VICTORY_F16_IN_F32=1 is not set. WARP has the ops but rounds the FMad twice, so it keeps the f32 path. Since #1387, that path rounds v_fma_f16 once itself. The answer goes into a new shader_cache::options() and into the cache key, so entries from one path are never served to the other (key test). The check is victory_shader::emit::host::Host::native16, shared with the tests, the same way fuses_fmad is shared.
  • victory translate's tally keeps the f32 path. --cache goes through host_shader and translates as the host does.
  • Module notes: a new "16-bit floats" entry in emit/mod.rs.

How the native results differ from the f32 path's

Operation f32 path native half
add, sub, mul exact in f32 or rounded there first; f32's 2 × 11 + 2 bits make that harmless, so the result is rounded once to nearest even rounded once to nearest even: same result
min, max, min3, max3, med3 exact exact: same result
fma, fmac rounded once (#1387's two-sum) rounded once (the option requires a host that does)
pk_fma, pk_fmac f32 FMad, then narrow16: rounded twice, 1 f16 ULP off where the f32 value lands on an f16 tie that the exact value is not on rounded once, as the console's v_pk_fma_f16 does
NaN payload quieted, as RDNA2 converts the host's (#2384: the Radeon passes 0x7c01 through, WARP gives 0x7fff)

So where the option is on, the native path is never further from the console than the f32 path, and closer for packed FMAs. Hosts whose 16-bit FMad rounds twice (WARP) don't get the option.

Tests (RTX 5070 Ti, driver 621.24, Windows 11)

All in emit/semantics_tests.rs. The native tests run only on adapters that pass Host::native16(): the hardware adapter here. WARP is refused and skips them.

  • hosts_that_round_f16_fmad_twice_keep_the_f32_path: WARP fails the 16-bit FMad check and is refused. The RTX 5070 Ti passes.
  • sixteen_bit_floats_match_the_hardware_natively: every 16-bit probe lowered natively, against the model. The existing f32-path tests still run unchanged on both adapters.
  • fused_f16_results_round_once_natively (hardware adapter only): the probe inputs the f32 path rounds twice (F16_DOUBLE), #2384's three cases (3c01·3e00+8001 → 3e01, 3c03·3e00+0001 → 3e05, 3c01·3e00+be00 → 1600) through v_fma_f16, v_fmac_f16 and v_pk_fma_f16, and 8,192 random finite triples (denormals included). All match single rounding.
  • native_f16_is_never_further_from_the_console: every 16-bit probe plus the 8,192 random FMAs, lowered both ways. Wherever the two results differ, the native one must be the model's. They differ on 1 input (a packed FMA), toward the model.
  • f16_results_round_as_the_mode_says_natively: under the toward-zero mode the sum stays on the f32 path, and after going back to nearest even it is native.
  • native_16bit_operations_are_declared_where_used: the SFI0 bit is set exactly for native arithmetic (not for conversions or toward-zero programs), and the module passes the validator.
  • the_f16_fma_cases_round_once_in_the_model: CPU check of #2384's cases.

The validator was dxil.dll 1.6 via VICTORY_DXIL, because this machine's SDK has no x64 dxil.dll. As a control, the validator rejects the native modules if the 16-bit flags are dropped ("Bitcast on minprecison types is not allowed").

Benchmark

translated_f16_math_costs (ignored; cargo test -p victory-shader --release --lib translated_f16_math -- --ignored --nocapture). It times translated console programs: dependent chains of 4,096 instructions, 262,144 threads, GPU timestamps around 10 back-to-back dispatches, best of five. Before is the f32 path, after is native:

Chain f32 path native Speed-up
v_pk_fma_f16 4.319 ms (0.50 T f16 ops/s) 0.081 ms (26.6 T) 53.5x
v_fma_f16 (f32 path with #1387) 2.489 ms (0.43 T) 0.081 ms (13.3 T) 30.9x
v_mul_f16 + v_add_f16 2.104 ms (0.51 T) 0.081 ms (13.2 T) 25.9x

With operands near 1, the two paths' final results were the same in every thread. Earlier figures here (37x, 23x and 21x, with 512-word chains) understated the work: chain counted encoding words, so the two VOP3/VOP3P chains held 256 instructions, and at that length a dispatch's fixed cost hid the arithmetic. Thanks to xndbogdan's RX 9070 XT ISA check for finding it.

Other checks

  • cargo test -p victory-shader (rebased on f3578e3): 305 passed, 3 failed. The 3 failures and 1 crash (skipped) also happen on origin/main 13f91ca on this machine: heap_direct_texture_reads_mark_their_heap_index crashes with 0xc0000005, and a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware fail.
  • cargo test -p victory-gpu: 226 passed, 2 failed. These are the two that already fail on main on this NVIDIA card: dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.

Not verified

  • No game run. Nothing here was checked on the title, and there is no frame-time number from a real scene. The benchmark is synthetic chains.
  • One hardware adapter (NVIDIA). On AMD hardware the translated half FMA is expected to become v_fma_f16 and pass the check, but that is not measured. The startup check tests one case only. A host that rounds that case once but other cases differently would get the option wrongly.
  • NaN payloads of the console's own v_add_f16 etc. are not known. The native path takes the host's payloads.
  • The native path is on by default where supported. VICTORY_F16_IN_F32=1 turns it off.

AI-assisted.

Since review

  • lower.rs went past the repository's 512 KiB source-file limit, which CI's policy check refused. The native-half helpers moved, unchanged, into lower/half.rs (905732a).
  • The benchmark's chains count instructions, not words, and are 4,096 instructions long (aef37bb). The table above is re-measured.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 21:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825) `0xkn0wh3r3:shader/native-f16` → `main` · +918 −48 · 18 files · 5 commits · open For #2384, following the measurement in #2806. The translator does every console f16 operation in f32 and rounds each result to f16 in integer code (`Lower::narrow16`, about 40 operations). #2806 measured that at 34x the host's own `half2` math on an RTX 5070 Ti. This PR adds a native path behind a host capability check. ## What changes - **`emit::Options::native16`** (new). When it is set and the program rounds 16-bit results to nearest even (`mode16` is `Some(0)`, or `None`, which `narrow16` also rounds to nearest even), these become DXIL `half` arithmetic: `v_add/sub/subrev/mul_f16`, `v_fma/fmac_f16`, `v_min/max/min3/max3/med3_f16` and `v_pk_add/mul/fma/fmac/min/max_f16`. Sources are read as bits: the abs/neg modifiers flip the sign bit, then `trunc` and `bitcast` give a `half`. Results are bitcast back and written into the destination half as before. The -0/+0 order of min/max and the clamp (+0 for NaN and for -0, as `semantics_tests` models the console) are decided on the bits, not left to the host. - **These stay on the f32 path:** programs that round toward zero (`mode16 == Some(3)`, which the title sets around its 16-bit interpolation) or toward an infinity; conversions (`v_cvt_*`, where the host's own conversion rounds as it likes); interpolation; `v_mad/mac_f16` (whether the console rounds the product is not settled; #1598); `v_fma_mix*`; and the transcendental and rounding operations. - **DXIL:** a `half` type in the bitcode writer, and `Uses::native16` for any live `half` or `i16` value. When it is set, the module gets the 16-bit data layout, the shader flags `LowPrecisionPresent | UseNativeLowPrecision`, and SFI0's native 16-bit ops bit. A module without live 16-bit values is unchanged. - **victory-gpu:** `host::native16()` asks once. It requires three things: the device reports `Native16BitShaderOpsSupported` (D3D12 OPTIONS4; SM 6.6 is required anyway); the device rounds a 16-bit `FMad` once (`Host::rounds_f16_fmad_once` dispatches #2384's case `3c01·3e00+8001` and expects `3e01`, run once at startup like `fuses_fmad`); and `VICTORY_F16_IN_F32=1` is not set. WARP has the ops but rounds the `FMad` twice, so it keeps the f32 path. Since #1387, that path rounds `v_fma_f16` once itself. The answer goes into a new `shader_cache::options()` and into the cache key, so entries from one path are never served to the other (`key` test). The check is `victory_shader::emit::host::Host::native16`, shared with the tests, the same way `fuses_fmad` is shared. - `victory translate`'s tally keeps the f32 path. `--cache` goes through `host_shader` and translates as the host does. - Module notes: a new "16-bit floats" entry in `emit/mod.rs`. ## How the native results differ from the f32 path's | Operation | f32 path | native `half` | |---|---|---| | add, sub, mul | exact in f32 or rounded there first; f32's 2 × 11 + 2 bits make that harmless, so the result is rounded once to nearest even | rounded once to nearest even: **same result** | | min, max, min3, max3, med3 | exact | exact: **same result** | | fma, fmac | rounded once (#1387's two-sum) | rounded once (the option requires a host that does) | | pk_fma, pk_fmac | f32 `FMad`, then `narrow16`: **rounded twice**, 1 f16 ULP off where the f32 value lands on an f16 tie that the exact value is not on | rounded **once**, as the console's `v_pk_fma_f16` does | | NaN payload | quieted, as RDNA2 converts | the host's (#2384: the Radeon passes `0x7c01` through, WARP gives `0x7fff`) | So where the option is on, the native path is never further from the console than the f32 path, and closer for packed FMAs. Hosts whose 16-bit `FMad` rounds twice (WARP) don't get the option. ## Tests (RTX 5070 Ti, driver 621.24, Windows 11) All in `emit/semantics_tests.rs`. The native tests run only on adapters that pass `Host::native16()`: the hardware adapter here. WARP is refused and skips them. - `hosts_that_round_f16_fmad_twice_keep_the_f32_path`: WARP fails the 16-bit `FMad` check and is refused. The RTX 5070 Ti passes. - `sixteen_bit_floats_match_the_hardware_natively`: every 16-bit probe lowered natively, against the model. The existing f32-path tests still run unchanged on both adapters. - `fused_f16_results_round_once_natively` (hardware adapter only): the probe inputs the f32 path rounds twice (`F16_DOUBLE`), #2384's three cases (`3c01·3e00+8001 → 3e01`, `3c03·3e00+0001 → 3e05`, `3c01·3e00+be00 → 1600`) through `v_fma_f16`, `v_fmac_f16` and `v_pk_fma_f16`, and 8,192 random finite triples (denormals included). All match single rounding. - `native_f16_is_never_further_from_the_console`: every 16-bit probe plus the 8,192 random FMAs, lowered both ways. Wherever the two results differ, the native one must be the model's. They differ on 1 input (a packed FMA), toward the model. - `f16_results_round_as_the_mode_says_natively`: under the toward-zero mode the sum stays on the f32 path, and after going back to nearest even it is native. - `native_16bit_operations_are_declared_where_used`: the SFI0 bit is set exactly for native arithmetic (not for conversions or toward-zero programs), and the module passes the validator. - `the_f16_fma_cases_round_once_in_the_model`: CPU check of #2384's cases. The validator was dxil.dll 1.6 via `VICTORY_DXIL`, because this machine's SDK has no x64 dxil.dll. As a control, the validator rejects the native modules if the 16-bit flags are dropped ("Bitcast on minprecison types is not allowed"). ## Benchmark `translated_f16_math_costs` (ignored; `cargo test -p victory-shader --release --lib translated_f16_math -- --ignored --nocapture`). It times translated console programs: dependent chains of 4,096 instructions, 262,144 threads, GPU timestamps around 10 back-to-back dispatches, best of five. Before is the f32 path, after is native: | Chain | f32 path | native | Speed-up | |---|---|---|---| | `v_pk_fma_f16` | 4.319 ms (0.50 T f16 ops/s) | 0.081 ms (26.6 T) | 53.5x | | `v_fma_f16` (f32 path with #1387) | 2.489 ms (0.43 T) | 0.081 ms (13.3 T) | 30.9x | | `v_mul_f16` + `v_add_f16` | 2.104 ms (0.51 T) | 0.081 ms (13.2 T) | 25.9x | With operands near 1, the two paths' final results were the same in every thread. Earlier figures here (37x, 23x and 21x, with 512-word chains) understated the work: `chain` counted encoding words, so the two VOP3/VOP3P chains held 256 instructions, and at that length a dispatch's fixed cost hid the arithmetic. Thanks to xndbogdan's RX 9070 XT ISA check for finding it. ## Other checks - `cargo test -p victory-shader` (rebased on f3578e3): 305 passed, 3 failed. The 3 failures and 1 crash (skipped) also happen on origin/main 13f91ca on this machine: `heap_direct_texture_reads_mark_their_heap_index` crashes with 0xc0000005, and `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware` fail. - `cargo test -p victory-gpu`: 226 passed, 2 failed. These are the two that already fail on main on this NVIDIA card: `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. ## Not verified - **No game run.** Nothing here was checked on the title, and there is no frame-time number from a real scene. The benchmark is synthetic chains. - **One hardware adapter (NVIDIA).** On AMD hardware the translated `half` FMA is expected to become `v_fma_f16` and pass the check, but that is not measured. The startup check tests one case only. A host that rounds that case once but other cases differently would get the option wrongly. - **NaN payloads of the console's own `v_add_f16` etc. are not known.** The native path takes the host's payloads. - The native path is **on by default where supported**. `VICTORY_F16_IN_F32=1` turns it off. AI-assisted. ### Since review - `lower.rs` went past the repository's 512 KiB source-file limit, which CI's policy check refused. The native-`half` helpers moved, unchanged, into `lower/half.rs` (905732a). - The benchmark's chains count instructions, not words, and are 4,096 instructions long (aef37bb). The table above is re-measured.
The translator did every console f16 operation in f32 and rounded each
result to f16 in integer code (`narrow16`, about 40 operations), which
costs about 34x the host's own half math (#2806). With the new
`emit::Options::native16`, `v_add/sub/subrev/mul_f16`, `v_fma/fmac_f16`,
`v_min/max/min3/max3/med3_f16` and `v_pk_add/mul/fma/fmac/min/max_f16`
become DXIL `half` arithmetic: 16-bit types, the native low precision
shader flags, the 16-bit data layout and SFI0's native 16-bit bit, set only
when a live instruction uses them.

The option is for hosts that report `Native16BitShaderOpsSupported` (D3D12
OPTIONS4; SM 6.6 is required anyway) and round a 16-bit FMad once, as the
console's v_fma_f16 does (`Host::rounds_f16_fmad_once`, a dispatch of
#2384's case, run once as `fuses_fmad` is). The RTX 5070 Ti does. WARP
rounds in f32 first and keeps the f32 path, which since #1387 rounds
v_fma_f16 once itself.

Results: sums, differences and products are the same as the f32 path's
(rounding in f32 first never changes the f16 result), as are minima,
maxima and medians (exact; the -0/+0 order and the clamp, which gives +0
for NaN and -0, are done on the bits). NaN payloads are the host's where
the f32 path quiets them. Fused multiply-adds round once; the f32 path
still rounds the packed ones twice. Programs that round toward zero (the
title's around its 16-bit interpolation) or toward an infinity keep the
f32 path, as do conversions, interpolation, v_mad/mac_f16, v_fma_mix* and
the transcendental and rounding operations.

victory-gpu asks the host once (`host::native16`, off with
`VICTORY_F16_IN_F32=1`) and puts the answer in `shader_cache::options()`
and the cache key, so one path's entries never serve the other.

Tests (RTX 5070 Ti, driver 621.24; WARP is refused and skips them): the
16-bit probes natively; the fused inputs the f32 path rounds twice,
#2384's three cases and 8,192 random finite triples (denormals included)
rounded once natively; every 16-bit probe and the random triples lowered
both ways, native never further from the model (they differ on 1 input,
a packed one); the toward-zero mode natively; the host check (WARP
refused); flags and validation of the lowered modules (dxil.dll 1.6).

A translated benchmark (ignored; 262,144 threads, dependent chains of
512 instructions, best of five, GPU timestamps):

  v_pk_fma_f16          f32 path 0.221 ms   native 0.006 ms   37x
  v_fma_f16             f32 path 0.129 ms   native 0.006 ms   23x
  v_mul_f16 + v_add_f16 f32 path 0.221 ms   native 0.011 ms   21x
lower.rs went past the repository's 512 KiB limit for a source file with
the native f16 lowering (CI's policy check failed). Its helpers move,
unchanged, into lower/half.rs, next to lower/bvh.rs.
`chain` repeated a step CHAIN / its word count times, and VOP3 and VOP3P
instructions take two words: the v_pk_fma_f16 and v_fma_f16 chains held
256 instructions where 512 were counted, so their f16 operations per
second read twice too high. Steps now give their instruction count. The
chains are 4,096 instructions long: at 512 a dispatch's fixed cost hid
the arithmetic on an RX 9070 XT. On an RTX 5070 Ti the native path is
53.5x (v_pk_fma_f16), 30.9x (v_fma_f16) and 25.9x (v_mul_f16 + v_add_f16)
faster, results alike in all 262,144 threads.
`valu16_native` claimed v_add/v_mul_f16 and the rest whatever their
output modifier and refused one, so with native 16-bit operations a
program the f32 path translates (once it handles output modifiers on f16
results, #2915) would be refused. An instruction with `omod` now falls
through to the f32 path, per instruction; a test checks both lowerings
translate or refuse v_add/v_mul_f16 with mul:2, mul:4 and div:2 alike,
and that a translated one declares no native 16-bit operations.

Found by steven-seagull27 combining #2825 with #2915.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:13 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:48 UTC · original

Verified and benchmarked bdc08a95 on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll):

  • cargo xtask policy: 184 files ok; cargo clippy (victory-shader default & --features host, victory-gpu default & --features diagnostics, victory): 0 warnings.
  • Functional suites:
    • victory-shader (RTX 5090 + WARP + dxil.dll): sixteen_bit_floats 2/2, f16_ 16/16 (1 ignored), native_ 3/3 (including native_16bit_operations_are_declared_where_used via dxil.dll and fused_f16_results_round_once_natively), emit::lower::tests 27/27.
    • victory-gpu shader_cache::tests: 3/3 on RTX 5090, 3/3 with VICTORY_F16_IN_F32=1, and 3/3 on WARP (VICTORY_D3D12_WARP=1).
  • Same-machine RTX 5090 --release benchmark (translated_f16_math_costs, 262,144 threads × 512 ops, 2 runs; 262,144/262,144 threads match the f32 path):
    • v_pk_fma_f16: 0.108 ms (2481 G ops/s) -> 0.003 ms (85773 G ops/s) (34.6×); run 2: 0.112 ms (2388 G) -> 0.003 ms (91479 G) (38.3×)
    • v_fma_f16: 0.052 ms (2603 G) -> 0.003 ms (44290 G) (17.0×); run 2: 0.050 ms (2696 G) -> 0.003 ms (43645 G) (16.2×)
    • v_mul_f16 + v_add_f16: 0.136 ms (988 G) -> 0.010 ms (13026 G) (13.2×); run 2: 0.105 ms (1283 G) -> 0.005 ms (26133 G) (20.4×)
  • Code review: RNE-only native16() gating, exact LOW_PRECISION | NATIVE_LOW_PRECISION + SFI0 0x4_0000 + 16-bit datalayout gating, bitwise abs/neg preserving denormals/NaNs, -0 < +0 & nan16 handling in max_min16/med3_16/clamp16, SM 6.2 single-rounding fma16, and shader_cache key update all check out.
  • Merge note: origin/main just advanced with WARP_LOCK/SharedDevice in crates/victory-shader/src/emit/host.rs, causing a small rebase conflict in emit/host.rs (dispatch_timed just needs to keep let _guard = self.lock_warp();). Clean against #2806.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7175564065) Verified and benchmarked `bdc08a95` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`): - `cargo xtask policy`: 184 files ok; `cargo clippy` (`victory-shader` default & `--features host`, `victory-gpu` default & `--features diagnostics`, `victory`): 0 warnings. - Functional suites: - `victory-shader` (RTX 5090 + WARP + `dxil.dll`): `sixteen_bit_floats` 2/2, `f16_` 16/16 (1 ignored), `native_` 3/3 (including `native_16bit_operations_are_declared_where_used` via `dxil.dll` and `fused_f16_results_round_once_natively`), `emit::lower::tests` 27/27. - `victory-gpu` `shader_cache::tests`: 3/3 on RTX 5090, 3/3 with `VICTORY_F16_IN_F32=1`, and 3/3 on WARP (`VICTORY_D3D12_WARP=1`). - Same-machine RTX 5090 `--release` benchmark (`translated_f16_math_costs`, 262,144 threads × 512 ops, 2 runs; 262,144/262,144 threads match the f32 path): - `v_pk_fma_f16`: `0.108 ms (2481 G ops/s)` -> **`0.003 ms (85773 G ops/s)` (34.6×)**; run 2: `0.112 ms (2388 G)` -> **`0.003 ms (91479 G)` (38.3×)** - `v_fma_f16`: `0.052 ms (2603 G)` -> **`0.003 ms (44290 G)` (17.0×)**; run 2: `0.050 ms (2696 G)` -> **`0.003 ms (43645 G)` (16.2×)** - `v_mul_f16 + v_add_f16`: `0.136 ms (988 G)` -> **`0.010 ms (13026 G)` (13.2×)**; run 2: `0.105 ms (1283 G)` -> **`0.005 ms (26133 G)` (20.4×)** - Code review: RNE-only `native16()` gating, exact `LOW_PRECISION | NATIVE_LOW_PRECISION` + `SFI0` `0x4_0000` + 16-bit datalayout gating, bitwise `abs`/`neg` preserving denormals/NaNs, `-0 < +0` & `nan16` handling in `max_min16`/`med3_16`/`clamp16`, SM 6.2 single-rounding `fma16`, and `shader_cache` key update all check out. - Merge note: `origin/main` just advanced with `WARP_LOCK`/`SharedDevice` in `crates/victory-shader/src/emit/host.rs`, causing a small rebase conflict in `emit/host.rs` (`dispatch_timed` just needs to keep `let _guard = self.lock_warp();`). Clean against #2806.
Author
Owner

@⁠xndbogdan on GitHub · 2026-11-25 21:53 UTC · original · edited 2026-11-25 21:55 UTC

Results on AMD hardware, the adapter the PR lists as unverified.

Setup: AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029, Intel Xeon E5-2670 v3 (times are GPU timestamps, so the CPU is not in them), Windows 11 IoT Enterprise LTSC 26100, bdc08a9, --release, validator dxil.dll from Windows SDK 10.0.26100. No game data.

Tests: all pass on the hardware adapter and on WARP.

  • sixteen_bit_floats_match_the_hardware_natively: 29 probes, 0 model mismatches on hardware or WARP.
  • fused_f16_results_round_once_natively: passed, so this card's native 16-bit FMA rounds once, as on the RTX 5070 Ti and RTX 4070 Ti.
  • native_f16_is_never_further_from_the_console: passed; the native and f32 paths differ on 2 inputs on hardware, as on the RTX 5070 Ti.
  • f16_results_round_as_the_mode_says_natively and native_16bit_operations_are_declared_where_used: passed.

Benchmark (translated_f16_math_costs), four runs (the first straight after the build, then three back to back). Results were alike in all 262,144 threads in every run.

Chain Speed-up over 4 runs First run, f32 → native
v_pk_fma_f16 5.2–9.2× 0.820 → 0.089 ms
v_fma_f16 2.1–3.4× 0.450 → 0.163 ms
v_mul_f16 + v_add_f16 3.9–5.9× 0.844 → 0.217 ms

The native path is faster in every run, but far less so than the 39×, 18× and 21× on the RTX 5070 Ti, and it varies from run to run. On this same card, #2806's hand-written half2 chain is 26× faster than narrow16, so the translated native code seems to leave speed behind on AMD. Two possible reasons, neither checked:

  • Each half is converted on its own (trunc, bitcast, zext), and AMD's compiler may not pack the two back into one v_pk_fma_f16. Radeon GPU Analyzer's ISA output for the native module would show whether it does.
  • The dispatches are short (~0.1 ms), which may be too short to time this card reliably.

AI-assisted (Claude Code). The tests and benchmark ran on the machine above.

**@⁠xndbogdan** on GitHub · 2026-11-25 21:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7175679206) · edited 2026-11-25 21:55 UTC Results on AMD hardware, the adapter the PR lists as unverified. **Setup:** AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029, Intel Xeon E5-2670 v3 (times are GPU timestamps, so the CPU is not in them), Windows 11 IoT Enterprise LTSC 26100, `bdc08a9`, `--release`, validator `dxil.dll` from Windows SDK 10.0.26100. No game data. **Tests: all pass on the hardware adapter and on WARP.** - `sixteen_bit_floats_match_the_hardware_natively`: 29 probes, 0 model mismatches on hardware or WARP. - `fused_f16_results_round_once_natively`: **passed**, so this card's native 16-bit FMA rounds once, as on the RTX 5070 Ti and RTX 4070 Ti. - `native_f16_is_never_further_from_the_console`: passed; the native and f32 paths differ on 2 inputs on hardware, as on the RTX 5070 Ti. - `f16_results_round_as_the_mode_says_natively` and `native_16bit_operations_are_declared_where_used`: passed. **Benchmark** (`translated_f16_math_costs`), four runs (the first straight after the build, then three back to back). Results were alike in all 262,144 threads in every run. | Chain | Speed-up over 4 runs | First run, f32 → native | |---|---:|---:| | `v_pk_fma_f16` | 5.2–9.2× | 0.820 → 0.089 ms | | `v_fma_f16` | 2.1–3.4× | 0.450 → 0.163 ms | | `v_mul_f16` + `v_add_f16` | 3.9–5.9× | 0.844 → 0.217 ms | The native path is faster in every run, but far less so than the 39×, 18× and 21× on the RTX 5070 Ti, and it varies from run to run. On this same card, #2806's hand-written `half2` chain is 26× faster than `narrow16`, so the translated native code seems to leave speed behind on AMD. Two possible reasons, neither checked: - Each half is converted on its own (`trunc`, `bitcast`, `zext`), and AMD's compiler may not pack the two back into one `v_pk_fma_f16`. Radeon GPU Analyzer's ISA output for the native module would show whether it does. - The dispatches are short (~0.1 ms), which may be too short to time this card reliably. *AI-assisted (Claude Code). The tests and benchmark ran on the machine above.*
Author
Owner

@⁠xndbogdan on GitHub · 2026-11-25 22:36 UTC · original

Follow-up to my AMD results above, with the ISA. The two possible reasons I gave there were both wrong. Same RX 9070 XT (gfx1201, driver 32.0.32015.7029), bdc08a9. I compiled the benchmark's six translated modules, and #2806's half2 shader, with Radeon GPU Analyzer 2.15 (DX12 mode, live driver).

1. The native path picks the same instructions as hand-written HLSL. Each native v_pk_fma_f16 compiles to two v_fma_f16, one on each half (v0.l, then v0.h). #2806's half2 mad, compiled by dxc, also becomes two v_fma_f16 on this driver, so neither gets a packed instruction. Program sizes, f32 path → native:

Chain Instructions VGPRs
v_pk_fma_f16 25,953 → 863 22 → 6
v_fma_f16 14,304 → 1,119 13 → 6
v_mul_f16 + v_add_f16 28,898 → 1,887 13 → 6

2. The chains are half as long as the test assumes, which made the AMD timings mostly fixed cost. chain() repeats step CHAIN / step.len() times, and step.len() counts encoding dwords. v_pk_fma_f16 and v_fma_f16 are 2-dword encodings, so those chains hold 256 instructions, not 512. The ISA agrees: 512 v_fma_f16 (2 × 256) in the packed chain, 256 in the scalar one. So:

  • the "G f16 ops/s" column is 2× too high for those two rows on every GPU. The speed-ups are unaffected.
  • the native shaders were short enough that per-dispatch costs dominated on this card. 8× the work took only 2–3× longer.

The same benchmark with CHAIN = 4096, two runs each:

Chain CHAIN = 512 CHAIN = 4096
v_pk_fma_f16 5.2–5.8× 15.3–20.0×
v_fma_f16 3.0–4.5× 6.6–9.4×
v_mul_f16 + v_add_f16 3.6–5.9× 5.5×

Results were alike in all 262,144 threads in every run. Counting instructions rather than words in chain() and using a longer chain would make the table comparable across GPUs.

3. A possible follow-up, not for this PR: the merge after scalar f16 results. Each native scalar result is merged into its 32-bit register to keep the other half, as the console does:

  • v_fma_f16 chain: per op, v_fma_f16 + v_bfi_b32 + v_mov_b32 (256 / 256 / 258 in the module);
  • mul + add chain: per op, the f16 op + v_mov_b16 + v_bfi_b32 (512 / 512 for 512 ops).

The packed chains need no merge. Where the other half of the destination is never read before it is overwritten, skipping the merge would take these chains from ~3 instructions per op to 1, which probably explains the lower scalar speed-ups. low16 already tracks reads of the low half alone, which may be a starting point. How often the title's shaders write single halves is not known.

AI-assisted (Claude Code). The benchmark runs and ISA dumps were made on the machine above, with a local, unpushed hook that wrote the modules and root signatures to disk.

**@⁠xndbogdan** on GitHub · 2026-11-25 22:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7176575971) Follow-up to my AMD results above, with the ISA. The two possible reasons I gave there were both wrong. Same RX 9070 XT (`gfx1201`, driver 32.0.32015.7029), `bdc08a9`. I compiled the benchmark's six translated modules, and #2806's `half2` shader, with Radeon GPU Analyzer 2.15 (DX12 mode, live driver). **1. The native path picks the same instructions as hand-written HLSL.** Each native `v_pk_fma_f16` compiles to two `v_fma_f16`, one on each half (`v0.l`, then `v0.h`). #2806's `half2` `mad`, compiled by dxc, also becomes two `v_fma_f16` on this driver, so neither gets a packed instruction. Program sizes, f32 path → native: | Chain | Instructions | VGPRs | |---|---:|---:| | `v_pk_fma_f16` | 25,953 → 863 | 22 → 6 | | `v_fma_f16` | 14,304 → 1,119 | 13 → 6 | | `v_mul_f16` + `v_add_f16` | 28,898 → 1,887 | 13 → 6 | **2. The chains are half as long as the test assumes, which made the AMD timings mostly fixed cost.** `chain()` repeats `step` `CHAIN / step.len()` times, and `step.len()` counts encoding dwords. `v_pk_fma_f16` and `v_fma_f16` are 2-dword encodings, so those chains hold 256 instructions, not 512. The ISA agrees: 512 `v_fma_f16` (2 × 256) in the packed chain, 256 in the scalar one. So: - the "G f16 ops/s" column is 2× too high for those two rows on every GPU. The speed-ups are unaffected. - the native shaders were short enough that per-dispatch costs dominated on this card. 8× the work took only 2–3× longer. The same benchmark with `CHAIN = 4096`, two runs each: | Chain | `CHAIN = 512` | `CHAIN = 4096` | |---|---:|---:| | `v_pk_fma_f16` | 5.2–5.8× | **15.3–20.0×** | | `v_fma_f16` | 3.0–4.5× | **6.6–9.4×** | | `v_mul_f16` + `v_add_f16` | 3.6–5.9× | **5.5×** | Results were alike in all 262,144 threads in every run. Counting instructions rather than words in `chain()` and using a longer chain would make the table comparable across GPUs. **3. A possible follow-up, not for this PR: the merge after scalar f16 results.** Each native scalar result is merged into its 32-bit register to keep the other half, as the console does: - `v_fma_f16` chain: per op, `v_fma_f16` + `v_bfi_b32` + `v_mov_b32` (256 / 256 / 258 in the module); - mul + add chain: per op, the f16 op + `v_mov_b16` + `v_bfi_b32` (512 / 512 for 512 ops). The packed chains need no merge. Where the other half of the destination is never read before it is overwritten, skipping the merge would take these chains from ~3 instructions per op to 1, which probably explains the lower scalar speed-ups. `low16` already tracks reads of the low half alone, which may be a starting point. How often the title's shaders write single halves is not known. *AI-assisted (Claude Code). The benchmark runs and ISA dumps were made on the machine above, with a local, unpushed hook that wrote the modules and root signatures to disk.*
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-25 22:42 UTC · original · edited 2026-11-25 23:26 UTC

Correction (see my later comment below): the timing table here uses the last single sample of each run. The medians show a much smaller effect: GPU lists 40.0 → 38.1 ms, cardmeter 40.8 → 40.9 ms, frame 112 → 111 ms.

AI-assisted testing (Gemini in OpenCode); measured locally on my own machine.

First real-game RTX 4080 verification (ported onto fxceless/victory-fork 9c184b3 stack)

I ported the core native-half emission from bdc08a9 (TypeDef::Half, 16-bit data layout, LOW_PRECISION | NATIVE_LOW_PRECISION + SFI0 0x4_0000, D3D12_OPTIONS4::Native16BitShaderOpsSupported, and the scalar + packed half lowerings in lower.rs) onto our local RTX 4080 test stack (fxceless/victory-fork 9c184b3 + bundled perf PRs) to test it in-game.

Setup: Windows 10 Pro 22H2 (Agility SDK 1.620.2), i5-13600K, 32 GB RAM, RTX 4080 16 GB (driver 621.01), Series X profile, diagnostics release build, separate warmed shader cache (victory-fxf16-cache).

Translation & pipeline creation:

  • victory translate --warm (2,576 world shader hashes): 2,512 / 2,513 found shaders translated cleanly (0 additional refusals vs the f32 path).
  • Runtime D3D12 pipeline creation: 2,113 pipelines created/loaded (1,821 made on cold run, 1,997 loaded + 125 made on warm run), 0 pipeline refusals, 0 crashes, 0 device removals across 12+ minutes total in-world.
  • Visual check (frame-2048.png warm run): clean cell, sunlit yard, Lucia head/hair/ponytail, posters, UI — no visible f16 artifacts. (Note: fxceless's lower.rs does not track mode16 yet, so even without the mode16 == Some(3) guard, the prologue/cell scene rendered cleanly.)

Warm RTX 4080 timing (same stack & switches, f32 legacyF32ToF16 baseline vs native half):
(Note: fxceless's f32 baseline defaults to 1-op legacyF32ToF16 rather than upstream's 40-op narrow16, so the delta vs upstream's narrow16 will be larger than this floor.)

Metric (framelog usual frame / cardmeter) fxceless f32 (legacyF32ToF16) Native DXIL half (#2825 port, warm)
framelog usual frame 113 ms (41 frames) 107 ms (36 frames, -6 ms)
Peak world FPS 9.30 fps 9.70 fps
framelog all other lists (GPU) 38.8 ms (201 lists) 34.1 ms (176 lists)
Total GPU time (send-and-hash + compare + lists) 47.9 ms 41.9 ms (23.9 fps GPU ceiling; card 43% busy)
cardmeter 256-frame mean 40.8 ms (210 lists) 40.9 ms (211 lists)

Native half f16 works cleanly end-to-end on real game shaders on Ada Lovelace / Windows 10 + Agility 1.620.2, with zero pipeline refusals and lower settled frame time even against a legacyF32ToF16 baseline.

**@⁠Proudnoob4** on GitHub · 2026-11-25 22:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7176699133) · edited 2026-11-25 23:26 UTC > **Correction (see my later comment below):** the timing table here uses the last single sample of each run. The medians show a much smaller effect: GPU lists 40.0 → 38.1 ms, `cardmeter` 40.8 → 40.9 ms, frame 112 → 111 ms. *AI-assisted testing (Gemini in OpenCode); measured locally on my own machine.* ### First real-game RTX 4080 verification (ported onto `fxceless/victory-fork` `9c184b3` stack) I ported the core native-`half` emission from `bdc08a9` (`TypeDef::Half`, 16-bit data layout, `LOW_PRECISION | NATIVE_LOW_PRECISION` + `SFI0 0x4_0000`, `D3D12_OPTIONS4::Native16BitShaderOpsSupported`, and the scalar + packed `half` lowerings in `lower.rs`) onto our local RTX 4080 test stack (`fxceless/victory-fork` `9c184b3` + bundled perf PRs) to test it in-game. **Setup:** Windows 10 Pro 22H2 (Agility SDK 1.620.2), i5-13600K, 32 GB RAM, RTX 4080 16 GB (driver 621.01), Series X profile, diagnostics release build, separate warmed shader cache (`victory-fxf16-cache`). **Translation & pipeline creation:** - `victory translate --warm` (2,576 world shader hashes): **2,512 / 2,513** found shaders translated cleanly (**0** additional refusals vs the f32 path). - Runtime D3D12 pipeline creation: **2,113** pipelines created/loaded (`1,821` made on cold run, `1,997` loaded + `125` made on warm run), **0** pipeline refusals, **0** crashes, **0** device removals across 12+ minutes total in-world. - Visual check (`frame-2048.png` warm run): clean cell, sunlit yard, Lucia head/hair/ponytail, posters, UI — no visible f16 artifacts. *(Note: `fxceless`'s `lower.rs` does not track `mode16` yet, so even without the `mode16 == Some(3)` guard, the prologue/cell scene rendered cleanly.)* **Warm RTX 4080 timing (same stack & switches, f32 `legacyF32ToF16` baseline vs native `half`):** *(Note: `fxceless`'s f32 baseline defaults to 1-op `legacyF32ToF16` rather than upstream's 40-op `narrow16`, so the delta vs upstream's `narrow16` will be larger than this floor.)* | Metric (`framelog` usual frame / `cardmeter`) | `fxceless` f32 (`legacyF32ToF16`) | Native DXIL `half` (`#2825` port, warm) | |---|---|---| | `framelog` usual frame | `113 ms` (41 frames) | **`107 ms`** (36 frames, **-6 ms**) | | Peak world FPS | `9.30 fps` | **`9.70 fps`** | | `framelog` `all other lists` (GPU) | `38.8 ms` (201 lists) | **`34.1 ms`** (176 lists) | | Total GPU time (`send-and-hash + compare + lists`) | `47.9 ms` | **`41.9 ms`** (`23.9 fps` GPU ceiling; card 43% busy) | | `cardmeter` 256-frame mean | `40.8 ms` (210 lists) | `40.9 ms` (211 lists) | Native `half` f16 works cleanly end-to-end on real game shaders on Ada Lovelace / Windows 10 + Agility 1.620.2, with zero pipeline refusals and lower settled frame time even against a `legacyF32ToF16` baseline.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 22:51 UTC · original

@⁠xndbogdan thank you, both findings were right. aef37bb makes chain count instructions rather than encoding words, so the VOP3/VOP3P chains now hold as many instructions as the table says, and it uses 4,096-instruction chains as you measured. On the RTX 5070 Ti that gives 53.5x for v_pk_fma_f16, 30.9x for v_fma_f16 and 25.9x for v_mul_f16 + v_add_f16, results alike in all 262,144 threads. The description's table is re-measured, and it credits your check.

Interesting that both the native path and dxc's half2 mad become two v_fma_f16 on gfx1201. So the gain there is from dropping the integer rounding sequence, not from packing. The merge after scalar results is noted for a follow-up.

CI was also failing on the policy check: lower.rs had passed the 512 KiB limit. 905732a moves the native-half helpers, unchanged, into lower/half.rs.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 22:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7176866193) @⁠xndbogdan thank you, both findings were right. aef37bb makes `chain` count instructions rather than encoding words, so the VOP3/VOP3P chains now hold as many instructions as the table says, and it uses 4,096-instruction chains as you measured. On the RTX 5070 Ti that gives 53.5x for `v_pk_fma_f16`, 30.9x for `v_fma_f16` and 25.9x for `v_mul_f16` + `v_add_f16`, results alike in all 262,144 threads. The description's table is re-measured, and it credits your check. Interesting that both the native path and dxc's `half2` `mad` become two `v_fma_f16` on gfx1201. So the gain there is from dropping the integer rounding sequence, not from packing. The merge after scalar results is noted for a follow-up. CI was also failing on the policy check: `lower.rs` had passed the 512 KiB limit. 905732a moves the native-`half` helpers, unchanged, into `lower/half.rs`.
Author
Owner

@⁠xndbogdan on GitHub · 2026-11-25 22:53 UTC · original

@⁠0xkn0wh3r3 thanks for the quick turnaround, and for the credit. 53.5× on the corrected chains is a great result. Good luck getting this merged.

**@⁠xndbogdan** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7176911164) @⁠0xkn0wh3r3 thanks for the quick turnaround, and for the credit. 53.5× on the corrected chains is a great result. Good luck getting this merged.
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-25 23:17 UTC · original · edited 2026-11-25 23:26 UTC

AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.

Setup: RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B:

  • A fxceless stack, f32 path
  • B = A + a local port of Marvisak/VIctory#2825 native f16
  • C = B + #1168 + #1147 + #1164 (VICTORY_CARD_PIECE_KB=16) + #1171 + #1172 + a local commit (skip clean card_dirty copies; chunk wide compare dispatches to ≤ 65,535 groups)
In-world, from the logs A B C
FPS, 2nd-half median (max) 8.8 (9.3) 8.8 (9.7) 8.9 (9.4)
Usual frame, median 112 ms 111 ms 113 ms
GPU title lists (all other lists), 2nd-half median 40.0 ms 38.1 ms 31.8 ms
cardmeter, 256-frame mean, steady 40.8 ms 40.9 ms 31.6–33.7 ms
Copy-back (last usual-frame summary) 23.2 ms / 62.5 MB 22.4 ms / 60.9 MB 28.4 ms / 49.4 MB
Pieces fetched on the copy queue / frame ~1,370 ~1,388 ~4,138
Writes back in place / frame 1,386 1,390 4,150
Card idle per frame 62.5 ms 68.7 ms 68.8 ms
  • GPU: title-list time fell by ~8 ms between B and C. Native f16 alone (A→B) changed it by ~2 ms at most (cardmeter unchanged). Which of C's additions gave the 8 ms is not isolated.
  • No FPS change: the frame is CPU-bound on the submit thread (copies ~63 ms + copy-back 22–28 ms of a ~110 ms frame), so the GPU saving does not reach the screen.
  • Artifacts in C: a frame grabbed at 330 s shows blocky corrupted tiles along the bottom of the screen and a stair-stepped edge on the character's shoulder. Which change causes it is not isolated. B's earlier frame looked clean.
  • Stability: no panic, device-removed or ERROR lines in C's log, no crash in 360 s.

For this PR: the earlier report here (22:42) gave 38.8 → 34.1 ms GPU lists and 113 → 107 ms per frame. Those were the last single sample of each run. The medians are 40.0 → 38.1 ms GPU lists, cardmeter 40.8 → 40.9 ms, and 112 → 111 ms per frame. So on this CPU-bound stack native f16 shows at most a ~2 ms GPU gain and no measurable frame gain, although it was active (supported=true active=true). The ~8 ms drop in C came from the other PRs, not from f16, which my 23:17 note got wrong. None of this contradicts the microbenchmark: this workload simply isn't limited by ALU throughput.

**@⁠Proudnoob4** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7177371337) · edited 2026-11-25 23:26 UTC *AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. **This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.*** **Setup:** RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B: - **A** fxceless stack, f32 path - **B** = A + a local port of `Marvisak/VIctory#2825` native f16 - **C** = B + `#1168` + `#1147` + `#1164` (`VICTORY_CARD_PIECE_KB=16`) + `#1171` + `#1172` + a local commit (skip clean `card_dirty` copies; chunk wide compare dispatches to ≤ 65,535 groups) | In-world, from the logs | A | B | C | |---|---:|---:|---:| | FPS, 2nd-half median (max) | 8.8 (9.3) | 8.8 (9.7) | 8.9 (9.4) | | Usual frame, median | 112 ms | 111 ms | 113 ms | | GPU title lists (`all other lists`), 2nd-half median | 40.0 ms | 38.1 ms | **31.8 ms** | | `cardmeter`, 256-frame mean, steady | 40.8 ms | 40.9 ms | **31.6–33.7 ms** | | Copy-back (last usual-frame summary) | 23.2 ms / 62.5 MB | 22.4 ms / 60.9 MB | **28.4 ms** / 49.4 MB | | Pieces fetched on the copy queue / frame | ~1,370 | ~1,388 | **~4,138** | | Writes back in place / frame | 1,386 | 1,390 | 4,150 | | Card idle per frame | 62.5 ms | 68.7 ms | 68.8 ms | - **GPU:** title-list time fell by ~8 ms between B and C. Native f16 alone (A→B) changed it by ~2 ms at most (`cardmeter` unchanged). Which of C's additions gave the 8 ms is **not isolated**. - **No FPS change:** the frame is CPU-bound on the submit thread (copies ~63 ms + copy-back 22–28 ms of a ~110 ms frame), so the GPU saving does not reach the screen. - **Artifacts in C:** a frame grabbed at 330 s shows blocky corrupted tiles along the bottom of the screen and a stair-stepped edge on the character's shoulder. Which change causes it is **not isolated**. B's earlier frame looked clean. - **Stability:** no panic, device-removed or ERROR lines in C's log, no crash in 360 s. **For this PR:** the earlier report here (22:42) gave 38.8 → 34.1 ms GPU lists and 113 → 107 ms per frame. Those were the last single sample of each run. The medians are 40.0 → 38.1 ms GPU lists, `cardmeter` 40.8 → 40.9 ms, and 112 → 111 ms per frame. So on this CPU-bound stack native f16 shows at most a ~2 ms GPU gain and no measurable frame gain, although it was active (`supported=true active=true`). The ~8 ms drop in C came from the other PRs, not from f16, which my 23:17 note got wrong. None of this contradicts the microbenchmark: this workload simply isn't limited by ALU throughput.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-25 23:27 UTC · original

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 3c81083 (on its base f3578e3).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 870 passed, 0 failed, 11 ignored.
  • The new tests ran and passed: hosts_that_round_f16_fmad_twice_keep_the_f32_path, sixteen_bit_floats_match_the_hardware_natively, the_f16_fma_cases_round_once_in_the_model, fused_f16_results_round_once_natively, f16_results_round_as_the_mode_says_natively, native_16bit_operations_are_declared_where_used, native_f16_is_never_further_from_the_console.
  • The new benchmark translated_f16_math_costs is #[ignore]d and was not run.
  • --skip leaves out tests that fail on main 842b0cb on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-25 23:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7177587407) Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `3c81083` (on its base `f3578e3`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **870 passed, 0 failed, 11 ignored**. - The new tests ran and passed: `hosts_that_round_f16_fmad_twice_keep_the_f32_path`, `sixteen_bit_floats_match_the_hardware_natively`, `the_f16_fma_cases_round_once_in_the_model`, `fused_f16_results_round_once_natively`, `f16_results_round_as_the_mode_says_natively`, `native_16bit_operations_are_declared_where_used`, `native_f16_is_never_further_from_the_console`. - The new benchmark `translated_f16_math_costs` is `#[ignore]`d and was not run. - `--skip` leaves out tests that fail on main `842b0cb` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:20 UTC · original

Integration finding for #2915: with its production float_result change (dcf36ff) applied to this head (3c81083), turning on native half rejects seven shaders that translate and run with the f32 option. valu16_native claims their modified ADD/MUL instruction before #2915's output-modifier path can handle it. The error is an output modifier on a 16-bit operation is not supported. The unmodified ADD control passes.

I tried a local change allowing an instruction with v.omod != 0 to fall through from valu16_native to the ordinary lowering. On an RTX 5080, native capability check true, all seven then validated and returned the expected bits. The software option on the same RTX, and WARP with the capability check false, agreed. Two cases distinguish applying the modifier before binary16 rounding from scaling an already-rounded half:

Synthetic instruction (binary16 operand bits) Expected and observed
MUL(0001, 3800) × 2 0001; rounding the product to half first would yield zero
ADD(7bff, 7bff) × 0.5 7bff; rounding the sum to half first would overflow

The other cases covered ADD ×2, ×4, ×0.5, ×4 with clamp, and a single shader containing ordinary MUL followed by modified ADD. That mixed shader returned 4380 for (1.5 × 0.25 + 1.5) × 2 and still declared native 16-bit operations in SFI0. The fallback can therefore be per instruction. Modified exact FMA remained explicitly refused on both paths as #2915 specifies.

Windows 26300.10075, driver 621.40, synthetic RDNA2 → DXIL → D3D12 readbacks. Tested with Codex assistance.

**@⁠steven-seagull27** on GitHub · 2026-11-26 02:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7180707260) Integration finding for #2915: with its production `float_result` change (`dcf36ff`) applied to this head (`3c81083`), turning on native half **rejects seven shaders that translate and run with the f32 option**. `valu16_native` claims their modified ADD/MUL instruction before #2915's output-modifier path can handle it. The error is `an output modifier on a 16-bit operation is not supported`. The unmodified ADD control passes. I tried a local change allowing an instruction with `v.omod != 0` to fall through from `valu16_native` to the ordinary lowering. On an RTX 5080, native capability check true, all seven then validated and returned the expected bits. The software option on the same RTX, and WARP with the capability check false, agreed. Two cases distinguish applying the modifier before binary16 rounding from scaling an already-rounded half: | Synthetic instruction (binary16 operand bits) | Expected and observed | |---|---| | `MUL(0001, 3800) × 2` | `0001`; rounding the product to half first would yield zero | | `ADD(7bff, 7bff) × 0.5` | `7bff`; rounding the sum to half first would overflow | The other cases covered ADD ×2, ×4, ×0.5, ×4 with clamp, and a single shader containing ordinary MUL followed by modified ADD. That mixed shader returned `4380` for `(1.5 × 0.25 + 1.5) × 2` and still declared native 16-bit operations in SFI0. The fallback can therefore be per instruction. Modified exact FMA remained explicitly refused on both paths as #2915 specifies. Windows 26300.10075, driver 621.40, synthetic RDNA2 → DXIL → D3D12 readbacks. Tested with Codex assistance.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 02:22 UTC · original · edited 2026-11-26 03:21 UTC

Automated triage for the maintainers.

Re-reviewed at 47078d7. The only change since the last triage is the integration fix for #2915.

valu16_native (crates/victory-shader/src/emit/lower/half.rs) now returns None for any instruction with an output modifier, so that instruction falls back to the f32 path while the rest of the shader stays native. The refusal in valu16_native_op is gone because nothing can reach it now. The new test output_modifiers_on_f16_results_take_the_f32_path_natively checks that both paths translate or refuse such instructions alike. steven-seagull27 confirmed the combination with #2915 on RTX 5080 and WARP.

The earlier assessment stands. The native half path is gated on Native16BitShaderOpsSupported, a startup probe that 16-bit FMad rounds once, and VICTORY_F16_IN_F32. The option is part of the shader cache key. Points for the maintainer are unchanged: NaN payloads become the host's, the path is on by default where supported, and the diff is large.

Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 02:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7180743824) · edited 2026-11-26 03:21 UTC <!-- victory-triage v1 head=47078d7f3cb90335ec6efc921ef8f3f3ce4d178c verdict=merge-candidate at=2026-11-26T03:21:12Z --> Automated triage for the maintainers. Re-reviewed at `47078d7`. The only change since the last triage is the integration fix for #2915. `valu16_native` (`crates/victory-shader/src/emit/lower/half.rs`) now returns `None` for any instruction with an output modifier, so that instruction falls back to the f32 path while the rest of the shader stays native. The refusal in `valu16_native_op` is gone because nothing can reach it now. The new test `output_modifiers_on_f16_results_take_the_f32_path_natively` checks that both paths translate or refuse such instructions alike. steven-seagull27 confirmed the combination with #2915 on RTX 5080 and WARP. The earlier assessment stands. The native `half` path is gated on `Native16BitShaderOpsSupported`, a startup probe that 16-bit `FMad` rounds once, and `VICTORY_F16_IN_F32`. The option is part of the shader cache key. Points for the maintainer are unchanged: NaN payloads become the host's, the path is on by default where supported, and the diff is large. **Verdict: merge candidate** (a recommendation to look, not an approval). CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 02:36 UTC · original

@⁠steven-seagull27 thanks, that's exactly the integration case. Fixed in dbc004b: valu16_native now returns None for any instruction with an output modifier, so that instruction falls through to the f32 path on its own, and the rest of the shader stays native. #2825 and #2915 then compose whichever lands first, as your mixed shader shows. The refusal for those instructions that the native path could no longer reach is gone. Modified exact FMA stays refused, as #2915 specifies.

The new test output_modifiers_on_f16_results_take_the_f32_path_natively checks that VOP3 v_add/v_mul_f16 with mul:2, mul:4 and div:2 translate or refuse alike on both paths, and that a translated one declares no native ops. On main today both paths refuse them alike, because #2915 isn't in. Your RTX 5080 results with #2915 applied (MUL(0001, 3800) × 2 → 0001, ADD(7bff, 7bff) × 0.5 → 7bff) are what the combination should give; I didn't re-run them here. The native tests (21) pass on an RTX 5070 Ti, and clippy is clean.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 02:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7180957509) @⁠steven-seagull27 thanks, that's exactly the integration case. Fixed in dbc004b: `valu16_native` now returns `None` for any instruction with an output modifier, so that instruction falls through to the f32 path on its own, and the rest of the shader stays native. #2825 and #2915 then compose whichever lands first, as your mixed shader shows. The refusal for those instructions that the native path could no longer reach is gone. Modified exact FMA stays refused, as #2915 specifies. The new test `output_modifiers_on_f16_results_take_the_f32_path_natively` checks that VOP3 `v_add`/`v_mul_f16` with mul:2, mul:4 and div:2 translate or refuse alike on both paths, and that a translated one declares no native ops. On `main` today both paths refuse them alike, because #2915 isn't in. Your RTX 5080 results with #2915 applied (`MUL(0001, 3800) × 2 → 0001`, `ADD(7bff, 7bff) × 0.5 → 7bff`) are what the combination should give; I didn't re-run them here. The native tests (21) pass on an RTX 5070 Ti, and clippy is clean.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:42 UTC · original

Confirmed on current head 47078d7 (same tree as dbc004b) combined with #2915 at dcf36ff. All eight arithmetic readbacks matched on RTX 5080 with native half enabled and disabled, and on WARP. The minimum-subnormal and maximum-finite cases returned 0001 and 7bff. The mixed native MUL → modified ADD returned 4380 and retained the native-16 SFI0 bit. Modified-only shaders cleared that bit, and modified exact FMA still took the expected refusal on all three runs.

**@⁠steven-seagull27** on GitHub · 2026-11-26 02:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7181044404) Confirmed on current head `47078d7` (same tree as `dbc004b`) combined with #2915 at `dcf36ff`. All eight arithmetic readbacks matched on RTX 5080 with native half enabled and disabled, and on WARP. The minimum-subnormal and maximum-finite cases returned `0001` and `7bff`. The mixed native MUL → modified ADD returned `4380` and retained the native-16 SFI0 bit. Modified-only shaders cleared that bit, and modified exact FMA still took the expected refusal on all three runs.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 22:11 UTC · original · reviewed

Scoped review — the part that had to be right is right: the shader-cache build key folds options().native16 in, so an f16-native translation can never be served to a non-native host (and the un-initialized-host -> native16=false direction fails safe). options() centralizing view_marks+native16 prevents drift between the cached and uncached translate paths. The rest — bitcode f16 type, host probe, the +200 lines of f16 lowering — is a big surface; the DXIL-level tests plus the claimed 39x on the 5070 Ti suggest it's exercised, but a second pair of eyes on the rounding/saturation semantics of the packed-f16 ops would be worthwhile.

**@⁠kotekompotek** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#pullrequestreview-6065689604) · **reviewed** Scoped review — the part that had to be right is right: the shader-cache build key folds options().native16 in, so an f16-native translation can never be served to a non-native host (and the un-initialized-host -> native16=false direction fails safe). options() centralizing view_marks+native16 prevents drift between the cached and uncached translate paths. The rest — bitcode f16 type, host probe, the +200 lines of f16 lowering — is a big surface; the DXIL-level tests plus the claimed 39x on the 5070 Ti suggest it's exercised, but a second pair of eyes on the rounding/saturation semantics of the packed-f16 ops would be worthwhile.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:47 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-shader --lib (all 8 new native-f16 tests): passed on RTX 5090 (sixteen_bit_floats_match_the_hardware_natively, fused_f16_results_round_once_natively, f16_results_round_as_the_mode_says_natively, native_f16_is_never_further_from_the_console, output_modifiers_on_f16_results_take_the_f32_path_natively, native_16bit_operations_are_declared_where_used, hosts_that_round_f16_fmad_twice_keep_the_f32_path, the_f16_fma_cases_round_once_in_the_model).
  • cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 4/4 passed.
  • cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Cleanly enables native 16-bit floating-point arithmetic on hosts that support it and pass the single-rounding FMA probe, with proper shader cache keying.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#pullrequestreview-6071816421) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib` (all 8 new native-f16 tests): passed on RTX 5090 (`sixteen_bit_floats_match_the_hardware_natively`, `fused_f16_results_round_once_natively`, `f16_results_round_as_the_mode_says_natively`, `native_f16_is_never_further_from_the_console`, `output_modifiers_on_f16_results_take_the_f32_path_natively`, `native_16bit_operations_are_declared_where_used`, `hosts_that_round_f16_fmad_twice_keep_the_f32_path`, `the_f16_fma_cases_round_once_in_the_model`). - `cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1`: 4/4 passed. - `cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Cleanly enables native 16-bit floating-point arithmetic on hosts that support it and pass the single-rounding FMA probe, with proper shader cache keying. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 10:22 UTC · original · approved these changes

Audited the DXIL encoding, native half lowering (lower/half.rs and packed16), rounding-mode / omod gating, rounds_f16_fmad_once probe, and shader_cache key isolation, and verified on Windows 11 with an RTX 5090, WARP, and the Windows 11 SDK validator (10.0.26100.0\x64\dxil.dll).

Verification (origin/main 63bcca43 merge-tree clean)

  • cargo clippy --workspace --all-targets --locked -- -D warnings (default & --all-features): clean; cargo xtask policy: 191 files ok.
  • victory-shader with SDK dxil.dll validation: all 9 f16 / native16 tests passed (hosts_that_round_f16_fmad_twice_keep_the_f32_path, sixteen_bit_floats_match_the_hardware, sixteen_bit_floats_match_the_hardware_natively, the_f16_fma_cases_round_once_in_the_model, fused_f16_results_round_once_natively, f16_results_round_as_the_mode_says_natively, output_modifiers_on_f16_results_take_the_f32_path_natively, native_16bit_operations_are_declared_where_used, native_f16_is_never_further_from_the_console):
    • RTX 5090: rounds_f16_fmad_once() == Ok(true), native16() == true; 0 model mismatches across all 23 probes, the #2384 cases, and 8,192 random finite/denormal FMA triples; native_f16_is_never_further_from_the_console differed on 1 packed FMA input (toward the model).
    • WARP: rounds_f16_fmad_once() == Ok(false), native16() == false (keeps f32 path).
    • emit::bitcode:: + emit::lower::tests::: 45/45 passed.
  • RTX 5090 release benchmark (translated_f16_math_costs, 4,096-inst chains, 262,144 threads, best of 5 × 10 dispatches):
    • v_pk_fma_f16: 2.284 ms (940 G f16 ops/s) → 0.036 ms (60,404 G f16 ops/s) — 64.3x (262,144/262,144 identical)
    • v_fma_f16: 1.297 ms (828 G) → 0.035 ms (30,402 G) — 36.7x (262,144/262,144 identical)
    • v_mul_f16 + v_add_f16: 1.017 ms (1,056 G) → 0.035 ms (30,632 G) — 29.0x (262,144/262,144 identical)
  • victory-gpu: shader_cache::tests:: 4/4 passed on RTX 5090 default, RTX 5090 VICTORY_F16_IN_F32=1 (short-circuits the probe), RTX 5090 VICTORY_D3D12_DEBUG=1, and WARP VICTORY_D3D12_DEBUG=1; draw::tests:: 20/20 passed on RTX 5090.

Minor non-blocking note

Inspecting ID3D12InfoQueue under the D3D12 Debug Layer shows Host::fmad_probe (crates/victory-shader/src/emit/host.rs:694, shared with the pre-existing fuses_fmad check) binds only the CBV/SRV/UAV descriptor heap before SetComputeRootSignature(&root), while root_signature_for sets D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED, logging D3D12_MESSAGE_ID(1419) (ERROR) once per probe call on both RTX 5090 and WARP (2 messages total now: once from fuses_fmad, once from rounds_f16_fmad_once). Pre-existing on main and harmless for the probe dispatch, though binding a 1-slot shader-visible sampler heap alongside views in fmad_probe would keep the debug queue completely clean (fine as a follow-up).

**@⁠fuzeofficlal** on GitHub · 2026-11-26 10:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#pullrequestreview-6072346702) · **approved these changes** Audited the DXIL encoding, native `half` lowering (`lower/half.rs` and `packed16`), rounding-mode / `omod` gating, `rounds_f16_fmad_once` probe, and `shader_cache` key isolation, and verified on Windows 11 with an RTX 5090, WARP, and the Windows 11 SDK validator (`10.0.26100.0\x64\dxil.dll`). ### Verification (`origin/main` `63bcca43` merge-tree clean) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default & `--all-features`): clean; `cargo xtask policy`: 191 files ok. - **`victory-shader` with SDK `dxil.dll` validation**: all 9 f16 / native16 tests passed (`hosts_that_round_f16_fmad_twice_keep_the_f32_path`, `sixteen_bit_floats_match_the_hardware`, `sixteen_bit_floats_match_the_hardware_natively`, `the_f16_fma_cases_round_once_in_the_model`, `fused_f16_results_round_once_natively`, `f16_results_round_as_the_mode_says_natively`, `output_modifiers_on_f16_results_take_the_f32_path_natively`, `native_16bit_operations_are_declared_where_used`, `native_f16_is_never_further_from_the_console`): - RTX 5090: `rounds_f16_fmad_once() == Ok(true)`, `native16() == true`; 0 model mismatches across all 23 probes, the `#2384` cases, and 8,192 random finite/denormal FMA triples; `native_f16_is_never_further_from_the_console` differed on 1 packed FMA input (toward the model). - WARP: `rounds_f16_fmad_once() == Ok(false)`, `native16() == false` (keeps f32 path). - `emit::bitcode::` + `emit::lower::tests::`: 45/45 passed. - **RTX 5090 release benchmark (`translated_f16_math_costs`, 4,096-inst chains, 262,144 threads, best of 5 × 10 dispatches)**: - `v_pk_fma_f16`: `2.284 ms` (`940 G` f16 ops/s) → **`0.036 ms`** (`60,404 G` f16 ops/s) — **64.3x** (262,144/262,144 identical) - `v_fma_f16`: `1.297 ms` (`828 G`) → **`0.035 ms`** (`30,402 G`) — **36.7x** (262,144/262,144 identical) - `v_mul_f16 + v_add_f16`: `1.017 ms` (`1,056 G`) → **`0.035 ms`** (`30,632 G`) — **29.0x** (262,144/262,144 identical) - **`victory-gpu`**: `shader_cache::tests::` 4/4 passed on RTX 5090 default, RTX 5090 `VICTORY_F16_IN_F32=1` (short-circuits the probe), RTX 5090 `VICTORY_D3D12_DEBUG=1`, and WARP `VICTORY_D3D12_DEBUG=1`; `draw::tests::` 20/20 passed on RTX 5090. ### Minor non-blocking note Inspecting `ID3D12InfoQueue` under the D3D12 Debug Layer shows `Host::fmad_probe` (`crates/victory-shader/src/emit/host.rs:694`, shared with the pre-existing `fuses_fmad` check) binds only the CBV/SRV/UAV descriptor heap before `SetComputeRootSignature(&root)`, while `root_signature_for` sets `D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED`, logging `D3D12_MESSAGE_ID(1419)` (`ERROR`) once per probe call on both RTX 5090 and WARP (2 messages total now: once from `fuses_fmad`, once from `rounds_f16_fmad_once`). Pre-existing on `main` and harmless for the probe dispatch, though binding a 1-slot shader-visible sampler heap alongside `views` in `fmad_probe` would keep the debug queue completely clean (fine as a follow-up).
Author
Owner

@⁠liandraraiane on GitHub · 2026-11-26 12:49 UTC · original

First Ampere (RTX 30) result, since the native path is gated on the card rounding a 16-bit FMad once and no RTX 30 card was in the thread yet.

Setup: NVIDIA GeForce RTX 3060 12 GB (Ampere, GA106), driver 610.88, Ryzen 7 5700G, Windows 11 Pro 26200, Rust 1.98.1, dxil.dll from Windows SDK 10.0.26100, release. This PR's head merged onto main 63bcca4 (one conflict in the test harness's dispatch, with a local timing hook of mine; the PR's code is unchanged). No game data.

Capability and correctness (the natively tests): 4/4 pass.

  • fused_f16_results_round_once_natively: passes, so this card's native 16-bit FMA rounds once and the native path turns on for the RTX 30 series too (v_fma_f16 over 8,192 inputs: 0 model mismatches).
  • sixteen_bit_floats_match_the_hardware_natively: 0 model mismatches on hardware for every probed operation (add, sub, mul, min, max, fma, fmac, pack, rcp, sqrt, rsq, exp, log, and the packed add/mul/fma/fmac with and without sel_hi_lo); WARP skipped as expected (no once-rounding FMad).
  • f16_results_round_as_the_mode_says_natively, output_modifiers_on_f16_results_take_the_f32_path_natively: pass.

translated_f16_math_costs, 5 runs (each the bench's own best of five), median:

Chain (4,096 instructions, 4,096 groups) f32 path native speed-up
v_pk_fma_f16 25.08 ms 0.631 ms 39.8x
v_fma_f16 24.07 ms 0.330 ms 73x
v_mul_f16 + v_add_f16 12.03 ms 0.330 ms 36.4x

Results alike in 262,144 of 262,144 threads in every run. The first run's native v_fma_f16 was 1.275 ms (warm-up); the other four were 0.329–0.331 ms.

Full victory-shader suite with the native path on: 306 passed, 3 failed, the same three that fail on main on this card (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware: the capped view heap of #1835); main alone: 298 passed, the same 3 failed. No new failure.

Not tested: a title (only synthetic chains and the PR's tests), other Ampere cards.

AI use: Claude Code ran the builds, tests and benchmark on this machine and drafted this comment.

**@⁠liandraraiane** on GitHub · 2026-11-26 12:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7192504276) First Ampere (RTX 30) result, since the native path is gated on the card rounding a 16-bit `FMad` once and no RTX 30 card was in the thread yet. **Setup:** NVIDIA GeForce RTX 3060 12 GB (Ampere, GA106), driver 610.88, Ryzen 7 5700G, Windows 11 Pro 26200, Rust 1.98.1, `dxil.dll` from Windows SDK 10.0.26100, release. This PR's head merged onto `main` `63bcca4` (one conflict in the test harness's dispatch, with a local timing hook of mine; the PR's code is unchanged). No game data. **Capability and correctness (the `natively` tests):** 4/4 pass. - `fused_f16_results_round_once_natively`: passes, so this card's native 16-bit FMA rounds once and the native path turns on for the RTX 30 series too (`v_fma_f16` over 8,192 inputs: 0 model mismatches). - `sixteen_bit_floats_match_the_hardware_natively`: 0 model mismatches on hardware for every probed operation (add, sub, mul, min, max, fma, fmac, pack, rcp, sqrt, rsq, exp, log, and the packed add/mul/fma/fmac with and without `sel_hi_lo`); WARP skipped as expected (no once-rounding `FMad`). - `f16_results_round_as_the_mode_says_natively`, `output_modifiers_on_f16_results_take_the_f32_path_natively`: pass. **`translated_f16_math_costs`**, 5 runs (each the bench's own best of five), median: | Chain (4,096 instructions, 4,096 groups) | f32 path | native | speed-up | |---|---:|---:|---:| | `v_pk_fma_f16` | 25.08 ms | 0.631 ms | 39.8x | | `v_fma_f16` | 24.07 ms | 0.330 ms | 73x | | `v_mul_f16` + `v_add_f16` | 12.03 ms | 0.330 ms | 36.4x | Results alike in 262,144 of 262,144 threads in every run. The first run's native `v_fma_f16` was 1.275 ms (warm-up); the other four were 0.329–0.331 ms. **Full `victory-shader` suite with the native path on:** 306 passed, 3 failed, the same three that fail on `main` on this card (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`: the capped view heap of #1835); `main` alone: 298 passed, the same 3 failed. No new failure. Not tested: a title (only synthetic chains and the PR's tests), other Ampere cards. AI use: Claude Code ran the builds, tests and benchmark on this machine and drafted this comment.
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 15:37 UTC · original

Merged and run on the retail title: no GPU reduction in one run, but the scenes are not comparable — how do I force the mode off for a matched A/B?

Setup: this PR merged into 63bcca4 (clean), RX 7900 XTX (1002:744c, driver 32.0.32029.2010), Windows 10 26300.10075, retail 1.0.2.1, diagnostics build, 300 s. I translated the whole pack with this tree first (translate --cache: 25,669 translated, 220 refused — identical to the unpatched tree, so nothing regressed in translation), then ran with a warm cache.

63bcca4 + this PR
frame (last report) 1,229.5 ms 1,163.6 ms
on the GPU 161.6 ms 222.6 ms
copies 203.0 ms / 379.7 MB 744.7 ms / 746.4 MB
prepare 368.5 ms 660.0 ms
draws / dropped 3,926 / 949 1,293 / 1,289

The GPU number went up, not down, and the draw counts are far apart (3,926 against 1,293, with 1,289 dropped against 949), so this is not an A/B of the f16 change at all: the two runs are in different scenes and the second is missing a third of its draws.

Before I conclude anything I would like to compare the same scene with the change on and off. Is Options::native16 reachable from an environment variable or a switch in this branch (as VICTORY_* switches are elsewhere), or is it decided by the host's capability alone? If it is capability-driven and there is no switch, I can build two binaries locally (one with the option forced off) and run them against the same save — say the word and I will, with the number of legacyF16ToF32/legacyF32ToF16 ops per frame as the thing that should move.

One thing that would help either way: which passes in this title use f16 chains heavily? Our world frame is ~370 ms of preparation and ~160 ms of GPU, so a 37x win on the passes you measured should be visible in the GPU number if those passes are in the world — and if it is not visible, that itself is worth knowing.

Written with an AI assistant.

**@⁠Jackster** on GitHub · 2026-11-26 15:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7196531789) **Merged and run on the retail title: no GPU reduction in one run, but the scenes are not comparable — how do I force the mode off for a matched A/B?** Setup: this PR merged into `63bcca4` (clean), RX 7900 XTX (`1002:744c`, driver 32.0.32029.2010), Windows 10 26300.10075, retail 1.0.2.1, diagnostics build, 300 s. I translated the whole pack with this tree first (`translate --cache`: 25,669 translated, 220 refused — identical to the unpatched tree, so nothing regressed in translation), then ran with a warm cache. | | `63bcca4` | + this PR | |---|---|---| | frame (last report) | 1,229.5 ms | 1,163.6 ms | | on the GPU | 161.6 ms | **222.6 ms** | | copies | 203.0 ms / 379.7 MB | 744.7 ms / 746.4 MB | | prepare | 368.5 ms | 660.0 ms | | draws / dropped | 3,926 / 949 | 1,293 / 1,289 | The GPU number went **up**, not down, and the draw counts are far apart (3,926 against 1,293, with 1,289 dropped against 949), so this is not an A/B of the f16 change at all: the two runs are in different scenes and the second is missing a third of its draws. Before I conclude anything I would like to compare the same scene with the change on and off. Is `Options::native16` reachable from an environment variable or a switch in this branch (as `VICTORY_*` switches are elsewhere), or is it decided by the host's capability alone? If it is capability-driven and there is no switch, I can build two binaries locally (one with the option forced off) and run them against the same save — say the word and I will, with the number of `legacyF16ToF32`/`legacyF32ToF16` ops per frame as the thing that should move. One thing that would help either way: which passes in this title use f16 chains heavily? Our world frame is ~370 ms of preparation and ~160 ms of GPU, so a 37x win on the passes you measured should be visible in the GPU number if those passes are in the world — and if it is not visible, that itself is worth knowing. Written with an AI assistant.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 18:04 UTC · original

Thanks. There's a switch for exactly this: VICTORY_F16_IN_F32=1 keeps f16 arithmetic in f32 on any host (host::native16). The startup log's host native 16-bit float operations native=… line says which mode a run is in. The shader cache key includes the mode, so each setting keeps its own entries. Warm the cache once per setting (translate --cache with and without the switch), then run the same save both ways.

One thing in your table worries me more than the GPU number: with this PR, 1,289 of 1,293 draws were dropped, against 949 of 3,926 without it. A different scene could explain the draw count, but nearly every draw dropped could also mean the native-half translations are refused when the host makes their pipelines on the 7900 XTX. Could you check, in the same scene with the switch off and on, the reasons on the dropped ... without a host pipeline lines, and whether CreateComputePipelineState/CreateGraphicsPipelineState failures appear in the log? If the drops follow the switch, that's a bug here and I'll fix it before anything else.

On which passes use f16 heavily: I can't say from here, since I don't look at title data. The legacyF16ToF32/legacyF32ToF16 counts per frame you suggest are a good proxy: wherever f16 chains run, they should be much lower in native mode (switch unset) than with VICTORY_F16_IN_F32=1.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 18:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7200029634) Thanks. There's a switch for exactly this: `VICTORY_F16_IN_F32=1` keeps f16 arithmetic in f32 on any host (`host::native16`). The startup log's `host native 16-bit float operations native=…` line says which mode a run is in. The shader cache key includes the mode, so each setting keeps its own entries. Warm the cache once per setting (`translate --cache` with and without the switch), then run the same save both ways. One thing in your table worries me more than the GPU number: with this PR, 1,289 of 1,293 draws were dropped, against 949 of 3,926 without it. A different scene could explain the draw count, but nearly every draw dropped could also mean the native-`half` translations are refused when the host makes their pipelines on the 7900 XTX. Could you check, in the same scene with the switch off and on, the reasons on the `dropped ... without a host pipeline` lines, and whether `CreateComputePipelineState`/`CreateGraphicsPipelineState` failures appear in the log? If the drops follow the switch, that's a bug here and I'll fix it before anything else. On which passes use f16 heavily: I can't say from here, since I don't look at title data. The `legacyF16ToF32`/`legacyF32ToF16` counts per frame you suggest are a good proxy: wherever f16 chains run, they should be much lower in native mode (switch unset) than with `VICTORY_F16_IN_F32=1`.
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/2825/head:github-bot/gh-2825'
git switch 'github-bot/gh-2825'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2825'
git switch 'github-bot/gh-2825'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2825'
git switch 'github-bot/gh-2825'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2825'
git switch 'main'
git merge --squash 'github-bot/gh-2825'
git switch 'main'
git merge --ff-only 'github-bot/gh-2825'
git switch 'main'
git merge 'github-bot/gh-2825'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2825
No description provided.