Shaders: honor directed rounding in v_cvt_f16_f32 #3803
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3803"
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-28T22:37:22Z.
The FP16 field of
FP_ROUNDselects rounding toward positive infinity in mode 1 and negative infinity in mode 2 (AMD RDNA2 ISA, section 6.4). On current main,v_cvt_f16_f32uses nearest-even for both modes. For example,0x3f800800(+1.000244140625) rounds to0x3c00in mode 1, where the next higher FP16 value is0x3c01.For this conversion, start with the existing truncation and step one half encoding outward when the finite input is inexact and the direction requires it. A bitwise comparison with the widened half handles underflow into the FP16 subnormal range and overflow to half infinity. The path retains the emitter's signed-zero handling for FP32 subnormals and the existing NaN encoding and high-half destination behavior.
Verification
63bcca4with only the new test applied, 26 of 50 signed inputs differed from the expected result in each of two WARP invocations.fda9900, all 200 readbacks match (50 signed inputs × 2 modes × 2 invocations on WARP 1.0.22 / Agility 1.620.2). The existing 38-input test for modes 0 and 3 also passes.Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7246795231
Please retain the Git author when cherry-picking or rebasing. If squashing into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted contribution.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T22:40:52Z.
Windows CI passed on
fda9900, including the workspace tests and both Clippy configurations.I also checked the directed conversion separately on WARP 1.0.22. With the regression test applied to
63bcca4, 26 of 50 signed inputs differed from the expected result in each of two invocations. Withfda9900, all 200 readbacks matched across modes 1 and 2. The existing 38-input test for modes 0 and 3 passed. A physical Radeon run is still pending.Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-28T23:37:47Z.
Hardware run on AMD: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head
fda990023on63bcca4. The fixture runs the hardware adapter and WARP in turn, and neither was skipped.f16_conversion_honors_both_directed_modes: pass.s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), lit(0x00000001); v_cvt_f16_f32 v5, v1; s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), lit(0x00000002); v_cvt_f16_f32 v6, v1victory-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-29T04:36:05Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
fda9900236892b9fbf3a616c28f120d753ebeeb6, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::semantics_tests::f16_conversion_honors_both_directed_modes --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the test name on the parent returned no match (exit 1; test is new on this PR);git diff --check HEAD^ HEADclean (2 files, +93/-2).CARGO_TARGET_DIR(target-3803-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.