Shaders: f16 arithmetic in native half on hosts with 16-bit operations (port of Marvisak/VIctory#2825) #502

Open
github-bot wants to merge 1 commit from github-bot/gh-502 into a-publier AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-27 07:42 UTC · original
0xkn0wh3r3:port/native-f16 → a-publier · +826 −28 · 16 files · 1 commits · open

This ports Marvisak/VIctory#2825 to this tree. That PR was written against Marvisak's main, which this tree's emitter has moved away from, so this is a re-implementation rather than a cherry-pick. It keeps the original's intent and its gate on the host's 16-bit support.

The problem

The translator does every console f16 operation in f32 and converts each result back with the host's own conversion (legacyF32ToF16, or f16_nearest in integer code with VICTORY_F16_NEAREST=1). Marvisak/VIctory#2806 measured that path at 34x the host's own half2 math on an RTX 5070 Ti. RDNA runs 16-bit floats natively, so on the cards this tree targets that work is wasted.

The change

On a host that runs native 16-bit operations and rounds a 16-bit FMad once, these become DXIL half arithmetic:

  • v_add/sub/subrev/mul_f16, v_fma/fmac_f16, v_min/max/min3/max3/med3_f16
  • 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 -0) are decided on the bits. On RDNA (rdna::MAX_MIN) min/max are the host's own, as this tree's f32 path already does there.

Sums, differences and products round once to nearest even, the console's MODE default. Fused multiply-adds round once, as the console's v_fma_f16 and v_pk_fma_f16 do. The f32 path rounds them twice.

These stay on the f32 path: conversions, interpolation, v_mad/mac_f16, v_fma_mix*, instructions with an output modifier, and the transcendental and rounding operations.

  • DXIL: a half type in the bitcode writer, and Usage::native16 for live half or i16 values. The lowering sets LowPrecisionPresent | UseNativeLowPrecision where it makes a half, and the clean-up clears them again if it removes every use. SFI0 gets the native 16-bit bit, and the module gets the 16-bit data layout. A module without native 16-bit values is unchanged.
  • Host check: emit::host::Host::native16 needs two things. The device must report Native16BitShaderOpsSupported (D3D12 OPTIONS4). A 16-bit FMad must round once: rounds_f16_fmad_once dispatches Marvisak/VIctory#2384's case 3c01·3e00+8001, lowered natively, and expects 3e01. victory-gpu asks once at device creation, after the wave size and RDNA facts, and tells the translator with emit::set_host_native16, as it does those. VICTORY_F16_IN_F32=1 keeps the f32 path on any host. WARP rounds the FMad twice and keeps it too.
  • Shader cache: the cache key (and translation_fingerprint) take the setting only when it is on. Entries from the f32 path keep their key, and one path's entries never serve the other. TRANSLATOR_VERSION is unchanged, because the f32 path's translations are the same.
  • victory translate --pipelines translates as for its adapter, as it already does for the wave size and RDNA. VICTORY_F16_IN_F32=1 gives f32.
  • emit::host's dispatch helpers are no longer test-only, because the probe uses them.

How it differs from the original

  • No mode16 gate. This tree does not model the MODE register, so a program that rounds toward zero also gets nearest even. The f32 path here already uses the host's rounding whatever MODE says.
  • Plumbing: this tree has no emit::Options, so the setting is a host global like set_host_rdna, set by victory-gpu when the device is created.
  • RDNA: min/max use the host's own operations on RDNA.
  • Tests: the original's tests are in semantics_tests.rs, which this tree does not have. New ones are in valu_tests.rs, checked against an exact f16 model.
  • Not ported: the ignored benchmark translated_f16_math_costs.

Testing

New tests:

  • native_f16_arithmetic_rounds_once_to_nearest_even: add, sub, subrev, mul, fma and fmac, plus v_pk_add/mul/fma_f16 on both halves. Inputs are random finite values (denormals included) and Marvisak/VIctory#2384's three FMA cases, checked against an exact single-rounding model.
  • native_f16_zeros_nans_and_clamp_are_the_consoles: the zero order of min/max/min3/max3, med3 with NaNs, and the clamp. On an RDNA adapter it also runs in the RDNA form.
  • native_16bit_operations_are_declared_where_used: the SFI0 bit is set for native arithmetic. It is not set for the f32 path, or for a conversion.
  • hosts_that_round_f16_fmad_twice_keep_the_f32_path: WARP is refused.
  • emit::tests::the_fingerprint_says_whether_f16_is_native.

