Shaders: f16 results flush output denormals when MODE says so #3365

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

@⁠Lyrnc on GitHub · 2026-11-26 20:36 UTC · original
Lyrnc:fix/f16-output-denorm-flush → main · +338 −5 · 3 files · 1 commits · open

What was wrong

With MODE bit 7 clear (bit 3 of s_denorm_mode's immediate, or s_setreg of the bit), RDNA2 flushes f16 output denormals. An f16 result that is below the smallest normal half, once rounded to a half's precision as if the exponent had no bottom, becomes a zero of its sign. The translator ignores s_denorm_mode and always keeps the subnormal.

Measured on gfx1036 with s_denorm_mode 4 (16-bit input denormals kept, output denormals flushed). s_denorm_mode 0 gives the same results for these f32-source cases.

instruction, input denormals kept (gfx1036 = main) flushed, gfx1036 flushed, main
v_cvt_f16_f32 0x33800000 (2^-24), any round mode 0x0001 0x0000 0x0001
v_cvt_f16_f32 0xb3800000 0x8001 0x8000 0x8001
v_cvt_f16_f32 0x387fe000 (2^-14 - 2^-25), nearest even 0x0400 0x0000 0x0400
v_cvt_f16_f32 0x387ff000 (2^-14 - 2^-26), nearest even 0x0400 0x0400 0x0400
v_cvt_f16_f32 0x387ff000, toward zero 0x03ff 0x0000 0x03ff
v_mul_f16 0x3c01 × 0x8001 0x8001 0x8000 0x8001
v_max_f16 0x0001, 0x8003 0x0001 0x0001 0x0001

The third and fourth rows show the rule. 0x387fe000 has 11 significant bits below 2^-14, so it flushes, even though rounding it onto the subnormal grid would give the smallest normal. 0x387ff000 rounds up to 2^-14 at a half's precision, so it is not flushed.

The same holds on gfx1036 for:

  • v_add_f16, v_sub_f16, v_mul_f16, v_fma_f16, v_fmac_f16, v_fract_f16 and v_rcp_f16;
  • v_pk_add_f16, v_pk_mul_f16 and v_pk_fma_f16, per half;
  • v_fma_mixlo_f16 and v_cvt_pkrtz_f16_f32. The latter always rounds toward zero, so its limit is 2^-14.

An exact model matches every measured result of the ten operations whose result is one rounding of an exact value: v_cvt_f16_f32, v_fma_mixlo_f16 of x × 1 + 0, v_add/sub/mul/fma/fmac_f16 and the packed add/mul/fma. That is 44,808 of 44,808 results, in all 12 MODE settings below. The model:

  • reads subnormal f16 inputs as zeros of their sign when MODE bit 6 is clear;
  • rounds the exact value once to f16 in the round mode;
  • applies the flush above when MODE bit 7 is clear;
  • signs exact zeros as IEEE does.

v_max_f16, v_min_f16, v_med3_f16 and v_pk_max_f16 do not flush their result: a subnormal operand comes out as it went in.

s_setreg_imm32_b32 hwreg(HW_REG_MODE, 7, 1) sets the same bit. Writing 0 after s_denorm_mode 12 flushes, and writing 1 after s_denorm_mode 0 keeps denormals.

What changed

  • The block-entry analysis that round16 does for the round mode becomes mode_at_blocks. It is the same function #3166 adds, with the same text. denorm16 uses it to follow MODE bit 7. The bit starts as kept, the console's float mode. s_denorm_mode and s_setreg with a constant write it. An s_setreg from an SGPR, or paths that disagree at a join, make it unknown, and an unknown bit keeps denormals as before.
  • flush16(h, f, mode) turns a result h, narrowed from f, into a zero of its sign when the bit is clear and |f| is below the limit for the round mode: 0x387ff000 for nearest even (or an unknown mode), 0x38800000 toward zero, and 0x387fe001 for the direction that rounds the magnitude up. It runs at these places:
    • the f16 results of valu16 except min/max/med3;
    • the packed add/mul/fma;
    • v_fma_mix{lo,hi}_f16;
    • v_cvt_pkrtz_f16_f32, in toward-zero mode.
  • The single-rounding v_fma_f16 path decides on the exact sum, the f32 sum and its TwoSum error.
  • narrow16 itself is unchanged.
  • The new analysis and helpers are in emit/lower/denorm16.rs, because lower.rs would otherwise pass the asset policy's 512 KiB file limit. lower.rs is now 521,855 bytes.

Tests

  • New test valu_tests::f16_results_flush_output_denormals_as_the_mode_says, with rows measured on gfx1036:
    • v_cvt_f16_f32 with s_denorm_mode 12, 4 and 0, in nearest-even and toward-zero mode, 12 inputs;
    • v_add_f16, v_mul_f16, v_fma_f16, v_fract_f16, v_pk_mul_f16, v_fma_mixlo_f16 and v_cvt_pkrtz_f16_f32 with s_denorm_mode 4;
    • v_max_f16 and v_min_f16 as controls that keep subnormals;
    • the s_setreg MODE[7] write both ways.
  • Results:
    • Radeon gfx1036: passes, and fails on main (s_denorm_mode 4, round 0, 0x33800000).
    • RTX 5080 (610.88): passes, and fails on main.
    • WARP runs in the same test through run_cases.
  • cargo test -p victory-shader --lib, lib tests (cargo test -p victory-shader --lib -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index; that test crashes the process on main too): 297 passed, 5 failed, 3 ignored. main 63bcca4 on this machine: 296 passed and the same 5 failed (rect::tests::rectangles_get_their_fourth_corner, stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware, tests::elements_sharing_a_row_keep_their_order).
  • cargo clippy -p victory-shader --lib --tests -- -D warnings: clean.
  • cargo xtask policy: ok (192 files). The new code is in lower/denorm16.rs, because adding it to lower.rs takes that file past the policy's 524,288-byte limit.

Hardware comparison

A probe runs the same instruction words on the gfx1036 hw oracle and through the translator (a local copy of the build_valu_cs harness, run on the Radeon). It covers 22 f16-producing operations, 96 to 110 rows of 3 results each, in 12 MODE settings: s_denorm_mode 12 and 0 in all four round modes, and 4 and 8 in nearest-even and toward-zero mode. The table counts results that differ from the hardware. NaNs with another payload count as equal.

results main this PR
s_denorm_mode 4 (outputs flushed, inputs kept), nearest even, the 13 flushing ops: 3,870 814 4
s_denorm_mode 4, toward zero, the same ops: 3,870 946 172
s_denorm_mode 0, f32-source ops (v_cvt_f16_f32, v_fma_mixlo_f16, v_cvt_pkrtz_f16_f32), nearest even and toward zero: 1,980 502 8
s_denorm_mode 4, v_max/min/med3_f16, v_pk_max_f16: 2,304 0 0
denormals kept (s_denorm_mode 12), all ops and round modes: 25,848 3,036 3,036 (unchanged)

All differences left in the s_denorm_mode 4 rows are also there with denormals kept, so none of them is a flush. They are:

  • the 4 v_fma_mixlo_f16 zeros of f32-denormal or −0 sources, where main gives −0 and gfx1036 gives +0, in every mode;
  • the toward-zero arithmetic that main does not round exactly: v_rcp_f16 90, v_fma_f16/v_fmac_f16 34, v_pk_fma_f16 33, v_sub_f16 5, v_add_f16 2, v_pk_add_f16 4.

The RTX 5080 (610.88) ran the same probe for v_cvt_f16_f32, v_add_f16, v_mul_f16, v_fma_f16, v_pk_mul_f16, v_fma_mixlo_f16, v_cvt_pkrtz_f16_f32 and the s_setreg cases. Every case gives the same count as on the Radeon, on main and with this PR.

What this does not change

  • Input denormals (MODE bit 6). With bit 6 clear (s_denorm_mode 0, 8, 3), gfx1036 also reads subnormal f16 sources as zeros. This affects the arithmetic, min/max/med3, v_floor/ceil_f16, v_sqrt/rcp_f16 and v_cvt_f32_f16. For example, v_cvt_f32_f16 of 0x0001 gives 0 and v_floor_f16 of 0x8001 gives -0. This PR does not model that. Under s_denorm_mode 0, results with subnormal inputs still differ: 4,947 of 25,848 here, down from 7,722. #3166 does it for v_cvt_norm_*16_f16, and a general input flush could follow the same analysis.
  • Directed rounding (round modes 1 and 2) of the arithmetic. Main still rounds it to nearest even. v_cvt_f16_f32 is #3159. With #3159 merged onto this PR, v_cvt_f16_f32 matches gfx1036 on all 3,960 results in the 12 MODE settings; main has 936 differences there. That works because flush16 uses the limit of the round mode, so it agrees with #3159's directed narrowing.
  • Output modifiers: the RDNA2 ISA says output modifiers are ignored only when output denormals are kept, which is what #2915 relies on. With bit 7 clear they would apply. That is left to #2915.
  • #3159: one conflict in float_result. The resolution is narrow16_in_mode for v_cvt_f16_f32, then flush16. With that resolution the combined result is the one above.
  • #3166: conflicts in the Lower fields and initialiser only. mode_at_blocks is identical.
  • #2891 / #2884: small conflicts in round16 / the run loop and in the packed fallback.
  • #2917, #2886 and #2782 merge cleanly.

Not tested

  • No title run. I don't know whether the title writes MODE bit 7.
  • v_interp_p2_f16 and the 16-bit input narrowing in interp: not measured, and left unchanged.
  • v_exp_f16, v_log_f16, v_sin/cos_f16, v_max3/min3_f16: no subnormal results in the probe. They follow the arithmetic and the min/max rule respectively, which is an assumption.
  • f64 results (MODE bit 7 is also the f64 output bit).
  • Instructions inside whole-wave sections do not update the tracked bit, the same as the round mode on main (see #2886).

AI use

Claude Code (Claude Opus 5.5) wrote the probes, the model, the fix and the test, and ran them on the GPUs above. The numbers come from those runs. No game data was used.

🤖 Generated with Claude Code

**@⁠Lyrnc** on GitHub · 2026-11-26 20:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/3365) `Lyrnc:fix/f16-output-denorm-flush` → `main` · +338 −5 · 3 files · 1 commits · open ### What was wrong With MODE bit 7 clear (bit 3 of `s_denorm_mode`'s immediate, or `s_setreg` of the bit), RDNA2 flushes f16 output denormals. An f16 result that is below the smallest normal half, once rounded to a half's precision as if the exponent had no bottom, becomes a zero of its sign. The translator ignores `s_denorm_mode` and always keeps the subnormal. Measured on gfx1036 with `s_denorm_mode 4` (16-bit input denormals kept, output denormals flushed). `s_denorm_mode 0` gives the same results for these f32-source cases. | instruction, input | denormals kept (gfx1036 = main) | flushed, gfx1036 | flushed, main | |---|---|---|---| | `v_cvt_f16_f32` 0x33800000 (2^-24), any round mode | 0x0001 | **0x0000** | 0x0001 | | `v_cvt_f16_f32` 0xb3800000 | 0x8001 | **0x8000** | 0x8001 | | `v_cvt_f16_f32` 0x387fe000 (2^-14 - 2^-25), nearest even | 0x0400 | **0x0000** | 0x0400 | | `v_cvt_f16_f32` 0x387ff000 (2^-14 - 2^-26), nearest even | 0x0400 | 0x0400 | 0x0400 | | `v_cvt_f16_f32` 0x387ff000, toward zero | 0x03ff | **0x0000** | 0x03ff | | `v_mul_f16` 0x3c01 × 0x8001 | 0x8001 | **0x8000** | 0x8001 | | `v_max_f16` 0x0001, 0x8003 | 0x0001 | 0x0001 | 0x0001 | The third and fourth rows show the rule. 0x387fe000 has 11 significant bits below 2^-14, so it flushes, even though rounding it onto the subnormal grid would give the smallest normal. 0x387ff000 rounds up to 2^-14 at a half's precision, so it is not flushed. The same holds on gfx1036 for: - `v_add_f16`, `v_sub_f16`, `v_mul_f16`, `v_fma_f16`, `v_fmac_f16`, `v_fract_f16` and `v_rcp_f16`; - `v_pk_add_f16`, `v_pk_mul_f16` and `v_pk_fma_f16`, per half; - `v_fma_mixlo_f16` and `v_cvt_pkrtz_f16_f32`. The latter always rounds toward zero, so its limit is 2^-14. An exact model matches every measured result of the ten operations whose result is one rounding of an exact value: `v_cvt_f16_f32`, `v_fma_mixlo_f16` of x × 1 + 0, `v_add/sub/mul/fma/fmac_f16` and the packed add/mul/fma. That is 44,808 of 44,808 results, in all 12 MODE settings below. The model: - reads subnormal f16 inputs as zeros of their sign when MODE bit 6 is clear; - rounds the exact value once to f16 in the round mode; - applies the flush above when MODE bit 7 is clear; - signs exact zeros as IEEE does. `v_max_f16`, `v_min_f16`, `v_med3_f16` and `v_pk_max_f16` do not flush their result: a subnormal operand comes out as it went in. `s_setreg_imm32_b32 hwreg(HW_REG_MODE, 7, 1)` sets the same bit. Writing 0 after `s_denorm_mode 12` flushes, and writing 1 after `s_denorm_mode 0` keeps denormals. ### What changed - The block-entry analysis that `round16` does for the round mode becomes `mode_at_blocks`. It is the same function #3166 adds, with the same text. `denorm16` uses it to follow MODE bit 7. The bit starts as kept, the console's float mode. `s_denorm_mode` and `s_setreg` with a constant write it. An `s_setreg` from an SGPR, or paths that disagree at a join, make it unknown, and an unknown bit keeps denormals as before. - `flush16(h, f, mode)` turns a result `h`, narrowed from `f`, into a zero of its sign when the bit is clear and `|f|` is below the limit for the round mode: 0x387ff000 for nearest even (or an unknown mode), 0x38800000 toward zero, and 0x387fe001 for the direction that rounds the magnitude up. It runs at these places: - the f16 results of `valu16` except min/max/med3; - the packed add/mul/fma; - `v_fma_mix{lo,hi}_f16`; - `v_cvt_pkrtz_f16_f32`, in toward-zero mode. - The single-rounding `v_fma_f16` path decides on the exact sum, the f32 sum and its TwoSum error. - `narrow16` itself is unchanged. - The new analysis and helpers are in `emit/lower/denorm16.rs`, because `lower.rs` would otherwise pass the asset policy's 512 KiB file limit. `lower.rs` is now 521,855 bytes. ### Tests - New test `valu_tests::f16_results_flush_output_denormals_as_the_mode_says`, with rows measured on gfx1036: - `v_cvt_f16_f32` with `s_denorm_mode` 12, 4 and 0, in nearest-even and toward-zero mode, 12 inputs; - `v_add_f16`, `v_mul_f16`, `v_fma_f16`, `v_fract_f16`, `v_pk_mul_f16`, `v_fma_mixlo_f16` and `v_cvt_pkrtz_f16_f32` with `s_denorm_mode 4`; - `v_max_f16` and `v_min_f16` as controls that keep subnormals; - the `s_setreg` MODE[7] write both ways. - Results: - Radeon gfx1036: passes, and fails on main (`s_denorm_mode 4, round 0, 0x33800000`). - RTX 5080 (610.88): passes, and fails on main. - WARP runs in the same test through `run_cases`. - `cargo test -p victory-shader --lib`, lib tests (`cargo test -p victory-shader --lib -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index`; that test crashes the process on main too): 297 passed, 5 failed, 3 ignored. main 63bcca4 on this machine: 296 passed and the same 5 failed (`rect::tests::rectangles_get_their_fourth_corner`, `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`, `tests::elements_sharing_a_row_keep_their_order`). - `cargo clippy -p victory-shader --lib --tests -- -D warnings`: clean. - `cargo xtask policy`: ok (192 files). The new code is in `lower/denorm16.rs`, because adding it to `lower.rs` takes that file past the policy's 524,288-byte limit. ### Hardware comparison A probe runs the same instruction words on the gfx1036 hw oracle and through the translator (a local copy of the `build_valu_cs` harness, run on the Radeon). It covers 22 f16-producing operations, 96 to 110 rows of 3 results each, in 12 MODE settings: `s_denorm_mode` 12 and 0 in all four round modes, and 4 and 8 in nearest-even and toward-zero mode. The table counts results that differ from the hardware. NaNs with another payload count as equal. | results | main | this PR | |---|---|---| | `s_denorm_mode 4` (outputs flushed, inputs kept), nearest even, the 13 flushing ops: 3,870 | 814 | **4** | | `s_denorm_mode 4`, toward zero, the same ops: 3,870 | 946 | **172** | | `s_denorm_mode 0`, f32-source ops (`v_cvt_f16_f32`, `v_fma_mixlo_f16`, `v_cvt_pkrtz_f16_f32`), nearest even and toward zero: 1,980 | 502 | **8** | | `s_denorm_mode 4`, `v_max/min/med3_f16`, `v_pk_max_f16`: 2,304 | 0 | 0 | | denormals kept (`s_denorm_mode 12`), all ops and round modes: 25,848 | 3,036 | 3,036 (unchanged) | All differences left in the `s_denorm_mode 4` rows are also there with denormals kept, so none of them is a flush. They are: - the 4 `v_fma_mixlo_f16` zeros of f32-denormal or −0 sources, where main gives −0 and gfx1036 gives +0, in every mode; - the toward-zero arithmetic that main does not round exactly: `v_rcp_f16` 90, `v_fma_f16`/`v_fmac_f16` 34, `v_pk_fma_f16` 33, `v_sub_f16` 5, `v_add_f16` 2, `v_pk_add_f16` 4. The RTX 5080 (610.88) ran the same probe for `v_cvt_f16_f32`, `v_add_f16`, `v_mul_f16`, `v_fma_f16`, `v_pk_mul_f16`, `v_fma_mixlo_f16`, `v_cvt_pkrtz_f16_f32` and the `s_setreg` cases. Every case gives the same count as on the Radeon, on main and with this PR. ### What this does not change - **Input denormals (MODE bit 6).** With bit 6 clear (`s_denorm_mode` 0, 8, 3), gfx1036 also reads subnormal f16 sources as zeros. This affects the arithmetic, min/max/med3, `v_floor/ceil_f16`, `v_sqrt/rcp_f16` and `v_cvt_f32_f16`. For example, `v_cvt_f32_f16` of 0x0001 gives 0 and `v_floor_f16` of 0x8001 gives -0. This PR does not model that. Under `s_denorm_mode 0`, results with subnormal inputs still differ: 4,947 of 25,848 here, down from 7,722. #3166 does it for `v_cvt_norm_*16_f16`, and a general input flush could follow the same analysis. - **Directed rounding** (round modes 1 and 2) of the arithmetic. Main still rounds it to nearest even. `v_cvt_f16_f32` is #3159. With #3159 merged onto this PR, `v_cvt_f16_f32` matches gfx1036 on all 3,960 results in the 12 MODE settings; main has 936 differences there. That works because `flush16` uses the limit of the round mode, so it agrees with #3159's directed narrowing. - **Output modifiers**: the RDNA2 ISA says output modifiers are ignored only when output denormals are kept, which is what #2915 relies on. With bit 7 clear they would apply. That is left to #2915. ### Merging with related PRs - #3159: one conflict in `float_result`. The resolution is `narrow16_in_mode` for `v_cvt_f16_f32`, then `flush16`. With that resolution the combined result is the one above. - #3166: conflicts in the `Lower` fields and initialiser only. `mode_at_blocks` is identical. - #2891 / #2884: small conflicts in `round16` / the run loop and in the packed fallback. - #2917, #2886 and #2782 merge cleanly. ### Not tested - No title run. I don't know whether the title writes MODE bit 7. - `v_interp_p2_f16` and the 16-bit input narrowing in `interp`: not measured, and left unchanged. - `v_exp_f16`, `v_log_f16`, `v_sin/cos_f16`, `v_max3/min3_f16`: no subnormal results in the probe. They follow the arithmetic and the min/max rule respectively, which is an assumption. - f64 results (MODE bit 7 is also the f64 output bit). - Instructions inside whole-wave sections do not update the tracked bit, the same as the round mode on main (see #2886). ### AI use Claude Code (Claude Opus 5.5) wrote the probes, the model, the fix and the test, and ran them on the GPUs above. The numbers come from those runs. No game data was used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With MODE bit 7 clear (s_denorm_mode bit 3, or an s_setreg of the
bit), RDNA2 gives a zero of its sign for an f16 result that is below
the smallest normal half once rounded to a half's precision; the
translator kept the subnormal. Measured on gfx1036: v_cvt_f16_f32 of
0x33800000 gives 0x0000, not 0x0001, in every round mode, and
0x387fe000 gives 0x0000 where denormals kept give 0x0400. The same
holds for v_add/sub/mul/fma/fmac/fract/rcp_f16, the packed add, mul
and fma, v_fma_mix and v_cvt_pkrtz_f16_f32; v_max/min/med3_f16 and
v_pk_max_f16 keep their results.

