Shaders: honor modifiers in f16 conversions #1544

Closed
Calvix2k wants to merge 1 commit from upstream-pr/1545 into main
Calvix2k commented 2026-11-24 19:01:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T19:01:34Z.


Summary

Fixes modifier handling in the opsel == 0 fast paths for two 16-bit conversion instructions:

  • v_cvt_f32_f16 now uses the existing half-float source path, preserving VOP3 abs and neg semantics.
  • v_cvt_f16_f32 applies VOP3 clamp before converting the f32 value to f16.
  • Adds focused synthetic shader regressions for both cases.

Verification

  • Focused regression tests compile and lower their shaders successfully. Runtime execution was skipped because this Windows system exposes neither an SM 6.6 hardware device nor an SM 6.6 WARP device.
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: passed.
  • cargo xtask policy: passed (154 files ok).
  • rustfmt --edition 2024 --check on valu_tests.rs: passed. lower.rs has pre-existing formatting differences elsewhere in the file.
  • Full cargo test -p victory-shader --locked -- --test-threads=1: 107 passed, 1 ignored, 15 failed because existing GPU tests require an available SM 6.6 hardware/WARP device, which this system lacks.

Synthetic tests only; no game assets used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6589231648 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T19:01:34Z. --- ## Summary Fixes modifier handling in the `opsel == 0` fast paths for two 16-bit conversion instructions: - `v_cvt_f32_f16` now uses the existing half-float source path, preserving VOP3 `abs` and `neg` semantics. - `v_cvt_f16_f32` applies VOP3 `clamp` before converting the f32 value to f16. - Adds focused synthetic shader regressions for both cases. ## Verification - Focused regression tests compile and lower their shaders successfully. Runtime execution was skipped because this Windows system exposes neither an SM 6.6 hardware device nor an SM 6.6 WARP device. - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings`: passed. - `cargo xtask policy`: passed (`154 files ok`). - `rustfmt --edition 2024 --check` on `valu_tests.rs`: passed. `lower.rs` has pre-existing formatting differences elsewhere in the file. - Full `cargo test -p victory-shader --locked -- --test-threads=1`: 107 passed, 1 ignored, 15 failed because existing GPU tests require an available SM 6.6 hardware/WARP device, which this system lacks. Synthetic tests only; no game assets used.
catminou4 commented 2026-11-24 20:02:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:20:53Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96. Execution/valu tests are #[cfg(all(test, windows))] and were not run here.

f16 conversions honor VOP3 modifiers: v_cvt_f16_f32 applies CLAMP to the f32 source before legacyF32ToF32→F16 conversion, and v_cvt_f32_f16 goes through half_fsrc so ABS/NEG on the f16 source work. Two valu tests pin clamp-before-convert (high half preserved: 0xbeef_1234 → 0xbeef_0000) and abs-then-neg (0x3c00 → 0xbf80). Windows-only execution; 96 passed on macOS.

<!-- greyfinch-sync:Marvisak/VIctory:review:6045810509 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545#pullrequestreview-6045810509). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T19:20:53Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), `cargo test -p victory-shader --locked` → 96. Execution/valu tests are `#[cfg(all(test, windows))]` and were not run here. f16 conversions honor VOP3 modifiers: `v_cvt_f16_f32` applies CLAMP to the f32 source before `legacyF32ToF32`→F16 conversion, and `v_cvt_f32_f16` goes through `half_fsrc` so ABS/NEG on the f16 source work. Two valu tests pin clamp-before-convert (high half preserved: 0xbeef_1234 → 0xbeef_0000) and abs-then-neg (0x3c00 → 0xbf80). Windows-only execution; 96 passed on macOS.
sinan-cmyk commented 2026-11-24 20:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T19:33:44Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count changes against main, and the tests pass on Ada.

Offline. I merged head f3d0ab9 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost. No program changes its failure reason either.

This is the expected result for a correctness fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests. With the same merge, cargo test --locked -p victory-shader --lib passed 122, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142274264 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7142274264). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T19:33:44Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count changes against `main`, and the tests pass on Ada.** **Offline.** I merged head f3d0ab9 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost. No program changes its failure reason either. This is the expected result for a correctness fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests.** With the same merge, `cargo test --locked -p victory-shader --lib` passed 122, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
geiyiliyabumo commented 2026-11-24 20:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T19:34:38Z.


