shader: v_cvt_f32_f64 rounds a double on its bits (#531) #546
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T02:48:01Z.
Refs #531
This is the
v_cvt_f32_f64part of #531 ("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 #521, #522 and #357. 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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-28T04:56:00Z.
Swept #546 (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 #531 probably comes from a part of the game this corpus doesn't reach, or the opcode sits behind an earlier refusal.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T05:17:56Z.
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" (#531)? With it, anyone holding a corpus from that part of the game could check that this PR translates it.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T08:13:32Z.
Closing: this change is already in.
Pull request closed