The lowerer now follows MODE bit 7 as it follows the round mode (the
block-entry analysis becomes mode_at_blocks, shared with round16), and
flush16 zeroes tiny results at those sites. The fused v_fma_f16 path
decides on the exact sum with its error. The new analysis and helpers
are in lower/denorm16.rs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:43:32 +00:00
Author
Owner

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

LGTM — denorm16_after, flush16, and flush16_exact cleanly model RDNA2 MODE[7] (s_denorm_mode bit 3 and HW_REG_MODE bit 7) output denormal flushing while preserving sign bits, NaN/Inf, and the v_min/v_max/v_med3/v_pk_min/v_pk_max exception, and moving the helpers into emit/lower/denorm16.rs keeps lower.rs within the size limit.

Verified

  • crates/victory-shader/src/emit/lower.rs size: 521,855 bytes (under the 524,288-byte limit).
  • cargo run --locked -p xtask -- policy: 192 files ok.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --all-features): clean.
  • rustfmt --edition 2024: clean on all PR-touched hunks and emit/lower/denorm16.rs.
  • emit::valu_tests::f16_results_flush_output_denormals_as_the_mode_says (RTX 5090 + WARP): passed; related f16 regression tests (v_fma_f16, f16_max_and_min, v_cvt_f16, packed_fmac, v_med3_f16): 5 passed, 0 failed; emit::lower: 33 passed, 0 failed.

