Shaders: honor directed rounding in integer-to-FP16 conversions #3807
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3807"
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:45:40Z.
On main,
v_cvt_f16_u16andv_cvt_f16_i16round to nearest-even in modes 1 and 2. AMD documents rounding support for both instructions. For example, unsigned 2049 rounds to 2048 on main in mode 1, where the expected half value is 2050. AMD RDNA2 ISA, VOP1 instructions and section 6.4The source first widens to an exact FP32 integer. When the nearest half lands on the wrong side for the selected direction, step one half encoding toward that direction. The original exact-input test from #990 remains in place.
Verification
63bcca4, 35,584 input patterns had at least one mismatched output in each of modes 1 and 2 per WARP invocation. Modes 0 and 3 passed.afadaa9, all 1,048,576 readbacks matched across two invocations of WARP 1.0.22 with Agility 1.620.2, including both destination high-half sentinels.9248dbawas clean and leftlower.rsat 523,645 bytes. The runtime checks above are for this PR's standalone head. A physical GPU run is pending.Coordination claim
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:48:43Z.
Windows CI passed on
afadaa9, including the workspace tests and both Clippy configurations.The separate WARP 1.0.22 run covered all 65,536 16-bit input codes as both signed and unsigned operands in all four rounding modes. It matched all 1,048,576 readbacks across both software-device invocations. With the same test on
63bcca4, 35,584 input codes had a mismatch in each of modes 1 and 2 per invocation. Modes 0 and 3 passed on both builds. A physical GPU run is pending.Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T23:51:32Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
afadaa9b129e7ebafa81a5a7bfeb7ff01a4045e7, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::semantics_tests::f16_integer_conversions_honor_round_mode --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the test name on the base returned no match (test is new on this PR);git diff --check HEAD^ HEADclean (2 files, +61/-1).CARGO_TARGET_DIR(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.