Shader fract f64 #1477

Closed
vsking2000 wants to merge 2 commits from upstream-pr/1477 into main
vsking2000 commented 2026-11-25 01:12:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by vsking2000 on 2026-11-25T01:12:46Z.


Claimed in the coordination issue as:

Depends on:

Fixes:

What and why

Tested

GPUs tested:

AI-assisted:

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5483179426 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477). Originally posted by [vsking2000](https://github.com/vsking2000) on 2026-11-25T01:12:46Z. --- Claimed in the coordination issue as: <!-- the item ID from the open "Coordinating who works on what" issue, for example TEST-17, or a link to your claim --> Depends on: <!-- #N for every pull request this one builds on or conflicts with (the coordination issue's Commands section, AGENTS.md); delete the line if it builds on none and conflicts with none --> Fixes: <!-- #N for each issue this closes (GitHub closes it on merge); delete the line if it closes none --> ### What and why <!-- What this changes and the problem it solves. --> ### Tested <!-- What you ran and on which GPU and driver (CONTRIBUTING.md). For the shader translator: how many shaders translate and pass spirv-val, before and after. --> GPUs tested: <!-- vendor, model, driver and OS of each GPU the GPU tests ran on, or n/a --> AI-assisted: <!-- yes or no (AGENTS.md asks a coding agent to say so) --> ### Checklist - [ ] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [ ] One topic; follow-up work goes in a new pull request. - [ ] 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.
ecox982745 commented 2026-11-25 01:45:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-25T01:45:28Z.


I tested translated v_fract_f64 at 3c359c50 on an RTX 4090 (Windows 11, NVIDIA 616.64). All 81,910 checked GPU outputs matched the PR's specified result bit for bit.

I used 20,480 distinct binary64 inputs loaded from a buffer at dispatch: both signs, all 2,048 exponent fields, and five fraction fields per exponent (zero, one, the high fraction bit, all ones, and a varying pattern). For finite values I computed the fractional part with exact rational arithmetic, rounded to binary64, then applied the specified cap below 1. Special values were compared as raw words.

Hand-written compute shader Exact matches
Plain v_fract_f64 20,480 / 20,480
Negated absolute source 20,480 / 20,480
mul:4 output modifier 20,480 / 20,480
clamp, finite inputs 20,470 / 20,470

The plain instruction returned positive zero for negative zero, preserved the sign and payload of the sampled signalling NaNs, returned 0xfff8000000000000 for both infinities, and mapped the smallest negative subnormal to 0x3fefffffffffffff. I excluded the ten nonfinite inputs from the clamp comparison because that result is outside this PR's contract.

The branch point 364ab4ea refused all four shader variants at v_fract_f64. At the head, all four passed Vulkan 1.2 SPIR-V validation and ran with vk_compute_test built from the head. Separately, test_fract_f64 and test_f64_literal_whole passed 28/28 on CPU, with no skips. This verifies the translated Vulkan behavior on NVIDIA. Native RDNA2 fractional-part edge semantics remain unmeasured here. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7149920406 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1477#issuecomment-7149920406). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-25T01:45:28Z. --- I tested translated `v_fract_f64` at `3c359c50` on an RTX 4090 (Windows 11, NVIDIA 616.64). All **81,910 checked GPU outputs** matched the PR's specified result bit for bit. I used 20,480 distinct binary64 inputs loaded from a buffer at dispatch: both signs, all 2,048 exponent fields, and five fraction fields per exponent (zero, one, the high fraction bit, all ones, and a varying pattern). For finite values I computed the fractional part with exact rational arithmetic, rounded to binary64, then applied the specified cap below 1. Special values were compared as raw words. | Hand-written compute shader | Exact matches | | --- | ---: | | Plain `v_fract_f64` | 20,480 / 20,480 | | Negated absolute source | 20,480 / 20,480 | | `mul:4` output modifier | 20,480 / 20,480 | | `clamp`, finite inputs | 20,470 / 20,470 | The plain instruction returned positive zero for negative zero, preserved the sign and payload of the sampled signalling NaNs, returned `0xfff8000000000000` for both infinities, and mapped the smallest negative subnormal to `0x3fefffffffffffff`. I excluded the ten nonfinite inputs from the clamp comparison because that result is outside this PR's contract. The branch point `364ab4ea` refused all four shader variants at `v_fract_f64`. At the head, all four passed Vulkan 1.2 SPIR-V validation and ran with `vk_compute_test` built from the head. Separately, `test_fract_f64` and `test_f64_literal_whole` passed 28/28 on CPU, with no skips. This verifies the translated Vulkan behavior on NVIDIA. Native RDNA2 fractional-part edge semantics remain unmeasured here. AI-assisted verification.
tiguan26 commented 2026-11-25 06:13:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T06:13:06Z.

Review: APPROVED


Approving. Merged into current main with no conflicts; the PR's tests pass and the full translator suite gives 488 files / 6,302 tests with only test_int32_to_f64 failing, the same baseline failure as main here (Linux, Python 3.13). I read the diff: the new lowering and its refusals match the ISA behaviour, and the tests cover both the folded and refused shapes.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6052691308 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477#pullrequestreview-6052691308). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T06:13:06Z. **Review:** APPROVED --- Approving. Merged into current main with no conflicts; the PR's tests pass and the full translator suite gives 488 files / 6,302 tests with only `test_int32_to_f64` failing, the same baseline failure as main here (Linux, Python 3.13). I read the diff: the new lowering and its refusals match the ISA behaviour, and the tests cover both the folded and refused shapes. AI-assisted (Claude).
qhukz13 commented 2026-11-26 01:19:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-26T01:19:55Z.


I checked 3c359c50 on Linux (Python 3.14), CPU only. I did not use a GPU.

Merge state. The branch merges into main (88479ff6) without conflicts. It conflicts with #1374 in two lines:

  • the parse_line f64 list in tools/shader_ir.py;
  • the --list-ops "Excluded" line in tools/f64_diff.py.

Whichever lands second has to take the other's opcodes out of that line. v_ldexp_f64 is still listed there as
excluded, but main translates it.

Tests. On the merge, test_fract_f64 passes, 23 tests with 1 skipped. test_f64_literal_whole and the old
test_valu_fract_f64 oracle also pass. The full translator suite on the merge gives
496 files, 6,356 tests, 0 files failed.

Edge cases. I translated hand-written listings and ran them through spirv_interp. They give the words in the row:

Case Result
-1e-300 and the negative subnormal 0x8000000000000001 0x3fefffffffffffff
-2.25 0.75
2^53 + 2 +0
-|0.25| in the e64 form 0.75
mul:2 ignored

The selects build every edge from the operand's words, so none of it depends on how a driver handles Floor(-0.0)
or binary64 subnormals. That is the right call.

One gap, shared with #1374. v_fract_f64_e64 v[4:5], inf clamp returns 0xfff8000000000000:

  • the select gives the NaN of fract(±inf);
  • clamp_mods_f64 then applies a bare FClamp to it, which GLSL.std.450 leaves undefined;
  • the hardware gives +0 with DX10_CLAMP set, the game's MODE.

A NaN passed with clamp takes the same path. The f32 and f16 clamps select +0 for a NaN since 2026-11-24 ("Float
min/max/med3 with NaN"), and that row already lists the f64 clamp as still bare. Since this op picks its own words for
every other edge, selecting +0 before the clamp here, or fixing clamp_mods_f64 once for all f64 ops, would close it.
Otherwise the row could say the clamp of the infinity and NaN cases is left to the driver.

For scale: docs/isa_coverage.md puts the f64 ops among the groups the 1.0.2.1 corpus does not need. This does not
block merging.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7179667040 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1477#issuecomment-7179667040). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-26T01:19:55Z. --- I checked `3c359c50` on Linux (Python 3.14), CPU only. I did not use a GPU. **Merge state.** The branch merges into main (`88479ff6`) without conflicts. It conflicts with #1374 in two lines: - the `parse_line` f64 list in `tools/shader_ir.py`; - the `--list-ops` "Excluded" line in `tools/f64_diff.py`. Whichever lands second has to take the other's opcodes out of that line. `v_ldexp_f64` is still listed there as excluded, but main translates it. **Tests.** On the merge, `test_fract_f64` passes, 23 tests with 1 skipped. `test_f64_literal_whole` and the old `test_valu_fract_f64` oracle also pass. The full translator suite on the merge gives 496 files, 6,356 tests, 0 files failed. **Edge cases.** I translated hand-written listings and ran them through `spirv_interp`. They give the words in the row: | Case | Result | |---|---| | -1e-300 and the negative subnormal `0x8000000000000001` | `0x3fefffffffffffff` | | -2.25 | 0.75 | | 2^53 + 2 | +0 | | `-\|0.25\|` in the e64 form | 0.75 | | `mul:2` | ignored | The selects build every edge from the operand's words, so none of it depends on how a driver handles `Floor(-0.0)` or binary64 subnormals. That is the right call. **One gap, shared with #1374.** `v_fract_f64_e64 v[4:5], inf clamp` returns `0xfff8000000000000`: - the select gives the NaN of fract(±inf); - `clamp_mods_f64` then applies a bare `FClamp` to it, which GLSL.std.450 leaves undefined; - the hardware gives +0 with DX10_CLAMP set, the game's MODE. A NaN passed with `clamp` takes the same path. The f32 and f16 clamps select +0 for a NaN since 2026-11-24 ("Float min/max/med3 with NaN"), and that row already lists the f64 clamp as still bare. Since this op picks its own words for every other edge, selecting +0 before the clamp here, or fixing `clamp_mods_f64` once for all f64 ops, would close it. Otherwise the row could say the clamp of the infinity and NaN cases is left to the driver. For scale: `docs/isa_coverage.md` puts the f64 ops among the groups the 1.0.2.1 corpus does not need. This does not block merging. AI-assisted (Claude).
MoonEyes commented 2026-11-27 22:42:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T22:42:55Z.


Hi @vsking2000, thanks for this pull request.

CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post claiming: <ID> there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one.

The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.

Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7229557194 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477#issuecomment-7229557194). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T22:42:55Z. --- Hi @vsking2000, thanks for this pull request. CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post `claiming: <ID>` there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one. The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time. Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough. AI-assisted (Claude Code, Claude Opus 5.5).
sodove commented 2026-11-28 10:44:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:44:17Z.


#1477 | head 3c359c509121dcc28f977a1038f2f90b105ae3f9 | python3 -m unittest discover -s tests/semantic -p test_f64_literal_whole.py -v, python3 -m unittest discover -s tests/semantic -p test_fract_f64.py -v | red: 28 run, 2 failures, 85 errors | green: 28 passed | Red → green

The two files exercise f64 fractional-part translation, including a literal spanning two DWORDs and the sign and rounding edge cases in the PR.

Captured 72 distinct complete SPIR-V module(s) emitted while rerunning test_fract_f64.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.

Test file Main + PR tests PR + main
tests/semantic/test_f64_literal_whole.py 5 run, 2 errors 5 passed
tests/semantic/test_fract_f64.py 23 run, 2 failures, 83 errors 23 passed

Base 3bd936ecd98995bca3e1da83d5e28d2343001aef was merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238089511 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477#issuecomment-7238089511). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T10:44:17Z. --- #1477 | head `3c359c509121dcc28f977a1038f2f90b105ae3f9` | `python3 -m unittest discover -s tests/semantic -p test_f64_literal_whole.py -v`, `python3 -m unittest discover -s tests/semantic -p test_fract_f64.py -v` | red: 28 run, 2 failures, 85 errors | green: 28 passed | **Red → green** The two files exercise f64 fractional-part translation, including a literal spanning two DWORDs and the sign and rounding edge cases in the PR. Captured 72 distinct complete SPIR-V module(s) emitted while rerunning test_fract_f64.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand. | Test file | Main + PR tests | PR + main | |---|---|---| | `tests/semantic/test_f64_literal_whole.py` | 5 run, 2 errors | 5 passed | | `tests/semantic/test_fract_f64.py` | 23 run, 2 failures, 83 errors | 23 passed | Base `3bd936ecd98995bca3e1da83d5e28d2343001aef` was merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7237873883).
TheGeogeo commented 2026-11-29 14:17:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:17:34Z.


Needs rebase: conflicts with main 3535eb5c4 in docs/design.md. The last main change to those lines is 273b3bdf9 (2026-11-24, "[integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)"). Not in main yet (git cherry: 2 commit(s) not there), and no duplicate found among the open pull requests.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257189663 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477#issuecomment-7257189663). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T14:17:34Z. --- Needs rebase: conflicts with `main` `3535eb5c4` in `docs/design.md`. The last `main` change to those lines is `273b3bdf9` (2026-11-24, "[integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)"). Not in `main` yet (`git cherry`: 2 commit(s) not there), and no duplicate found among the open pull requests. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 11:47:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:47:12Z.

Review: CHANGES_REQUESTED


This PR cannot merge in its current state:

  • Merge conflict with main in docs/design.md (and overlaps tools/shader_ir.py / tools/f64_diff.py with #1374).
  • No CI run on current head 3c359c5.
  • Unfilled PR description: the body is still the raw PR template without summary, test results, or coordination-issue claim.

Please rebase onto current main, fill out the PR description (including the coordination claim), and obtain a green CI run.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130609876 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477#pullrequestreview-6130609876). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:47:12Z. **Review:** CHANGES_REQUESTED --- This PR cannot merge in its current state: - **Merge conflict** with `main` in `docs/design.md` (and overlaps `tools/shader_ir.py` / `tools/f64_diff.py` with `#1374`). - **No CI run** on current head `3c359c5`. - **Unfilled PR description**: the body is still the raw PR template without summary, test results, or coordination-issue claim. Please rebase onto current `main`, fill out the PR description (including the coordination claim), and obtain a green CI run. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 17:23:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:23:37Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319227092 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1477#issuecomment-7319227092). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:23:37Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1477
No description provided.