Shaders: correctly round unsigned-to-float conversion on WARP #2184
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2186"
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 Razdva122 on 2026-11-25T07:18:52Z.
WARP can round a full-width unsigned integer conversion one ULP away from the console result. The examples from FIND-5 and #1602 both reproduce on the GitHub Windows runner. This addresses the unsigned-conversion part of FIND-5.
For
v_cvt_f32_u32, convert the high and low 16-bit halves separately, then computehi × 65536 + lo. Both halves and the scaled high half are exactly representable in f32. Only the addition rounds, including when the host fuses the multiply and add. This costs five DXIL operations in place of the unsigned cast. Other conversions keep their existing lowering.The existing conversion probe now compares exact result bits for 84 unsigned inputs, including the reported values and both sides of rounding midpoints. On the same runner, the previous lowering missed two WARP results and the new lowering passed. Both workspace Clippy configurations and the full workspace suite passed. In a separate CPU check, the split conversion matched an integer round-to-nearest-even oracle over all 2³² inputs. Windows comparison and test log
Related PR #1602 adds conversion coverage and documents the discrepancy. This PR changes the production instruction and uses a zero-tolerance regression for it. Physical GPU performance remains unmeasured.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T07:24:28Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib emit::semantics_tests::— 32 passed, 0 failed (1 ignored) on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean rounding fix for unsigned-to-float conversion on WARP, verified across both RTX 5090 and WARP. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T07:50:16Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
b21594a4ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T07:57:59Z.
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head
b21594a4intomain940d32fin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with--all-features: clean.cargo test --workspace --locked: 701 passed, 0 failed, 10 ignored, two runs (mainalone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:10:09Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Unsigned-to-float conversion correctly rounded on WARP... — cvt rounding fix; relates to #1326's fcmp WARP fix theme.
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-25T09:18:13Z.
Confirmed the unsigned-to-float rounding fix at
b21594a4on an RTX 5080 (driver 621.40) and built-in WARP 10.0.26100.10068. Both matched the model bit-for-bit on all 84v_cvt_f32_u32inputs, with zero differences between adapters.For one direct comparison, I ran the same integer through the tests on #1602 (
94a2e994) and on this PR. The outputs below are f32 bit patterns.0xffffff7f0x4f7fffff0x4f7fffff→0x4f7fffff0x4f800000→0x4f7fffffThe #1602 test explicitly allows that one-ULP difference on WARP and logged it. The exact check on this head passes. Across the full selected conversion test, each adapter completed 20 dispatches covering 1,154 input records. Windows 11 build 26300.10075.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:38:15Z.
Automated triage for the maintainers.
Merge candidate.
v_cvt_f32_u32inLower::valu_op(crates/victory-shader/src/emit/lower.rs) now converts the two 16-bit halves separately and combines them ashi * 65536 + lothroughfmad. Both halves and the scaled high half are exact in f32, so the sum rounds once, to nearest even, whether or not the host fuses. That is correct on every host, not only on WARP, which misrounds the plainuitofp.The probe in
semantics_tests::conversion_probesnow compares bit-exactly (INT). Its inputs are the two observed WARP misroundings plus the neighbours of the rounding midpoints at every inexact exponent. The expected values come from Rust'sas f32, an independent reference. The thread confirms bit-exact results on an RTX 5080 and on WARP. CIcheckpasses, the offline count is unchanged, and the branch merges cleanly.Generated by Claude Code