check.py, run_gpu_tests.py: exact-word pixel tests accept KosmicKrisp's canonical NaN (TEST-KOSMICKRISP-CANONICAL-NAN) #2110

Closed
github-bot wants to merge 1 commit from github-bot/gh-2110 into main AGit
Owner

@⁠Tauwni on GitHub · 2026-11-25 21:07 UTC · original
Tauwni:fix/kosmickrisp-nan-canonicalization → main · +62 −6 · 4 files · 1 commits · closed without merging

Claimed in the coordination issue as: #1608

What and why

KosmicKrisp (Mesa 26.3.1) writes any f32 NaN to an RGBA32F attachment as 0x7fc00000. That is the measured row in docs/testing.md, and until now only ps_nan_payload allowed it. So ps_cndmask_sign_mods and ps_valu16_mad_sel, which expect non-canonical NaN words (0xff800001, 0x7f800001, 0xffffffff), failed every pixel on KosmicKrisp while passing on MoltenVK and llvmpipe (the finding in #1608).

The same rule now covers every exact-word pixel test, in check.py and in run_gpu_tests.py (check_pixel_const): the canonical word is accepted only in a channel that expects an f32 NaN, and only when vk_harness reports driver: KosmicKrisp. Finite channels and other drivers stay exact. The Known problems row names the two fixtures.

Tested

Apple M3, macOS 26.5.1, test programs built from this branch:

ps_cndmask_sign_mods ps_valu16_mad_sel ps_nan_payload
MoltenVK 1.4.2 PASS, exact PASS, exact PASS
KosmicKrisp (Mesa 26.3.1) FAIL on main, PASS ("exact but for KosmicKrisp's canonical NaN") same PASS
llvmpipe (Mesa 26.3.1) PASS, exact PASS, exact PASS
  • Full run_gpu_tests.py on all three: no new failure. KosmicKrisp's remaining ones are cs_bvh / cs_bvh32 (#1212) and cs_imgatomic_ext (#1518).
  • check.py (with #1444 applied locally so build.py runs): the same two pass on KosmicKrisp.
  • New unit tests in tests/test_shader_checks.py (KosmicKrispCanonicalNaN): canonical NaN accepted on KosmicKrisp only, only that word, only in a NaN channel.
  • Not covered: cs_fmt_all on KosmicKrisp. Its two mismatches (word 293, an f16 sNaN stored quiet, and word 312, an 11/11/10 float with a changed finite G) aren't this canonicalization, so they stay a finding.

GPUs tested: Apple M3 (10-core GPU) with MoltenVK 1.4.2, KosmicKrisp (Mesa 26.3.1) and llvmpipe (Mesa 26.3.1), macOS 26.5.1

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • No translator rule.

🤖 Generated with Claude Code

**@⁠Tauwni** on GitHub · 2026-11-25 21:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2110) `Tauwni:fix/kosmickrisp-nan-canonicalization` → `main` · +62 −6 · 4 files · 1 commits · closed without merging Claimed in the coordination issue as: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ### What and why KosmicKrisp (Mesa 26.3.1) writes any f32 NaN to an RGBA32F attachment as `0x7fc00000`. That is the measured row in `docs/testing.md`, and until now only `ps_nan_payload` allowed it. So `ps_cndmask_sign_mods` and `ps_valu16_mad_sel`, which expect non-canonical NaN words (`0xff800001`, `0x7f800001`, `0xffffffff`), failed every pixel on KosmicKrisp while passing on MoltenVK and llvmpipe (the finding in #1608). The same rule now covers every exact-word pixel test, in `check.py` and in `run_gpu_tests.py` (`check_pixel_const`): the canonical word is accepted only in a channel that expects an f32 NaN, and only when `vk_harness` reports `driver: KosmicKrisp`. Finite channels and other drivers stay exact. The Known problems row names the two fixtures. ### Tested Apple M3, macOS 26.5.1, test programs built from this branch: | | `ps_cndmask_sign_mods` | `ps_valu16_mad_sel` | `ps_nan_payload` | |---|---|---|---| | MoltenVK 1.4.2 | PASS, exact | PASS, exact | PASS | | KosmicKrisp (Mesa 26.3.1) | FAIL on `main`, PASS ("exact but for KosmicKrisp's canonical NaN") | same | PASS | | llvmpipe (Mesa 26.3.1) | PASS, exact | PASS, exact | PASS | - Full `run_gpu_tests.py` on all three: no new failure. KosmicKrisp's remaining ones are `cs_bvh` / `cs_bvh32` (#1212) and `cs_imgatomic_ext` (#1518). - `check.py` (with #1444 applied locally so `build.py` runs): the same two pass on KosmicKrisp. - New unit tests in `tests/test_shader_checks.py` (`KosmicKrispCanonicalNaN`): canonical NaN accepted on KosmicKrisp only, only that word, only in a NaN channel. - Not covered: `cs_fmt_all` on KosmicKrisp. Its two mismatches (word 293, an f16 sNaN stored quiet, and word 312, an 11/11/10 float with a changed finite G) aren't this canonicalization, so they stay a finding. GPUs tested: Apple M3 (10-core GPU) with MoltenVK 1.4.2, KosmicKrisp (Mesa 26.3.1) and llvmpipe (Mesa 26.3.1), macOS 26.5.1 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] No translator rule. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KosmicKrisp writes any f32 NaN to an RGBA32F attachment as 0x7fc00000 (the
measured row in docs/testing.md), which only ps_nan_payload allowed, so
ps_cndmask_sign_mods and ps_valu16_mad_sel failed every pixel there. The same
rule (that word, a NaN channel, "driver: KosmicKrisp") now covers every
exact-word pixel test in both runners; other drivers stay exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:18:14 +00:00
github-bot closed this pull request 2026-11-26 11:27:36 +00:00
Author
Owner

@⁠Tauwni on GitHub · 2026-11-26 10:56 UTC · original

Closing this one. Since I opened it, I found the cause: emit_src_component in Mesa's src/kosmickrisp/compiler/msl_type_inference.c prints every float-typed NaN constant as (NAN). It is a driver bug, so making the exact-word checks accept the canonical word on KosmicKrisp would hide it. That also goes against the "do not weaken the expected words" rule of the cs_bvh row.

#2229 documents these fixtures (ps_cndmask_sign_mods, ps_valu16_mad_sel, and cs_fmt_all word 293) as expected failures on KosmicKrisp, the same way the cs_bvh row does. A KosmicKrisp 26.3.1 built locally with that line printing the NaN's bits instead passes all of them.

AI-assisted (Claude Code).

**@⁠Tauwni** on GitHub · 2026-11-26 10:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2110#issuecomment-7190037965) Closing this one. Since I opened it, I found the cause: `emit_src_component` in Mesa's `src/kosmickrisp/compiler/msl_type_inference.c` prints every float-typed NaN constant as `(NAN)`. It is a driver bug, so making the exact-word checks accept the canonical word on KosmicKrisp would hide it. That also goes against the "do not weaken the expected words" rule of the `cs_bvh` row. #2229 documents these fixtures (`ps_cndmask_sign_mods`, `ps_valu16_mad_sel`, and `cs_fmt_all` word 293) as expected failures on KosmicKrisp, the same way the `cs_bvh` row does. A KosmicKrisp 26.3.1 built locally with that line printing the NaN's bits instead passes all of them. AI-assisted (Claude Code).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.