Results:

  • The native tests pass on an RTX 5070 Ti and on an AMD Radeon iGPU (Ryzen 9800X3D, chosen with VICTORY_D3D12_ADAPTER). Both pass Host::native16.
  • With dxil.dll as validator, the native modules validate. As a control, dropping the 16-bit flags fails validation ("Bitcast on minprecison types is not allowed"). This validator does not check the data layout.
  • cargo test -p victory-shader: 308 passed, 0 failed, 4 ignored.
  • cargo test -p victory-gpu: 396 passed, 0 failed, 34 ignored.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • cargo xtask policy: ok.

Not verified

  • Not run on a discrete RDNA2/3/4 card. Only the iGPU and the NVIDIA card were tested.
  • No game run, and no frame-time number.
  • The startup check tests one FMA case only.
  • NaN payloads of the console's own v_add_f16 and the like are not known. The native path takes the host's.
  • The native path is on by default where supported. VICTORY_F16_IN_F32=1 turns it off.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-27 07:42 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502) `0xkn0wh3r3:port/native-f16` → `a-publier` · +826 −28 · 16 files · 1 commits · open This ports [Marvisak/VIctory#2825](https://github.com/Marvisak/VIctory/pull/2825) to this tree. That PR was written against Marvisak's `main`, which this tree's emitter has moved away from, so this is a re-implementation rather than a cherry-pick. It keeps the original's intent and its gate on the host's 16-bit support. ## The problem The translator does every console f16 operation in f32 and converts each result back with the host's own conversion (`legacyF32ToF16`, or `f16_nearest` in integer code with `VICTORY_F16_NEAREST=1`). Marvisak/VIctory#2806 measured that path at 34x the host's own `half2` math on an RTX 5070 Ti. RDNA runs 16-bit floats natively, so on the cards this tree targets that work is wasted. ## The change On a host that runs native 16-bit operations and rounds a 16-bit `FMad` once, these become DXIL `half` arithmetic: - `v_add/sub/subrev/mul_f16`, `v_fma/fmac_f16`, `v_min/max/min3/max3/med3_f16` - `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 -0) are decided on the bits. On RDNA (`rdna::MAX_MIN`) min/max are the host's own, as this tree's f32 path already does there. Sums, differences and products round once to nearest even, the console's MODE default. Fused multiply-adds round once, as the console's `v_fma_f16` and `v_pk_fma_f16` do. The f32 path rounds them twice. These stay on the f32 path: conversions, interpolation, `v_mad/mac_f16`, `v_fma_mix*`, instructions with an output modifier, and the transcendental and rounding operations. - **DXIL:** a `half` type in the bitcode writer, and `Usage::native16` for live `half` or `i16` values. The lowering sets `LowPrecisionPresent | UseNativeLowPrecision` where it makes a `half`, and the clean-up clears them again if it removes every use. SFI0 gets the native 16-bit bit, and the module gets the 16-bit data layout. A module without native 16-bit values is unchanged. - **Host check:** `emit::host::Host::native16` needs two things. The device must report `Native16BitShaderOpsSupported` (D3D12 OPTIONS4). A 16-bit `FMad` must round once: `rounds_f16_fmad_once` dispatches Marvisak/VIctory#2384's case `3c01·3e00+8001`, lowered natively, and expects `3e01`. victory-gpu asks once at device creation, after the wave size and RDNA facts, and tells the translator with `emit::set_host_native16`, as it does those. `VICTORY_F16_IN_F32=1` keeps the f32 path on any host. WARP rounds the `FMad` twice and keeps it too. - **Shader cache:** the cache key (and `translation_fingerprint`) take the setting only when it is on. Entries from the f32 path keep their key, and one path's entries never serve the other. `TRANSLATOR_VERSION` is unchanged, because the f32 path's translations are the same. - **`victory translate --pipelines`** translates as for its adapter, as it already does for the wave size and RDNA. `VICTORY_F16_IN_F32=1` gives f32. - `emit::host`'s dispatch helpers are no longer test-only, because the probe uses them. ## How it differs from the original - **No `mode16` gate.** This tree does not model the MODE register, so a program that rounds toward zero also gets nearest even. The f32 path here already uses the host's rounding whatever MODE says. - **Plumbing:** this tree has no `emit::Options`, so the setting is a host global like `set_host_rdna`, set by victory-gpu when the device is created. - **RDNA:** min/max use the host's own operations on RDNA. - **Tests:** the original's tests are in `semantics_tests.rs`, which this tree does not have. New ones are in `valu_tests.rs`, checked against an exact f16 model. - **Not ported:** the ignored benchmark `translated_f16_math_costs`. ## Testing New tests: - `native_f16_arithmetic_rounds_once_to_nearest_even`: add, sub, subrev, mul, fma and fmac, plus `v_pk_add/mul/fma_f16` on both halves. Inputs are random finite values (denormals included) and Marvisak/VIctory#2384's three FMA cases, checked against an exact single-rounding model. - `native_f16_zeros_nans_and_clamp_are_the_consoles`: the zero order of min/max/min3/max3, med3 with NaNs, and the clamp. On an RDNA adapter it also runs in the RDNA form. - `native_16bit_operations_are_declared_where_used`: the SFI0 bit is set for native arithmetic. It is not set for the f32 path, or for a conversion. - `hosts_that_round_f16_fmad_twice_keep_the_f32_path`: WARP is refused. - `emit::tests::the_fingerprint_says_whether_f16_is_native`. Results: - The native tests pass on an RTX 5070 Ti and on an AMD Radeon iGPU (Ryzen 9800X3D, chosen with `VICTORY_D3D12_ADAPTER`). Both pass `Host::native16`. - With `dxil.dll` as validator, the native modules validate. As a control, dropping the 16-bit flags fails validation ("Bitcast on minprecison types is not allowed"). This validator does not check the data layout. - `cargo test -p victory-shader`: 308 passed, 0 failed, 4 ignored. - `cargo test -p victory-gpu`: 396 passed, 0 failed, 34 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `cargo xtask policy`: ok. ## Not verified - Not run on a discrete RDNA2/3/4 card. Only the iGPU and the NVIDIA card were tested. - No game run, and no frame-time number. - The startup check tests one FMA case only. - NaN payloads of the console's own `v_add_f16` and the like are not known. The native path takes the host's. - The native path is on by default where supported. `VICTORY_F16_IN_F32=1` turns it off.
Port of Marvisak/VIctory#2825 onto a-publier, re-implemented against this
branch's emitter (which has no emit::Options, no MODE tracking and its own
f32 path for 16-bit floats).