Verified commit f3d0ab9 on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, gfx1200, SM 6.6) + WARP:

  • cargo test -p victory-shader --lib: 122 passed, 0 failed, 1 ignored (including the new f16 conversion modifier GPU tests).

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142295588 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7142295588). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T19:34:38Z. --- Verified commit `f3d0ab9` on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, `gfx1200`, SM 6.6)** + **WARP**: - `cargo test -p victory-shader --lib`: **122 passed, 0 failed, 1 ignored** (including the new f16 conversion modifier GPU tests). *AI-assisted; synthetic tests only, no game files.*
tdogghockey commented 2026-11-24 20:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tdogghockey on 2026-11-24T19:37:57Z.


I independently checked this at head f3d0ab9 on aarch64 Linux.

  • cargo test --offline -p victory-shader --locked — 96 passed, 0 failed, 1 ignored.
  • cargo check --offline -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc — clean.
  • cargo clippy --offline -p victory-shader --all-targets --locked -- -D warnings reports the same two pre-existing unused-import errors in emit/mod.rs on base ffe310e, so I don't attribute them to this PR.
  • rustfmt --check on lower.rs reports the same three pre-existing diff hunks as base.

Source check: the v_cvt_f32_f16 fast path now goes through half_fsrc, which applies abs then neg after legacyF16ToF32, and the v_cvt_f16_f32 fast path clamps before narrowing. That matches the stated VOP3 semantics. The new tests live in #[cfg(all(test, windows))] emit::valu_tests, so they could not execute on this Linux host; Windows-target compilation only is confirmed here.

No correctness issue found in the verifiable surface. No approval implied.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142372197 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7142372197). Originally posted by [tdogghockey](https://github.com/tdogghockey) on 2026-11-24T19:37:57Z. --- I independently checked this at head `f3d0ab9` on aarch64 Linux. - `cargo test --offline -p victory-shader --locked` — 96 passed, 0 failed, 1 ignored. - `cargo check --offline -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc` — clean. - `cargo clippy --offline -p victory-shader --all-targets --locked -- -D warnings` reports the same two pre-existing unused-import errors in `emit/mod.rs` on base `ffe310e`, so I don't attribute them to this PR. - `rustfmt --check` on `lower.rs` reports the same three pre-existing diff hunks as base. Source check: the `v_cvt_f32_f16` fast path now goes through `half_fsrc`, which applies abs then neg after `legacyF16ToF32`, and the `v_cvt_f16_f32` fast path clamps before narrowing. That matches the stated VOP3 semantics. The new tests live in `#[cfg(all(test, windows))] emit::valu_tests`, so they could not execute on this Linux host; Windows-target compilation only is confirmed here. No correctness issue found in the verifiable surface. No approval implied.
Calvix2k commented 2026-11-24 22:02:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T22:01:15Z.


Superseded by upstream 77053a0: the opsel == 0 path for v_cvt_f32_f16 now reads through the half-float source path (abs/neg preserved), and the 16-bit float result path applies clamp before the single narrow16 conversion. Both regressions this PR adds are covered upstream; closing to avoid a duplicate conflict. Thanks for the targeted cases.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145694940 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7145694940). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T22:01:15Z. --- Superseded by upstream 77053a0: the opsel == 0 path for `v_cvt_f32_f16` now reads through the half-float source path (abs/neg preserved), and the 16-bit float result path applies `clamp` before the single `narrow16` conversion. Both regressions this PR adds are covered upstream; closing to avoid a duplicate conflict. Thanks for the targeted cases.
Calvix2k commented 2026-11-24 22:02:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T22:01:16Z.


Closing as superseded by upstream 77053a0.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145695435 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7145695435). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T22:01:16Z. --- Closing as superseded by upstream 77053a0.
upstream-sync closed this pull request 2026-11-24 23:04:43 +00:00

Pull request closed

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
Marvisak/VIctory!1544
No description provided.