Skip to content

Translator: --f64-soft, exact binary64 without shaderFloat64 (SHADER-479) - #2904

Open
Jolymmiles wants to merge 2 commits into
ItsNotRexed:mainfrom
Jolymmiles:t3/f64-soft-fallback
Open

Jolymmiles wants to merge 2 commits into
ItsNotRexed:mainfrom
Jolymmiles:t3/f64-soft-fallback

Conversation

@Jolymmiles

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: SHADER-479 (claim)

What and why

Metal has no double type, so MoltenVK (and KosmicKrisp) report no shaderFloat64, and any module that declares Float64 can't run on a Mac. ps_f64_mods skipped there, and a game shader with an f64 op couldn't run at all. Intel Arc has neither shaderFloat64 nor shaderInt64.

--f64-soft is a translator mode that keeps every binary64 value as the two 32-bit words of its register pair and computes with 32-bit integer instructions only, so the module declares neither Float64 nor Int64.

  • tools/soft_f64.py (new): Berkeley SoftFloat 3's algorithms on 32-bit halves (add/sub mags, round-and-pack, f64_to_f32). Each operation is one SPIR-V function, emitted once per module and called with OpFunctionCall. The bodies are straight-line OpSelect code, and every shift amount is reduced below 32, since SPIR-V and MSL leave larger shifts undefined.
  • Semantics: IEEE-754 binary64 with MODE.FP_ROUND[3:2] (nearest even and toward zero; the function also implements ±inf). f64 denormals are kept. -0 follows IEEE. An operand NaN comes back quiet with its sign and payload, src0 first; inf − inf gives 0x7ff80000_00000000. neg/abs act on the sign bit. omod rounds to nearest even, as the native OpFMul does, and clamp gives +0 for NaN and −0.
  • Covered: v_add_f64 (all modifiers, MODE toward zero), v_cvt_f32_f64, and the output modifiers of v_frexp_mant_f64.
  • Not covered yet: under the flag, v_rcp_f64, v_rsq_f64 and v_sqrt_f64 (tests: polish v_rcp_f64/v_rsq_f64/v_sqrt_f64 test coverage #2244) are refused (Unsupported), as is any later f64 op without a soft form. A module never declares Float64 under --f64-soft.
  • Automatic selection, like the other fallbacks: tools/vk_subgroup_info.py now reports float64 (MoltenVK and KosmicKrisp false, llvmpipe true). make_game.py, scripts/run_gpu_tests.py and runtime/test/shaders/build.py pass --f64-soft where it is false, and LEONIDA_F64_SOFT=1/0 overrides that.
  • Without the flag the translator output is byte-identical.
  • New GPU fixtures ps_f64_round (ties to even, −0, toward zero, overflow to DBL_MAX) and ps_f64_cvt (f32 ties, overflow, neg/abs), plus tests/semantic/test_f64_soft.py, the docs/design.md contract row and a docs/testing.md section.

Tested

All runs are on an Apple M3 Max (macOS 27.3) with MoltenVK 1.4.2 (Homebrew), MoltenVK main 1.4.3, KosmicKrisp and llvmpipe (LLVM 23.1.6), on ec8ec4c9.

  • Bit-exactness sweep (work/ harness, not committed): 1,048,576 operand pairs (random words, nearby exponents, cancellation, ties, denormal and overflow ranges, and the cross product of 38 specials) through 12 variants. The variants are add in all four rounding modes, mul:2/mul:4/div:2, clamp, neg, abs, toward zero + div:2 + clamp, and v_cvt_f32_f64, run as a compute shader. All 12,582,912 results equal an exact fractions reference on KosmicKrisp, llvmpipe, MoltenVK 1.4.2 and MoltenVK main.
  • Against the translator's native double code on llvmpipe (the only fp64 driver here), every word is equal except where llvmpipe itself isn't exact:
    • It flushes f64 denormals: it has no shaderDenormPreserveFloat64, and about 10% of the inputs involve a denormal operand, result or toward-zero intermediate.
    • NaN payloads differ.
    • One toward-zero sum near DBL_MAX comes out wrong on the native path, because its TwoSum overflows (Gen.f64_add_mode). I'm posting that as a separate finding. KosmicKrisp has no fp64 at all (shaderFloat64 false).
  • scripts/run_gpu_tests.py, all tests, 6 configs (MoltenVK, KosmicKrisp and llvmpipe, each plain and with LEONIDA_W64_EMULATE=1 LEONIDA_MESH_COMPUTE=1), main against this branch:
    • Nothing gets worse.
    • ps_f64_mods goes from SKIP to PASS (4096/4096) on MoltenVK and KosmicKrisp, in both modes.
    • ps_f64_round and ps_f64_cvt pass on all 6 configs.
    • The one remaining failure, ps_ssharp on MoltenVK 1.4.2, fails the same way on main.
    • Overall: MoltenVK goes from 116/189 to 119/191, KosmicKrisp from 132/189 to 135/191, llvmpipe from 120/189 to 122/191.
  • Stability: --filter f64 ran 10 times each on MoltenVK, KosmicKrisp, llvmpipe native and llvmpipe with LEONIDA_F64_SOFT=1: 3/3 every time.
  • Byte identity: runtime/test/shaders/build.py gives the same output on main and on this branch, 453 of 453 files, plain and with LEONIDA_W64_EMULATE=1, LEONIDA_F16_INTERP_FALLBACK=1 + LEONIDA_TEXOFF_FALLBACK=1 and LEONIDA_BARY_FALLBACK=1. index.json differs only by the two new fixtures. With LEONIDA_F64_SOFT=1, only ps_f64_mods changes: no Float64, and no shaderFloat64 in its features.
  • CPU:
    • python -m unittest discover -s tests/semantic: OK. tests/semantic/test_f64_soft.py has 27 tests (translated programs through the interpreter, plus 4,500 inputs run straight through the function bodies, against its own Fraction reference). A negative control (a broken tie rule, a dropped quiet bit) makes it fail.
    • python -m unittest discover -s tests -p "test_*.py": the same 3 failures as main (test_docs_design_rows, the existing duplicate rows).
    • regen_fixtures.py --check, compileall and make_game.py --help: clean.
  • Not run: the corpus slice, because I don't have a work folder. Without the flag the output is byte-identical, so translated and spirv-val counts can't change. With the flag, a shader that uses v_rcp/rsq/sqrt_f64 becomes Unsupported, where before it translated but couldn't run on these devices.

Also seen: KosmicKrisp writes 0x7fc00000 for any f32-NaN word stored to vk_harness's R32G32B32A32_SFLOAT attachment. ps_f64_round therefore exports DBL_MAX's high word shifted right by 8. I'm posting this as a finding.

AI-assisted (Claude Code). No game data: the fixtures and tests are hand-written.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🤖 Generated with Claude Code

@padhossein

Copy link
Copy Markdown
Contributor

Independent software binary64 Vulkan check (5ddfabc9). With LEONIDA_F64_SOFT=1, all three ps_f64 fixtures passed full assembly/translation/validation and rendered 4,096/4,096 exact pixels each on Mesa llvmpipe 26.1.6. I independently dispatched 24 binary64 additions in each of the two MODE values currently accepted by RDNA2 translation (nearest-even and toward-zero); all 96 result words matched the Fraction reference, covering denormals, signed zero, overflow, ties, and NaN quieting. That compute shader uses BDA for the result buffer; it has no Float64 capability. The 27 targeted semantic tests also pass.

Synthetic inputs only. AI-assisted (Codex).

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 5ddfabc907072b523b9a2be238e7f697c1b3bce0 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent synthetic Vulkan check of 5ddfabc907072b523b9a2be238e7f697c1b3bce0 on Linux 7.0.0-43 (RTX 5090, NVIDIA 595.99.02, LLVM 21.1.8, SPIRV-Tools 2026.1).

All three fixtures (ps_f64_mods, ps_f64_round, and ps_f64_cvt) matched all 4,096 pixels each with LEONIDA_F64_SOFT=1 and again with LEONIDA_F64_SOFT=0. The raw words were identical between modes, including the signed-zero and toward-zero overflow cases.

All six modules passed Vulkan 1.2 SPIR-V validation. Disassembly confirmed that the three software modules declare neither Float64 nor Int64, while each native module declares Float64. All 27 focused semantic tests passed. The GPU run used forced selection on a device with native binary64 support.

AI-assisted verification.

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 data point (adds to the M3 Max results in the PR body). Tested head 5ddfabc on Apple M2 (Mac14,3), macOS 26.4 (25E246), MoltenVK 1.4.2 (Homebrew, direct), subgroup 4..32, llvm-mc 23.1.6, Python 3.13.18.

python -I scripts/run_gpu_tests.py --filter f64 --build runtime/build/linux: 3 shaders translated, 3 pass spirv-val; 3/3 passed — ps_f64_mods, ps_f64_round and ps_f64_cvt each 4096/4096 pixels exact. On unpatched main at ec8ec4c on this same M2, ps_f64_mods is a SKIP (no shaderFloat64); with this head it runs and passes, matching the M3 Max result.

Build note: the full build at this head fails on AppleClang 17 at vk_pipeline_check.cpp:567 (the Mac from_chars break, BUILD-822, fixed by open PR #2927); all GPU binaries built, so the run above is valid. Head fetched unchanged into a separate worktree; no rebase/edit/push. Synthetic shaders, counts only; no game files.

AI-assisted.

@Etoile-Bleu

Copy link
Copy Markdown
Contributor

Tested 5ddfabc merged with main 1628210 on NVIDIA GeForce RTX 5070 Ti (real fp64 hardware, shaderFloat64 true), driver 621.24, Windows 11 (10.0.26200): pass.

Merge: the PR conflicts with main in docs/design.md only (a table row added next to the class-compare row); keeping both rows resolves it. Everything below is on the merged tree.

  • python -m unittest discover -s tests/semantic: 4169 tests OK; test_f64_soft.py 27/27; test_make_game_translator_flags, test_vk_subgroup_info, test_make_game_argparse, regen_fixtures.py --check pass. tools/vk_subgroup_info.py reports float64: true on this card, so the auto-selection keeps the native path here.
  • python -I scripts/run_gpu_tests.py with LEONIDA_F64_SOFT=0 and =1 (llvm-mc 21.1.8, runtime built with MSVC/Ninja): 145/191 passed, 0 failed, 46 skipped in both. ps_f64_mods, ps_f64_round and ps_f64_cvt are 4096/4096 in both; with =1 the index shows no Float64 capability and no shaderFloat64 feature.
  • Soft vs native on a GPU that has real doubles: I wrote a throwaway compute shader (not in the PR) where each thread builds an operand pair from a hash (exponents within 3, near-cancellation, denormals, top binade/overflow, independent exponents, some inf/NaN) and writes v_add_f64 (MODE nearest and toward zero) and v_cvt_f32_f64, then compared every word with an exact Fraction reference. 524,288 pairs / 2,097,152 results (65,840 with a denormal operand, 50,833 denormal sums, 32,766 finite operands with an infinite sum, 150,165 where toward-zero differs from nearest): 0 mismatches with --f64-soft (module declares no Float64) and 0 with native doubles. NaN results were only required to be NaN. Breaking the tie rule in soft_f64.py (0x200 -> 0x201) gives 6,375 mismatches on one seed, so the sweep does detect it.
  • One thing to know when writing references: v_cvt_f32_f64 follows MODE.FP_ROUND[1:0] (single), not [3:2], so after s_setreg MODE [3:2]=3 it still rounds to nearest, which is what both translations do.

No game files used. Run with AI assistance.

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 5ddfabc on Steam Deck LCD (Van Gogh, RADV Mesa 26.2.0-devel, SteamOS 3.9.5, kernel 7.2.7-valve2-2-neptune-72-g31504582a073): pass.

Commands run (from the PR worktree, against the existing runtime/build on ec8ec4c9):

  • PYTHONPATH=tests/semantic python3 tests/semantic/test_f64_soft.py -> 27/27 OK
  • python3 -I scripts/run_gpu_tests.py --build /home/deck/opencode/Leonida/runtime/build -> 177/191 passed, 14 skipped, 0 failed

The 14 skips are the expected D3D12-owned fixtures and ps_w64x_readlane on this RADV device (cannot require a 64-wide fragment subgroup); no failures. Total increased by 2 vs the 175/189 baseline due to the new ps_f64_cvt and ps_f64_round fixtures. On this RADV device shaderFloat64 is available, so the full GPU suite ran in the normal (non---f64-soft) path.

AI-assisted (OpenCode).

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 5ddfabc9 on CachyOS Linux, Python 3.14. tests/semantic/test_f64_soft.py, tests/test_make_game_argparse.py, tests/test_make_game_translator_flags.py, tests/test_vk_subgroup_info.py: 122 passed, 1 skipped, 76 subtests passed.

The soft-f64, translator flag, preflight and capability-detection tests passed on Linux. This check covers the CPU semantics and option plumbing.

AI-assisted, synthetic inputs only.

@Jolymmiles

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (16282101, resolved the docs/design.md table conflict) and pushed b2a119c1 with fixes from an internal adversarial review:

  • 32-bit literals on v_frexp_mant_f64_e64 / v_frexp_exp_i32_f64_e64: marked both operands as f64 literals in shader_ir.py and read via f64_words() (0x3ff80000 mul:2 → 1.5, exp → 1), preserving byte-identical output on all existing fixtures when --f64-soft is off. Added SoftF64Frexp semantic tests and GPU fixture ps_f64_frexp_lit.
  • v_cvt_f32_f64 output modifiers under --f64-soft: replaced GLSL FClamp (undefined on NaN) with integer scale_f32 / clamp01_f32 handling NaN (→ +0.0), ±0, subnormals, and overflow cleanly (also fixed a duplicate OpTypeFunction caught by spirv-val). Added semantic tests and GPU fixture ps_f64_cvt_mods.
  • Int64 contract accuracy: clarified in docs/design.md and help text that soft f64 lowering adds neither Float64 nor Int64 (unrelated features like 64-bit physical buffer addressing still declare Int64 independently; covered by SoftF64Capabilities).
  • Standalone runtime/test/shaders/build.py auto-selection & --harness probe: LEONIDA_F64_SOFT=1/0/unset now matches run_gpu_tests.py and make_game.py; added vk_subgroup_info.py --harness / harness_info() matching vk_device_pick.h selection on mixed-GPU systems without changing make_game.py's runtime-feature filtering.
  • Hardware-evidence note in docs/design.md: explicitly marked f64 NaN payload/sign and f64 omod rounding edge cases as unmeasured on RDNA2 hardware.

Re-tested on b2a119c1 (Apple M3 Max, macOS 27.3, MoltenVK 1.4.2 / KosmicKrisp / llvmpipe Mesa 26.3.1):

  • tests/semantic: 4,179 passed (test_f64_soft.py: 37/37), regen_fixtures.py --check OK; 226 stdlib test files rc 0 (test_vk_subgroup_info 50, test_make_game_translator_flags 15, test_shader_build_f64_soft 4).
  • Byte-identity vs origin/main with LEONIDA_F64_SOFT=0 across 4 flag configs: 454/454 shared modules identical (458/458 under BARY).
  • scripts/run_gpu_tests.py --filter f64: 5/5 PASS (4096/4096) on MoltenVK (auto), KosmicKrisp (auto & =1; =0 SKIP), and llvmpipe (auto, =0, =1).
  • Standalone runtime/test/shaders/build.py (env unset on Mac): auto-selected --f64-soft, 218/218 spirv-val pass, 5/5 check.py ok.

No game files used. AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 5ddfabc as-is (it conflicts with main 1628210 only in docs/design.md) on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:

  • scripts/run_gpu_tests.py: 145/191 passed, 46 skipped, 0 failed. main 1628210 gives 143/189, 46 skipped, 0 failed. All 196 test shaders translate and pass spirv-val.
  • New GPU tests: ps_f64_cvt PASS, ps_f64_round PASS.
  • tests/semantic/test_f64_soft.py: ran 27 tests in 11.472s; OK.
  • tests/test_make_game_argparse.py: Ran 36 tests in 5.738s OK.
  • tests/test_make_game_translator_flags.py: .
  • tests/test_vk_subgroup_info.py: ran 45 tests in 0.035s; OK.

AI-assisted (Claude Code).

@Jolymmiles

Copy link
Copy Markdown
Contributor Author

Thanks for the RTX 5090 run, @JRamos1993. The docs/design.md conflict you hit on 5ddfabc is resolved in the current head b2a119c1, which is rebased on main 1628210. The code is unchanged apart from the review fixes, so your results still apply to the native-f64 side.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested at the head on Windows 11 / Python 3.13.0: the new file 27/27; unittest discover -s tests/semantic 4164 OK vs 4142 on main (+22 net: +27 new, -5 that main gained since the merge base); regen_fixtures --check clean. Negative control: reverting the translator hunk gives 24/27 errors, and only the three pure-reference tests still pass.

The design holds up: binary64 as (lo, hi) u32 pairs with one OpFunction per module (soft_f64.py:143,230,273,305), covering v_add_f64 (neg/abs/omod/clamp, MODE 3), v_cvt_f32_f64 and v_frexp_mant_f64 modifiers, with rcp/rsq/sqrt refused. NaN quieting/payload/src0-wins, inf-inf, +/-inf/-0 and f64 denormals are all as described. The soft ps_f64_mods output has only Shader + SignedZeroInfNanPreserve - no Float64/Int64/OpTypeFloat 64 - and validates with spirv-val.

One blocking item: docs/design.md:292 conflicts with main, which expanded the adjacent "Floating-point class compare" row. Rebase keeping both rows; it is the only conflicting file.

Minor:

  • runtime/test/shaders/build.py:170 accepts only "1", while make_game.py:970 and run_gpu_tests.py:276 accept true/yes/on. It is documented, but the harness and the build should agree.
  • make_game.py:981 (is False) silently emits native Float64 when device detection fails, so a Mac user gets an unloadable module; log the fallback.
  • Soft clamp gives +0 for NaN/-0 (soft_f64.py:291) where native f64 FClamp (rdna2spirv.py:4092) is driver-defined; documented, but only the soft path is tested.

Approve after the rebase. AI-assisted review, no game files, no GPU.

Jolymmiles added a commit to Jolymmiles/Leonida that referenced this pull request Nov 22, 2026
…the choice elsewhere

Review on ItsNotRexed#2904: a failed device probe silently kept native doubles, which on a Mac gives
modules MoltenVK and KosmicKrisp can't load. macOS has no Vulkan driver with shaderFloat64,
so there the unknown case now takes --f64-soft; on other systems make_game logs that it keeps
native doubles and how to switch. Tests pin the device answer so they don't depend on the host.
@Jolymmiles

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @tupacfan04.

  • Blocking (docs/design.md conflict): fixed in 7efba4b8, which is rebased on main f847748c and keeps both rows. That rebase also merged --pc-tail-ubo / max_push_constants_size alongside float64 in make_game.py, vk_subgroup_info.py, build.py and their tests. The PR is mergeable now.
  • build.py accepting only 1: the current head already accepts 1/true/yes/on and 0/false/no/off, as make_game.py and run_gpu_tests.py do (f64_soft() in runtime/test/shaders/build.py). You probably read an earlier revision.
  • Silent native Float64 when detection fails: fixed in 6df8f204. When vk_subgroup_info.py can't answer, make_game.py now takes --f64-soft on macOS, since no Vulkan driver there has shaderFloat64. On other systems it logs that it keeps native doubles and how to switch. test_f64_soft_follows_the_device covers both cases, and the make_game tests now pin the device answer so they don't depend on the host.
  • Clamp of NaN/-0: left as is in this PR. The soft path follows the hardware rule from Translator: the clamp bit gives +0 for a NaN and for -0 (SHADER-186) #2437 (SHADER-186): +0 for NaN and -0. The native FClamp is the clamp row's subject and is driver-defined; on the drivers measured in Translator: the clamp bit gives +0 for a NaN and for -0 (SHADER-186) #2437 it already gives the same +0. Changing the native emission would break byte identity, so it belongs with Translator: the clamp bit gives +0 for a NaN and for -0 (SHADER-186) #2437.

Re-checked after the rebase on an Apple M3 Max: the semantic and tests/ suites are OK. --filter f64 (6 tests) gives 6/6 on MoltenVK, KosmicKrisp, llvmpipe native and llvmpipe with LEONIDA_F64_SOFT=1. With LEONIDA_F64_SOFT=0 the output is byte-identical to main (473/473 files in three configs, 477/477 in the fourth).

@Jolymmiles

Copy link
Copy Markdown
Contributor Author

Aggregate corpus check over the full 26,503-shader Xbox 1.0.2.1 disassembly (rdna2spirv.py at current head 6df8f204, counts only, no game data):

  • Total shaders containing any *_f64 opcode: 5 / 26,503 (v_add_f64: 5 shaders / 216 occurrences; v_cvt_f32_f64_e32: 5 shaders / 36 occurrences; 0 shaders with v_rcp/rsq/sqrt/frexp_f64).
  • Native translation: 5/5 translated, 5/5 valid, 5 declare Float64.
  • With --f64-soft: 5/5 translated, 5/5 valid, 5/5 pass spirv-val --target-env vulkan1.2 --allow-offset-texture-operand, 0 declare Float64.

AI-assisted verification.

…K, Intel Arc)

Metal has no double type, so MoltenVK and KosmicKrisp report no shaderFloat64 and
ps_f64_mods skipped on every Mac. Under --f64-soft the f64 ops keep their values as the
two 32-bit words of the register pair and compute with 32-bit integer instructions only
(tools/soft_f64.py: SoftFloat's add, round-and-pack and f64_to_f32 on 32-bit halves, one
SPIR-V function per operation per module), so the lowering adds neither Float64 nor Int64
(Int64 still comes with what declares it without the flag, such as the 64-bit physical
buffer addresses of scalar loads). Covers v_add_f64 (neg/abs, clamp, omod, MODE toward
zero), v_cvt_f32_f64 (its f32 omod and clamp in integer code too: clamp(NaN) and
clamp(-0) are +0, not GLSL FClamp's undefined NaN result) and the output modifiers of
v_frexp_mant_f64. v_rcp/rsq/sqrt_f64, and any f64 op without a soft form, are refused
under the flag instead of declaring Float64.

v_frexp_mant_f64 / v_frexp_exp_i32_f64 now read a 32-bit literal as bits 63:32, as
v_add_f64 does, with or without the flag (0x3ff80000 is 1.5; it was read as the low word,
a denormal).

tools/vk_subgroup_info.py reports float64, and --harness answers for the device the test
programs pick (vk_device_pick.h's rule, no runtime feature filter). make_game.py passes
--f64-soft where the runtime's GPU lacks shaderFloat64; scripts/run_gpu_tests.py and
runtime/test/shaders/build.py where the harness's GPU does. LEONIDA_F64_SOFT=1/0
overrides, and make_game.py --f64-soft wins over 0. Without the flag the translator
output of every test shader main also builds is byte-identical.

New GPU fixtures ps_f64_round, ps_f64_cvt, ps_f64_cvt_mods and ps_f64_frexp_lit, CPU
tests in tests/semantic/test_f64_soft.py, tests/test_shader_build_f64_soft.py and
tests/test_vk_subgroup_info.py, contract row in docs/design.md.
…the choice elsewhere

Review on ItsNotRexed#2904: a failed device probe silently kept native doubles, which on a Mac gives
modules MoltenVK and KosmicKrisp can't load. macOS has no Vulkan driver with shaderFloat64,
so there the unknown case now takes --f64-soft; on other systems make_game logs that it keeps
native doubles and how to switch. Tests pin the device answer so they don't depend on the host.
@Jolymmiles

Copy link
Copy Markdown
Contributor Author

Rebased on main aa2988cc (head 6eccc0ca). Three things for reviewers:

  • Fixture renamed. Coordinating who works on what (14) (moved to #3047) #2891's TwoSum fix (82cb279) added its own runtime/test/shaders/ps_f64_round.asm (toward-zero sums at DBL_MAX), so my fixture is now ps_f64_ties. Both are registered. main's ps_f64_round now also runs under --f64-soft, and test_f64_soft.py checks its words.
  • New native f64 ops from main. v_trunc/ceil/rndne/floor_f64, v_div_fixup_f64 and v_div_fmas_f64 landed with native code. Like rcp/rsq/sqrt, they are refused under the flag by the Float64 guard, and the contract row lists them as not covered yet. None of them has a GPU test.
  • vk_subgroup_info.py: main's Vulkan 1.2 device path is merged with --harness.

Checked on an Apple M3 Max:

  • --filter f64 runs 7 tests: 7/7 on MoltenVK, KosmicKrisp and llvmpipe native, and on llvmpipe with LEONIDA_F64_SOFT=1 before the final one-commit rebase onto aa2988cc.
  • With LEONIDA_F64_SOFT=0, build.py output is byte-identical to main (493/493 files in three configs, 497/497 with LEONIDA_BARY_FALLBACK=1).
  • The tests/ suite is OK.
  • tests/semantic has exactly the same 36 failures and 2 errors as main aa2988cc (sdwa / fma_mix hardware rows, loop-ballot emulation). None comes from this PR.

@Yourrespawn

Copy link
Copy Markdown
Contributor

Tested 6df8f204 on NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), driver 617.14, Vulkan API 1.4.351, Windows 11 Pro 10.0.26200: pass — both paths.

  • Semantic suite: 7359 OK, 1 expected failure (Python 3.12.10), including the soft_f64 coverage
  • run_gpu_tests.py, default hardware path: 157/203 passed, 0 failed, 46 skipped (native wave64 skipped as expected) — the four f64 fixtures (cs_f64_add, ps_f64_cvt, ps_f64_cvt_mods, ps_f64_frexp_lit) all 4096/4096 exact on real shaderFloat64 hardware, so the opt-in mode changes nothing where the driver has doubles.
  • The soft path itself, cross-vendor on NVIDIA: LEONIDA_F64_SOFT=1 → 6/6 f64 fixtures pass, every pixel exact (cs_f64_add, ps_f64_cvt, ps_f64_cvt_mods, ps_f64_frexp_lit, ps_f64_mods, ps_f64_round). The Berkeley SoftFloat algorithms lowered to straight-line 32-bit integer SPIR-V produce bit-exact IEEE-754 binary64 through the NVIDIA driver — the same lowerings the author validated on MoltenVK. That's a strong datapoint that a card without shaderFloat64 would draw these correctly too.

AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested 6eccc0c on Apple M2 with MoltenVK 1.4.2 (macOS 26.4 (25E246), subgroup 4..32, device Vulkan 1.4.357): f64 fixtures 7/7 pass; full suite 134/214 passed, 73 skipped, 7 failed vs base aa2988c 127/210 passed, 76 skipped, 7 failed A/B; no regression.

This is the target platform: vulkaninfo reports no shaderFloat64 on this Apple GPU, and the base skips cs_f64_add, ps_f64_mods and ps_f64_round for exactly that reason.

  • --filter f64: cs_f64_add, ps_f64_cvt, ps_f64_cvt_mods, ps_f64_frexp_lit, ps_f64_mods, ps_f64_round, ps_f64_ties — 7/7 PASS, all pixel readbacks 4096/4096 exact.
  • Full suite at head: 217 shaders translated, 217 pass spirv-val; 134/214 passed, 73 skipped, 7 failed (the seven known MoltenVK expected failures: cs_fma_fused, ps_ssharp, ps_vcmp_f16, ps_vcmp_f16_e64, ps_vcmp_f32_nan, ps_vcmpx_f16, ps_vcmpx_f16_e64).
  • Negative control at this PR's base aa2988cc555b, built and run identically here: 127/210 passed, 76 skipped, 7 failed, the same seven. Against that base the head adds four passing fixtures (ps_f64_cvt, ps_f64_cvt_mods, ps_f64_frexp_lit, ps_f64_ties), turns three f64 fixtures from SKIP to PASS, and changes the status of no other common test.
  • python -m unittest discover -s tests/semantic -p test_f64_soft.py: 38/38 OK (Homebrew llvm-mc 21.1.8, Python 3.13.18).
  • Clean CMake configure and full build on AppleClang 17; no code changes of my own.

For completeness, running current upstream/main 98fa503f here gives 152/217 with the same seven failures; its higher count and lower skip count come from newer fixtures and runner skip logic on main, not from this PR — the base-matched A/B above is the meaningful comparison.

No game data; synthetic fixtures and counts only.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants