Shaders: honor directed rounding in v_mul_f16 #3804
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3804"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T23:06:04Z.
v_mul_f16now uses the active half-precision rounding mode for modes 1 and 2. A product of two finite binary16 values fits exactly in f32. Start with the existing truncation, widen that half, and step one half encoding outward when the comparison shows truncation landed on the wrong side. AMD documents that the instruction honors the rounding mode. RDNA 2 ISA, sections 6.4 and 12.7The synthetic test compares 529 pairs in each of the four modes against the CPU reference, with signed zeros, subnormals, overflow, infinities and NaNs. On
63bcca4, each WARP invocation had 65 mismatches in mode 1 and 58 in mode 2. The proposed build matched all 4,232 readbacks across both software-device invocations. The existing FP16 rounding and arithmetic tests and all 33 lowerer tests passed. Both strict shader Clippy configurations and the asset policy passed.Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T23:11:37Z.
Windows CI passed on
386cc0f, including both Clippy configurations and workspace tests. In the signed WARP comparison, the 529 pairs matched in each of the four rounding modes on both software invocations. Main differed on 65 pairs in mode 1 and 58 pairs in mode 2 per invocation.The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T23:22:23Z.
The exact heads of #3803 (
fda9900) and #3804 (386cc0f) conflict in the FP16 narrowing code and where the two regression tests are added. I resolved both conflicts in9248dba. It keeps both tests and uses the same directed narrowing for conversion and multiply in modes 1 and 2. The helper preserves the existing signed-zero flush for FP32 subnormals. A nonzero product of two finite FP16 values is normal in FP32, so that rule does not flush a multiply result.63bcca4with both tests, per WARP invocation9248dba, both WARP invocationsv_cvt_f16_f32modes 1 and 2v_mul_f16modes 0–3WARP 1.0.22 with Agility 1.620.2. The existing mode 0 and 3 conversion test, the nearest-even and single-rounding tests, and all 33 lowerer tests also passed. Strict shader Clippy passed with default and all features. Asset policy passed for 191 files (
lower.rsis 522,296 bytes). These combined results are from the software adapter.Both original heads remain parents of the comparison branch. Please retain the Git authors on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding my changes into another commit. Comparison branchAI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-28T23:37:46Z.
Hardware run on AMD: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head
386cc0fccon63bcca4. The fixture runs the hardware adapter and WARP in turn, and neither was skipped.f16_multiply_honors_round_mode: pass.MODEround field value 0-3), 2,116 inputs in all. No case had a mismatch against the model on either adapter, and hardware and WARP agreed on every input. Examples:s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), lit(0x00000000); v_mul_f16 v5, v1, v2s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), lit(0x00000001); v_mul_f16 v5, v1, v2s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), lit(0x00000002); v_mul_f16 v5, v1, v2s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), lit(0x00000003); v_mul_f16 v5, v1, v2victory-shader --lib --features host: 303 passed; 0 failed; 3 ignored.AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T23:39:28Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
386cc0fcc55351a2d8722f0a0ceef7c20423d185, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::semantics_tests::f16_multiply_honors_round_mode --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the new test name on the parent returned no match (test is new on this PR);git diff --check HEAD^ HEADclean (2 files, +57/-2).CARGO_TARGET_DIR(target-3804-watch, never shared) withCARGO_BUILD_JOBS=2.AI-assisted (Hy4 flash).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.