Skip to content

docs/testing: ps_cndmask_sign_mods and ps_valu16_mad_sel on KosmicKrisp are the (NAN) constant printer - #7680

Closed
Conrage wants to merge 1 commit into
ProjectLeonida:mainfrom
Conrage:fix-kk-nan-constant-docs
Closed

Conrage wants to merge 1 commit into
ProjectLeonida:mainfrom
Conrage:fix-kk-nan-constant-docs

Conversation

@Conrage

@Conrage Conrage commented Nov 23, 2026

Copy link
Copy Markdown

Claimed in the coordination issue as: #7599 (comment)

What and why

On KosmicKrisp, ps_cndmask_sign_mods and ps_valu16_mad_sel fail, and docs/testing.md doesn't say why. The cause is the same nir_to_msl constant printer as #3125 and #6623, not the translator.

Measured on an Apple M5 (Mesa 26.3.1), with each test run alone through vk_harness. All 4096 pixels give the same words:

test want KosmicKrisp MoltenVK 1.4.2
ps_cndmask_sign_mods ff800001 7f800001 80000001 7f800001 7fc00000 7fc00000 80000001 7fc00000 exact
ps_valu16_mad_sel 00008003 db880000 ffffffff 80000000 00008003 db880000 7fc00000 80000000 exact

Both shaders take only constant inputs, so NIR folds each export to a single float4 constant. MESA_KK_DEBUG=msl shows every NaN component printed as (NAN), while denormals and -0.0 print correctly:

  • float4((NAN), (NAN), float(-1.40129846432481707e-45), (NAN))
  • float4(float(4.59e-41), float(-7.66e+16), (NAN), float(-0.0))

The RGBA32F attachment itself keeps NaN payloads. When each exported word is ORed with ud0 >> 31, which is 0 at run time but can't be folded, KosmicKrisp writes the expected words for both tests. It does the same for ps_nan_payload (#3125), which returns 7fc12345 ffc54321 3f800000 3f000000, the same as MoltenVK.

This PR:

The fix belongs in Mesa: print a float NaN constant by its bits, as as_type<float>(0x...u). A translator workaround would have to stop constant folding on every pixel-shader export, so this PR doesn't change any test expectations.

Tested

Docs only. pytest tests/test_docs_*.py: 33 passed and 3 failed, the same 3 as on main (test_docs_cli_flags x2 and test_docs_links). The GPU measurements above are from an Apple M5 with KosmicKrisp (Mesa 26.3.1) and MoltenVK 1.4.2, no game files.

Related: #7595 works around the cs_bvh case in the translator.

AI-assisted: yes

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. (No translator change.)

…sp are the (NAN) constant printer

On KosmicKrisp (Mesa 26.3.1, Apple M5) both tests read 0x7fc00000 for their
NaN-pattern words. Their exports fold to one float4 constant and nir_to_msl
prints every NaN component as (NAN); denormals and -0.0 print correctly and
MoltenVK 1.4.2 is exact. Add a known-problems row for them, and note on the
ps_nan_payload row that the RGBA32F attachment keeps payloads when the words
are run-time values: only NaNs NIR folds into a constant are lost.

AI-assisted: yes
@morodirule

Copy link
Copy Markdown

Tested d95bf04 on Arch Linux, Python 3.14.10, CPU only: pass — docs design/table/list/repeated rows suites OK (5+2+3+2). test_docs_links 6/7: the 2 failures (dev-tools fence anchor, gpu-results missing file) exist identically at HEAD~1 and name files this docs-only diff doesn't touch — pre-existing, unrelated. No game files. AI-assisted.

@lucasmartin042009-sudo

Copy link
Copy Markdown

Tested d95bf04 on Apple M3 Pro, macOS 27.2.1 (26B131), KosmicKrisp (Mesa 26.3.1, Homebrew) and MoltenVK 1.4.2. vk_harness reports driver: KosmicKrisp / driver: MoltenVK.

Confirmed: with KosmicKrisp, ps_cndmask_sign_mods fails 4096/4096 with 7fc00000 7fc00000 80000001 7fc00000, and ps_valu16_mad_sel fails 4096/4096 with z=7fc00000 (want ffffffff), other words exact. Both pass 4096/4096 exact with MoltenVK 1.4.2. MESA_KK_DEBUG=msl shows (NAN) for the NaN components while denormals and -0.0 print correctly. ps_nan_payload passes.

Differs: none (M3 Pro here, M5 in the description).

Not tested: the run-time-value (ud0 >> 31) experiment, the Mesa fix, pytest tests/test_docs_*.py.

Full suite with KosmicKrisp for reference: 174/241 passed, 63 skipped, 4 failed (cs_bvh, cs_bvh32 and the two tests above).

No game files. AI-assisted: yes (Claude Code).

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.

5 participants