Shaders: correctly round unsigned-to-float conversion on WARP #2186
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2186
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2186/head"
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?
@Razdva122 on GitHub · 2026-11-25 07:18 UTC · original
Razdva122:shader/exact-u32-to-f32→main· +28 −3 · 2 files · 1 commits · merged 2026-11-25 21:55 UTCWARP 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.
@sinan-cmyk on GitHub · 2026-11-25 07:50 UTC · original
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).
@MamaLeVrai on GitHub · 2026-11-25 07:57 UTC · original
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.
@steven-seagull27 on GitHub · 2026-11-25 09:18 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 12:38 UTC · original
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