The translator does every console f16 operation in f32 and converts each
result back with the host's own conversion (VICTORY_F16_NEAREST=1: rounded
to nearest in integer code). On a host that runs native 16-bit operations
and rounds a 16-bit FMad once, these become DXIL half arithmetic instead:
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 (abs/neg flip
the sign bit), 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
-0) are decided on the bits; on RDNA (rdna::MAX_MIN) min/max are the host's
own, as the f32 path's are there. Sums, differences and products round once
to nearest even (the console's MODE default), fused multiply-adds round
once as the console's v_fma_f16 and v_pk_fma_f16 do (the f32 path rounds
them twice). Conversions, interpolation, v_mad/mac_f16, v_fma_mix*,
instructions with an output modifier and the transcendental and rounding
operations stay on the f32 path.

- DXIL: a half type in the bitcode writer; Usage::native16 for live half or
  i16 values. The lowering sets LowPrecisionPresent | UseNativeLowPrecision
  where it makes a half (cleared again if the clean-up removes every use),
  SFI0 gets the native 16-bit bit and the module the 16-bit data layout. A
  module without native 16-bit values is unchanged.
- Host: emit::host::Host::native16 needs Native16BitShaderOpsSupported
  (D3D12 OPTIONS4) and a 16-bit FMad that rounds once
  (rounds_f16_fmad_once dispatches #2384's 3c01*3e00+8001 lowered natively
  and expects 3e01). victory-gpu asks once at device creation, after the
  wave size and RDNA facts, and tells the translator with
  emit::set_host_native16, as it does those. VICTORY_F16_IN_F32=1 keeps
  the f32 path. WARP rounds the FMad twice and keeps it too.
