shader: v_cvt_f32_f64 rounds a double on its bits (#531) #550
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!550
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-546"
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?
@marcus-4 on GitHub · 2026-11-28 02:48 UTC · original
marcus-4:fix/cvt-f32-f64→main· +333 −1 · 5 files · 1 commits · closed without mergingRefs #535
This is the
v_cvt_f32_f64part of #535 ("one opcode"). The rectangle stage-in part and logging a reason for every dropped draw are not in this PR.What changes
v_cvt_f32_f64was refused ("v_cvt_f32_f64 is not supported"). It is now lowered on the double's bits as 64-bit integers, inLower::f64_bits_to_f32_bits:Lower::src_f64reads a double source.negandabsact on bit 63, an inline float constant is read as that double, and a literal as the double's high dword.src64keeps refusing float modifiers on the integer operations that use it.docs/native-host.md: a new "Doubles" section, which marks the rounding mode as a guess. The console's MODE could flush f32 denormal results. This PR follows the IEEE default, which is DXIL'sfptrunc, and is also what Leonida's translator (ProjectLeonida/mandy) chose for the same instruction.Tests
double_tests::a_double_rounds_to_the_nearest_float_with_its_modifiers(Metal):f64 as f32.valu_tests::v_cvt_f32_f64_rounds_a_double_to_the_nearest_float(Windows hardware GPU and WARP, so it runs in CI).Checked locally (M1 Pro, macOS 27.2):
x86_64-pc-windows-gnullvmwith-D warningsandcargo xtask policypass;Checked locally (M1 Pro, macOS 27.2), each GPU test in its own process, one at a time:
A first, parallel run (10 test threads) of victory-gpu on this branch hung this 16 GB M1 Pro's GPU within its first second: IOGPUFamily logged 80 command queues for the test binary, then nothing; WindowServer's Metal submission blocked in the driver for 120 s, and the kernel's watchdog panicked. No test hangs on its own, this one included (about 1 s). So it takes many tests' GPU work at once, which is the class of failure in #525, #526 and #360. That parallel run is a separate matter from this change, and I'll open an issue for it with the reports if that would help.
Apple GPUs run no doubles, so v_cvt_f32_f64 was refused ("v_cvt_f32_f64 is not supported"). It is now lowered on 64-bit integers: round to nearest even with the carry into the exponent, infinity past the largest float, float denormals kept, a NaN quieted with its sign and the top of its payload. Source neg and abs act on bit 63; inline float constants read as doubles and a literal as the high dword. The rounding follows the IEEE default (DXIL's fptrunc), as Leonida's translator (ProjectLeonida/mandy) chose; whether the console's MODE flushes f32 denormal results is marked as a guess in native-host.md. Tests: victory-gpu double_tests (Metal, edge doubles and 4,096 random ones, plain/neg/abs/clamp, bit for bit against Rust's conversion) and victory-shader valu_tests (Windows hardware GPU and WARP). Refs #531github-bot referenced this pull request2026-11-28 03:18:48 +00:00
@alexballvideos-netizen on GitHub · 2026-11-28 04:56 UTC · original
Swept #550 (head
508ef3c3, merged onto main61f55a49) over a 21,579-shader world corpus (Series X, 1.0.2.1) withexamples/sweep -j 4, on an M3 Max.No shader in this corpus is refused first for
v_cvt_f32_f64, so this is a no-regression check, not a coverage measurement. The one shader from #535 probably comes from a part of the game this corpus doesn't reach, or the opcode sits behind an earlier refusal.@marcus-4 on GitHub · 2026-11-28 05:17 UTC · original
Thanks, @alexballvideos-netizen. A clean no-regression sweep is what this needed. Agreed that it says nothing about coverage.
@LakshanSivakumar, do you have the hash of the shader your run refused with "v_cvt_f32_f64 is not supported" (#535)? With it, anyone holding a corpus from that part of the game could check that this PR translates it.
@marcus-4 on GitHub · 2026-11-28 08:13 UTC · original
Closing: this change is already in.
Pull request closed