Non-blocking scope notes (matching the PR's stated follow-ups)

  • flush16_exact (denorm16.rs:91) assumes RNE (mode16 != Some(3)), and directed rounding modes (1 | 2), intermediate f32 double rounding in v_fmac/v_pk_fma/v_fma_mix* / RTZ v_fma_f16, v_interp_p2_f16, whole-wave section writes, and SGPR/divergent MODE joins (None defaulting to keep) remain follow-ups.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3365#pullrequestreview-6080339375) · **approved these changes** LGTM — `denorm16_after`, `flush16`, and `flush16_exact` cleanly model RDNA2 `MODE[7]` (`s_denorm_mode` bit 3 and `HW_REG_MODE` bit 7) output denormal flushing while preserving sign bits, NaN/Inf, and the `v_min`/`v_max`/`v_med3`/`v_pk_min`/`v_pk_max` exception, and moving the helpers into `emit/lower/denorm16.rs` keeps `lower.rs` within the size limit. ### Verified - `crates/victory-shader/src/emit/lower.rs` size: **521,855 bytes** (under the 524,288-byte limit). - `cargo run --locked -p xtask -- policy`: `192 files ok`. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--all-features`): clean. - `rustfmt --edition 2024`: clean on all PR-touched hunks and `emit/lower/denorm16.rs`. - `emit::valu_tests::f16_results_flush_output_denormals_as_the_mode_says` (RTX 5090 + WARP): **passed**; related f16 regression tests (`v_fma_f16`, `f16_max_and_min`, `v_cvt_f16`, `packed_fmac`, `v_med3_f16`): **5 passed, 0 failed**; `emit::lower`: **33 passed, 0 failed**. ### Non-blocking scope notes (matching the PR's stated follow-ups) - `flush16_exact` (`denorm16.rs:91`) assumes RNE (`mode16 != Some(3)`), and directed rounding modes (`1 | 2`), intermediate f32 double rounding in `v_fmac`/`v_pk_fma`/`v_fma_mix*` / RTZ `v_fma_f16`, `v_interp_p2_f16`, whole-wave section writes, and SGPR/divergent `MODE` joins (`None` defaulting to keep) remain follow-ups.
Author
Owner

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

LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).

  • Flushing f16 output denormals according to the shader's MODE setting (cleanly factored into emit/lower/denorm16.rs) matches RDNA2 hardware behavior on both discrete NVIDIA hardware and WARP.
  • cargo test -p victory-shader --lib emit::valu_tests::f16_results_flush_output_denormals_as_the_mode_says -- --test-threads=1: passed on RTX 5090 and VICTORY_WARP=1.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 20:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3365#pullrequestreview-6080355879) · **approved these changes** LGTM — verified on RTX 5090 and `VICTORY_WARP=1` (Windows / D3D12) against `origin/main` (`63bcca4`). - Flushing f16 output denormals according to the shader's `MODE` setting (cleanly factored into `emit/lower/denorm16.rs`) matches RDNA2 hardware behavior on both discrete NVIDIA hardware and WARP. - `cargo test -p victory-shader --lib emit::valu_tests::f16_results_flush_output_denormals_as_the_mode_says -- --test-threads=1`: passed on RTX 5090 and `VICTORY_WARP=1`. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠evan-kolberg on GitHub · 2026-11-26 20:58 UTC · original

