Shaders: honor modifiers in f16 conversions #1545

Closed
github-bot wants to merge 1 commit from gh-pr/1545/head into gh-pr/1545/base
Owner

@⁠Calvix2k on GitHub · 2026-11-24 19:01 UTC · original
Calvix2k:codex/shader-cvt-modifiers-028 → main · +41 −5 · 2 files · 1 commits · closed without merging

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.

**@⁠Calvix2k** on GitHub · 2026-11-24 19:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1545) `Calvix2k:codex/shader-cvt-modifiers-028` → `main` · +41 −5 · 2 files · 1 commits · closed without merging ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:35:50 +00:00
github-bot closed this pull request 2026-11-26 04:35:50 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 19:33 UTC · original

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).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 19:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7142274264) ### 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).
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 19:34 UTC · original

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 19:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7142295588) 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.*
Author
Owner

@⁠tdogghockey on GitHub · 2026-11-24 19:37 UTC · original

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.

**@⁠tdogghockey** on GitHub · 2026-11-24 19:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7142372197) 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.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 22:01 UTC · original

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** on GitHub · 2026-11-24 22:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7145694940) 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.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 22:01 UTC · original

Closing as superseded by upstream 77053a0.

**@⁠Calvix2k** on GitHub · 2026-11-24 22:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1545#issuecomment-7145695435) Closing as superseded by upstream 77053a0.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1545
No description provided.