- Cache: the shader cache key (and translation_fingerprint) take the
  setting only when it is on, so f32-path entries keep their key and one
  path's entries never serve the other. TRANSLATOR_VERSION is unchanged:
  the f32 path's translations are the same.
- victory translate --pipelines translates as for its adapter, as it does
  for the wave size and RDNA (VICTORY_F16_IN_F32=1: f32).
- emit::host's dispatch helpers are no longer test-only (the probe uses
  them).

Differences from the original: no mode16 gate (this branch does not model
MODE, so a program that rounds toward zero also gets nearest even); the
probe and flag plumbing follow this branch's host settings instead of
emit::Options; the RDNA min/max shortcut; the tests are new ones in
valu_tests.rs against an exact f16 model (semantics_tests.rs does not exist
here), and the ignored translated_f16_math_costs benchmark is not ported.

Tests (valu_tests.rs): native_f16_arithmetic_rounds_once_to_nearest_even
(add/sub/subrev/mul/fma/fmac and pk_add/pk_mul/pk_fma on random finite
inputs with denormals and #2384's cases, against an exact model),
native_f16_zeros_nans_and_clamp_are_the_consoles (also in the RDNA form on
an RDNA adapter), native_16bit_operations_are_declared_where_used,
hosts_that_round_f16_fmad_twice_keep_the_f32_path; emit::tests::
the_fingerprint_says_whether_f16_is_native. Run on an RTX 5070 Ti and on an
AMD Radeon iGPU (VICTORY_D3D12_ADAPTER), both of which pass Host::native16;
WARP is refused. With dxil.dll as validator, dropping the 16-bit flags
fails validation ("Bitcast on minprecison types is not allowed").
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 07:43:25 +00:00
Author
Owner

@⁠gw1337x on GitHub · 2026-11-27 09:59 UTC · original

Tested in the title on RDNA 3: RX 7800 XT 16 GB, driver 32.0.32015.7029, Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds (--profile diag --features diagnostics) of 37b25cc and its base 4eb6cfd, same boot.

The path comes on here: host native 16-bit float operations native16=true.

Settings: scripts/play.ps1 settings plus VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, Series X profile, ray tracing off. Method: 270 s hands-off from a Chapter I boat save; fps is the layer's 1 s figure from the window title, sampled every second, 45-265 s with 1000+ draws ("steady" from 205 s); per-frame figures from VICTORY_TIMELINE windows of 30 frames at 200 s and 240 s. A first run of the PR filled the shader cache under the new key and is left out.

Run (order) Build steady fps (title / layer's log) card running per frame
1 37b25cc 29.0 / 28.5 31.3-32.3 ms
2 4eb6cfd 29.0 / 28.8 31.4-32.2 ms
3 37b25cc 29.0 / 28.7 31.6-31.9 ms

No change I can tell apart from noise in this scene, where the card is the limit (about 31-32 ms of a 34 ms frame). The picture at 241 s matches the base. No device loss. I did not count how many of this scene's shaders have f16 arithmetic.

**@⁠gw1337x** on GitHub · 2026-11-27 09:59 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502#issuecomment-7215338673) Tested in the title on RDNA 3: RX 7800 XT 16 GB, driver 32.0.32015.7029, Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds (`--profile diag --features diagnostics`) of `37b25cc` and its base `4eb6cfd`, same boot. The path comes on here: `host native 16-bit float operations native16=true`. Settings: `scripts/play.ps1` settings plus `VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1`, Series X profile, ray tracing off. Method: 270 s hands-off from a Chapter I boat save; fps is the layer's 1 s figure from the window title, sampled every second, 45-265 s with 1000+ draws ("steady" from 205 s); per-frame figures from `VICTORY_TIMELINE` windows of 30 frames at 200 s and 240 s. A first run of the PR filled the shader cache under the new key and is left out. | Run (order) | Build | steady fps (title / layer's log) | card running per frame | |---|---|---|---| | 1 | `37b25cc` | 29.0 / 28.5 | 31.3-32.3 ms | | 2 | `4eb6cfd` | 29.0 / 28.8 | 31.4-32.2 ms | | 3 | `37b25cc` | 29.0 / 28.7 | 31.6-31.9 ms | No change I can tell apart from noise in this scene, where the card is the limit (about 31-32 ms of a 34 ms frame). The picture at 241 s matches the base. No device loss. I did not count how many of this scene's shaders have f16 arithmetic.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 11:11 UTC · original

Data from one real frame on a discrete RDNA 3 card. RX 7900 XT, driver 32.0.32029.2010, Windows 11 26300, diag profile. PR head 37b25cc against a-publier 4eb6cfd.

A disclosure first. I used victory replay --retranslate on a recorded frame, and that path never turns native half on. The PR calls set_host_native16 at device creation in victory-gpu and in victory translate, not in retranslate, so there it translates in f32. To get native-half shaders I added a local env switch (six lines, not in the PR) that calls emit::set_host_native16(true) next to set_host_rdna(true) there. That forces the path and does not ask the card. I did not run Host::native16 on this card, the PR's GPU tests, or the game with this PR, so I do not know whether the runtime turns it on with this card and driver. The comment above reports native16=true on an RX 7800 XT.

Setup: a world frame recorded on 4eb6cfd (1,024 pipelines). 1,162 of its 1,183 title shaders translate on every build (--view-limit 2097151 --raw-views 2097152). The other 21 containers were not found and keep the recorded shaders. Then replay --compare --shaders <A> --shaders-b <B> --loops 11 in both orders, on 4eb6cfd plus the replay fix in #550.

Measured:

  • Switch off (native half off, as in the PR's own --retranslate): the folder is byte-identical to base's. 1,162 files, same sha256sum * | sha256sum.
  • Switch on: 17 of the 1,162 shaders differ (CS 15, PS 2). All 17 carry the native 16-bit feature flag in SFI0, and no base file does. 14 are smaller, 2 larger, 1 the same size.
  • With either folder the report says 994 of 1024 pipelines made with shaders of the folder given, 0 refused. By the replay code every file in the folder belongs to at least one recorded pipeline and all pipelines are made at load, so this driver made pipelines from the 17 native-half shaders.
  • Card time per frame, median of 11 loops, base / #502: 17.88 / 17.85 ms with base first (--timing detailed), 17.46 / 17.42 ms with #502 first. Loops after each run's first span 17.28-18.07 ms. A control (recorded shaders against base-retranslated) gives 17.44 / 17.41 ms. No difference I can measure.
  • Picture, PSNR against the presented frame per loop: 57.2-57.7 dB for base, 57.2-57.8 dB for #502. The first loop of each run is the exception (66.0 dB base, 65.1 dB #502).

Limits:

  • None of the 17 is in the 16 title pipelines among the report's 20 costliest (5-6 of those 16 use one of the 21 not found). I did not check that this frame runs any of the 17. This shows the driver takes them and the picture stays within the replay's spread. It is not a cost number for native half.
  • One frame, one scene, one card.

A question: should replay --retranslate set native16 from the card as the runtime does, or take a flag for it as #388 proposes for the wave size and RDNA? As it is, a folder retranslated with this PR cannot show the PR's change.

**@⁠adrianmjim** on GitHub · 2026-11-27 11:11 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502#issuecomment-7216791995) Data from one real frame on a discrete RDNA 3 card. RX 7900 XT, driver 32.0.32029.2010, Windows 11 26300, `diag` profile. PR head 37b25cc against a-publier 4eb6cfd. A disclosure first. I used `victory replay --retranslate` on a recorded frame, and that path never turns native half on. The PR calls `set_host_native16` at device creation in victory-gpu and in `victory translate`, not in [`retranslate`](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/apps/victory/src/replay.rs#L468-L471), so there it translates in f32. To get native-half shaders I added a local env switch (six lines, not in the PR) that calls `emit::set_host_native16(true)` next to `set_host_rdna(true)` there. That forces the path and does not ask the card. I did not run `Host::native16` on this card, the PR's GPU tests, or the game with this PR, so I do not know whether the runtime turns it on with this card and driver. The comment above reports `native16=true` on an RX 7800 XT. Setup: a world frame recorded on 4eb6cfd (1,024 pipelines). 1,162 of its 1,183 title shaders translate on every build (`--view-limit 2097151 --raw-views 2097152`). The other 21 containers were not found and keep the recorded shaders. Then `replay --compare --shaders <A> --shaders-b <B> --loops 11` in both orders, on 4eb6cfd plus the replay fix in #550. Measured: - Switch off (native half off, as in the PR's own `--retranslate`): the folder is byte-identical to base's. 1,162 files, same `sha256sum * | sha256sum`. - Switch on: 17 of the 1,162 shaders differ (CS 15, PS 2). All 17 carry the native 16-bit feature flag in SFI0, and no base file does. 14 are smaller, 2 larger, 1 the same size. - With either folder the report says `994 of 1024 pipelines made with shaders of the folder given, 0 refused`. By the replay code every file in the folder belongs to at least one recorded pipeline and all pipelines are made at load, so this driver made pipelines from the 17 native-half shaders. - Card time per frame, median of 11 loops, base / #502: 17.88 / 17.85 ms with base first (`--timing detailed`), 17.46 / 17.42 ms with #502 first. Loops after each run's first span 17.28-18.07 ms. A control (recorded shaders against base-retranslated) gives 17.44 / 17.41 ms. No difference I can measure. - Picture, PSNR against the presented frame per loop: 57.2-57.7 dB for base, 57.2-57.8 dB for #502. The first loop of each run is the exception (66.0 dB base, 65.1 dB #502). Limits: - None of the 17 is in the 16 title pipelines among the report's 20 costliest (5-6 of those 16 use one of the 21 not found). I did not check that this frame runs any of the 17. This shows the driver takes them and the picture stays within the replay's spread. It is not a cost number for native half. - One frame, one scene, one card. A question: should `replay --retranslate` set native16 from the card as the runtime does, or take a flag for it as #388 proposes for the wave size and RDNA? As it is, a folder retranslated with this PR cannot show the PR's change.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 11:40 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 37b25cc: victory-gpu 396 passed, 0 failed, 34 ignored; victory-shader 308 passed, 0 failed, 4 ignored; victory bins 25 passed.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 11:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502#issuecomment-7217350598) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `37b25cc`: `victory-gpu` 396 passed, 0 failed, 34 ignored; `victory-shader` 308 passed, 0 failed, 4 ignored; `victory` bins 25 passed. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 13:26 UTC · original · reviewed

AI-assisted review: I focused on the new native-half bitcode path and the validator limitation noted in the PR description.

**@⁠gut0to** on GitHub · 2026-11-27 13:26 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502#pullrequestreview-6088861930) · **reviewed** AI-assisted review: I focused on the new native-half bitcode path and the validator limitation noted in the PR description.
@ -610,2 +619,4 @@
// Native 16-bit types are laid out in 16 bits, minimum precision in
// 32 (the validator wants the layout that matches the flags).
w.record(
3,
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 13:26 UTC · original

Could we add a bitcode-level regression test for both values of native16 that inspects the emitted data-layout string (and confirms the default layout remains byte-for-byte unchanged)? The PR notes that the available DXIL validator does not check this layout, and this is the core ABI change for native half types.

**@⁠gut0to** on GitHub · 2026-11-27 13:26 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502#discussion_r4719951436) Could we add a bitcode-level regression test for both values of `native16` that inspects the emitted data-layout string (and confirms the default layout remains byte-for-byte unchanged)? The PR notes that the available DXIL validator does not check this layout, and this is the core ABI change for native `half` types.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 15:15 UTC · original

Checked on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release (native half supported), at the PR head: a hardware test builds each case twice, once on the f32 path and once with native half, runs both on the card, and compares them bit for bit and against an exact console model (one rounding to nearest even, denormals kept). 1,412 input triples per run: all pairs of 30 edge values (±0, denormals, smallest normal, 1±ulp, 65504, ±inf, quiet/signalling/negative NaN), random triples, and hand-picked ties and overflow/underflow cases.

Ops: v_add/sub/subrev/mul/max/min_f16, v_fma_f16, v_max3/min3/med3_f16, v_fmac_f16, the v_pk_* forms, v_cvt_f16_f32 and v_cvt_f32_f16, with neg/abs/clamp/omod, op_sel (including writing the high half) and SDWA word selects.

  • Native half against the console model: 0 mismatches in every modelled case (denormal results, overflow, ties, high half, SDWA, packed halves, and the PR's own FMA case).
  • min/max/min3/max3/med3, omod and the conversions are identical to the f32 path. The only differences are NaN payloads.
  • Add, sub, mul, FMA, fmac and packed forms differ from the f32 path in 42 to 574 of 1,412 cases per run, and every case I checked is the f32 path being one ulp low (AMD's legacyF32ToF16 rounds toward zero, and FMA there rounds twice). Example: v_add_f16 0x0001 + 0xBC00 gives 0xBBFF on f32, 0xBC00 native and in the model. With clamp, no case differed by more than one ulp across 25 runs. So the PR moves results only toward the console's.

Things to know: the key of every shader changes on native-16 hosts (translation_fingerprint, shader_cache.rs), so the whole cache is translated again once after merge; and device creation now runs one compute dispatch as a probe (host.rs ~1057-1063), keeping the f32 path if it fails. The MODE register is not modelled, so a program that switches to round-toward-zero still gets nearest even (the PR documents it).

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 15:15 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/502#issuecomment-7221837159) Checked on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release (native half supported), at the PR head: a hardware test builds each case twice, once on the f32 path and once with native half, runs both on the card, and compares them bit for bit and against an exact console model (one rounding to nearest even, denormals kept). 1,412 input triples per run: all pairs of 30 edge values (±0, denormals, smallest normal, 1±ulp, 65504, ±inf, quiet/signalling/negative NaN), random triples, and hand-picked ties and overflow/underflow cases. Ops: `v_add/sub/subrev/mul/max/min_f16`, `v_fma_f16`, `v_max3/min3/med3_f16`, `v_fmac_f16`, the `v_pk_*` forms, `v_cvt_f16_f32` and `v_cvt_f32_f16`, with neg/abs/clamp/omod, op_sel (including writing the high half) and SDWA word selects. - **Native half against the console model: 0 mismatches** in every modelled case (denormal results, overflow, ties, high half, SDWA, packed halves, and the PR's own FMA case). - min/max/min3/max3/med3, omod and the conversions are identical to the f32 path. The only differences are NaN payloads. - Add, sub, mul, FMA, fmac and packed forms differ from the f32 path in 42 to 574 of 1,412 cases per run, and every case I checked is the f32 path being **one ulp low** (AMD's `legacyF32ToF16` rounds toward zero, and FMA there rounds twice). Example: `v_add_f16 0x0001 + 0xBC00` gives `0xBBFF` on f32, `0xBC00` native and in the model. With clamp, no case differed by more than one ulp across 25 runs. So the PR moves results only toward the console's. Things to know: the key of every shader changes on native-16 hosts (`translation_fingerprint`, `shader_cache.rs`), so the whole cache is translated again once after merge; and device creation now runs one compute dispatch as a probe (`host.rs` ~1057-1063), keeping the f32 path if it fails. The MODE register is not modelled, so a program that switches to round-toward-zero still gets nearest even (the PR documents it). AI-assisted (Claude Code); no game data.
This pull request can be merged automatically.
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/502/head:github-bot/gh-502'
git switch 'github-bot/gh-502'

Merge

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