Shaders: test the VOP3 modifiers of v_cvt_f16_f32 and v_cvt_f32_f16, and drop their unreachable arms #231

Open
murillojndem wants to merge 1 commit from upstream-pr/231 into main
murillojndem commented 2026-11-29 21:00:08 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-29T21:00:08Z.


Upstream's fc0c736 (Marvisak/VIctory#2159) fixed v_cvt_f16_f32 and v_cvt_f32_f16 dropping their VOP3 modifiers: the VALU lowering had arms for opsel == 0 that read the source without abs and neg and wrote the result without clamp and omod. This repository has the same two arms in emit/lower.rs, but they are not reached: valu_op hands both conversions to valu16 first, which applies their modifiers and op_sel, and returns. So the bug does not show here. A change of that order would bring it back unnoticed, since no test ran these conversions.

Change:

  • The two arms are removed (low_half, which another lowering uses, stays). Lowered shaders are unchanged, since the arms were not reached.
  • Two tests in emit::valu_tests run the VOP3 forms on the hardware adapter and on WARP:
    • v_cvt_f32_f16_applies_vop3_source_modifiers_to_the_half_it_widens: six f16 values, with another f16 in the high half, under no modifier, neg, abs, abs and neg, and neg with clamp; and op_sel picking the high half, with neg.
    • v_cvt_f16_f32_applies_omod_and_clamp_before_narrowing_and_keeps_the_high_half: six values with and without clamp, omod mul:2 before clamp, and a NaN (a NaN without clamp, 0 with it), each keeping the destination's high half.
      Clamp is checked as a median of the value, 0 and 1: NaN and -0 give +0, which is what the RX 7900 XT returned for -0 with clamp.

Tests:

  • Both tests pass on the RX 7900 XT and on WARP. With both conversions sent to the removed arms, as upstream had them before fc0c736, both fail.
  • victory-shader --lib: 239 passed, 2 failed, 4 ignored on the RX 7900 XT and WARP with one test thread. The two failures, emit::rect::tests::rectangles_are_drawn_whole and emit::rect::tests::the_rectangle_stage_is_a_geometry_shader, fail on main too.
  • Clippy with -D warnings, with and without --all-features, and cargo xtask policy pass.

Generated with Claude Code

<!-- greyfinch-sync:DexNom/VIctory:issue:5555065952 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/231). Originally posted by [murillojndem](https://github.com/murillojndem) on 2026-11-29T21:00:08Z. --- Upstream's fc0c736 (Marvisak/VIctory#2159) fixed `v_cvt_f16_f32` and `v_cvt_f32_f16` dropping their VOP3 modifiers: the VALU lowering had arms for `opsel == 0` that read the source without `abs` and `neg` and wrote the result without `clamp` and `omod`. This repository has the same two arms in `emit/lower.rs`, but they are not reached: `valu_op` hands both conversions to `valu16` first, which applies their modifiers and op_sel, and returns. So the bug does not show here. A change of that order would bring it back unnoticed, since no test ran these conversions. Change: - The two arms are removed (`low_half`, which another lowering uses, stays). Lowered shaders are unchanged, since the arms were not reached. - Two tests in `emit::valu_tests` run the VOP3 forms on the hardware adapter and on WARP: - `v_cvt_f32_f16_applies_vop3_source_modifiers_to_the_half_it_widens`: six f16 values, with another f16 in the high half, under no modifier, neg, abs, abs and neg, and neg with clamp; and op_sel picking the high half, with neg. - `v_cvt_f16_f32_applies_omod_and_clamp_before_narrowing_and_keeps_the_high_half`: six values with and without clamp, omod mul:2 before clamp, and a NaN (a NaN without clamp, 0 with it), each keeping the destination's high half. Clamp is checked as a median of the value, 0 and 1: NaN and -0 give +0, which is what the RX 7900 XT returned for -0 with clamp. Tests: - Both tests pass on the RX 7900 XT and on WARP. With both conversions sent to the removed arms, as upstream had them before fc0c736, both fail. - `victory-shader --lib`: 239 passed, 2 failed, 4 ignored on the RX 7900 XT and WARP with one test thread. The two failures, `emit::rect::tests::rectangles_are_drawn_whole` and `emit::rect::tests::the_rectangle_stage_is_a_geometry_shader`, fail on main too. - Clippy with `-D warnings`, with and without `--all-features`, and `cargo xtask policy` pass. Generated with [Claude Code](https://claude.com/claude-code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/231:upstream-pr/231'
git switch 'upstream-pr/231'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/231'
git switch 'upstream-pr/231'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/231'
git switch 'upstream-pr/231'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/231'
git switch 'main'
git merge --squash 'upstream-pr/231'
git switch 'main'
git merge --ff-only 'upstream-pr/231'
git switch 'main'
git merge 'upstream-pr/231'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
DexNom/VIctory!231
No description provided.