Independent M4 Pro pixel-stage result for Lyrnc’s #3365 lowering. On CrossOver 26.3 and D3DMetal 4.0 beta 3, Mac main bf99e728 differed from the gfx1036 output-mode oracle at 64/256 pixels. The same Mac base with 2c7372e’s production code matched 256/256. Exact #3365 change · Exact Mac base

The generated fragment shader used v_cvt_f16_f32 with nearest-even rounding and MODE immediates 12 and 4. In mode 4 the patch changed 0x8001 → 0x8000 for negative minimum subnormal and 0x0400 → 0x0000 for FP32 0x387fefff. One FP32 ULP higher (0x387ff000) stayed 0x0400. RGBA32F readback recorded the raw half word as an exact FP32 integer and echoed the original runtime FP32 input. The fixture adapted Capt-Speed’s pixel-shader builder and VastyViz’s fullscreen triangle. Capt-Speed’s builder · VastyViz’s triangle

Prepared and tested with Codex.

**@⁠evan-kolberg** on GitHub · 2026-11-26 20:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3365#issuecomment-7203257042) Independent M4 Pro pixel-stage result for Lyrnc’s #3365 lowering. On CrossOver 26.3 and D3DMetal 4.0 beta 3, Mac main `bf99e728` differed from the gfx1036 output-mode oracle at **64/256 pixels**. The same Mac base with `2c7372e`’s production code matched **256/256**. [Exact #3365 change](https://github.com/Lyrnc/VIctory/commit/2c7372e78d1e033dfe0ad8bc9a41e5a96787712d) · [Exact Mac base](https://github.com/pragyaangaur/VIctory-macOS/commit/bf99e728b2fa89c3550d51e07626c0da9bd6ec47) The generated fragment shader used `v_cvt_f16_f32` with nearest-even rounding and MODE immediates 12 and 4. In mode 4 the patch changed `0x8001 → 0x8000` for negative minimum subnormal and `0x0400 → 0x0000` for FP32 `0x387fefff`. One FP32 ULP higher (`0x387ff000`) stayed `0x0400`. RGBA32F readback recorded the raw half word as an exact FP32 integer and echoed the original runtime FP32 input. The fixture adapted Capt-Speed’s pixel-shader builder and VastyViz’s fullscreen triangle. [Capt-Speed’s builder](https://github.com/pragyaangaur/VIctory-macOS/commit/b51011aa6502ef349b63f71e7cf27c6f87a14200) · [VastyViz’s triangle](https://github.com/pragyaangaur/VIctory-macOS/commit/7ac1f54d83179d4d7656b39dee0a06917d139e2e) Prepared and tested with Codex.
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/3365/head:github-bot/gh-3365'
git switch 'github-bot/gh-3365'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3365'
git switch 'github-bot/gh-3365'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3365'
git switch 'github-bot/gh-3365'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3365'
git switch 'main'
git merge --squash 'github-bot/gh-3365'
git switch 'main'
git merge --ff-only 'github-bot/gh-3365'
git switch 'main'
git merge 'github-bot/gh-3365'
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!3365
No description provided.