Repository navigation
Conversation
…image_bvh (ItsNotRexed#6623) KosmicKrisp (Mesa 26.3.1) types an OpSelect by the first concrete type that reaches it. In the image_bvh*_intersect_ray lowering the result words share registers with bitcast floats, so the box branch's 0xFFFFFFFF "no hit" select and canon()'s 0xFFC00000 select were typed float and their constants printed as the MSL literal (NAN), which Metal reads as 0x7FC00000. cs_bvh and cs_bvh32 returned 0x7fc00000 for the miss word. Build those two selects as (x & keep) | (k & pick) with keep/pick selects between two constants. Bitwise ops never take a float type in KosmicKrisp's inference, so the constants stay integers. The result words are the same on every driver. Tested on an Apple M5 (macOS): cs_bvh/cs_bvh32 0/2 -> 2/2 on KosmicKrisp and 2/2 -> 2/2 on MoltenVK 1.4.2; full run_gpu_tests.py unchanged otherwise on both; tests/semantic unchanged. AI-assisted: yes
|
I exercised the triangle On CachyOS / llvmpipe (LLVM 23.1.5), both For a negative control I changed only the triangle canonical constant in the translator to positive NVIDIA hardware retest: Compared parent Retail translation: I scanned all 26,503 ordinary listings and translated every listing containing either BVH intersection opcode on the same parent/head pair. All 64 are compute shaders. Both revisions translated and passed I also checked the separate 2,684-listing compute pipeline library. Its 64 opcode-bearing listings have exactly the same set of DXBC container hashes as the 64 above. With the library listings and their own sidecars, both revisions emitted modules for the same 25/64; all 25 validated and changed binary, with equal index entries. The other 39 produced no indexed module on either revision. The two extraction paths therefore have different baseline coverage and should not be added together as 128 distinct inputs. GPU execution above used the synthetic scenes. I ran the new three-payload fixture from |
|
Tested d657c88 merged with main dde82f2 on Linux/Python 3.12.16: concern Merge is clean (tools/rdna2spirv.py only, no test file). Nothing fails, but nothing in the repo's tests can tell this change from main, so I cannot call it a pass.
|
|
Independent NVIDIA Windows check for d657c88: PASS. Windows 11 Pro 10.0.26200, GeForce RTX 3080, NVIDIA 616.92, Vulkan 1.4.351, subgroup 32. Built this head's GPU test programs with MSVC 19.44 / RelWithDebInfo and used llvm-mc 23.1.6 and SPIRV-Tools 2026.4.
|
|
Tested
AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
|
One point the other checks here do not cover, then a pass on this hardware. The eight
Commands: No game files. AI-assisted. |
|
AI-assisted. No game files used. Adding AMD Windows results to @Kev-Ball's llvmpipe/NVIDIA comparison: The C++ test programs were built once from the parent, since the PR changes only I added @Kev-Ball's NaN-triangle scene to a local copy of
The NaN-scene runs retain the stock expected values in the harness, so they exit 1 with four mismatches even for the unmodified translators. The table compares raw readback words, not NaN-scene pass labels. To check that these runs observe the two constants the PR rewrites, I made four one-line translator mutants, each constant once in the parent and once in the PR:
For these modules/scenes, the old A NaN-scene test with its own expected values could pin that output constant. The SPIR-V-level check @kapitche suggests would serve a different purpose: pinning the workaround's generated form, since the unmodified parent and PR are expected to agree on this driver. Neither test is added here. Scope: synthetic scenes only, no KosmicKrisp/Metal run (the bug this fixes), no validation layer, and the NaN-scene change to |
|
Tested d657c88 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: fail on this RADV setup (regression vs main) Commands:
The PR targets KosmicKrisp NaN-pattern select typing (#6623); on this RADV Deck it causes the existing cs_bvh/cs_bvh32 GPU checks to fail. AI-assisted (OpenCode) |
|
@javdc I checked the eight decimal words from your Deck run against Could you run the same |
|
Tested GPU suite (full) — 223/240 passed, 16 skipped, 1 failed ( Two semantic files fail on this head: Counts and error classes only; no game data. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
|
Tested d657c88 merged with The earlier comments covered the GPU runs, the NaN-triangle scene on GPUs, and the selects that remain. I added a CPU-only check: hand-made NaN bit patterns run through the semantic interpreter, on What I ran:
Hand-made cases on the CPU interpreter (
The NaN triangle gives the same words as the llvmpipe and AMD runs above. Child indices with NaN bit patterns pass through the new Mutants, each in a copy of the PR's translator:
Two points from this:
Overlap: #7090 (a16 AI-assisted (Claude Code). |
… NaN words (ItsNotRexed#6623) Review on ItsNotRexed#7595: every NaN input in the BVH semantic tests was 0x7FC00000, so a usel_k that dropped its mask still passed. A payload NaN in v0.x catches it on the CPU. AI-assisted: yes
|
Thanks, everyone. Two follow-ups:
@javdc, all eight words in your Deck output match AI-assisted: yes Generated by Claude Code |
AI-assisted: yes
|
Follow-up on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073.
So on this RADV VANGOGH setup this is a real mismatch (not a validation-exit-only case): the PR changes the stock cs_bvh/cs_bvh32 output words compared to main. AI-assisted (OpenCode) |
|
@javdc Thanks for running both modules directly. The three differing words identify a baseline change: I checked the ancestry: The isolating Deck comparison is to rebuild the harness at |
|
Independent Windows recheck of ac665326 on an RTX 3080 Ti (driver 621.35, MSVC 19.44, Vulkan SDK 1.4.363.0). I built the harness and both shaders from this revision. All eight tests in |
|
Correction/follow-up on the same Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073. After fast-forwarding local
My earlier exit-1 report compared against a pre- AI-assisted (OpenCode) |
|
Windows + NVIDIA regression check of
Runtime built from each tree,
|
|
Tested
Windows 11 Pro 26300, MSVC 19.44, llvm-mc 21.1.8 (AMDGPU), SPIRV-Tools v2026.4. No game files. AI-assisted (Claude Code). |
|
Tested
Code read: No game files. AI-assisted (Claude). |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested Standalone tools built with llvm-mingw 20261117 (clang, Ninja, Release,
Both non-passing results are on main too, not caused by this PR: AI-assisted (Claude Code). |
|
Tested ac66532 on RTX 5070 Ti (Blackwell, subgroup 32), NVIDIA 621.01, Windows 11, applied on top of main dfe4e4a: pass, with one note on the new test. The patch applies cleanly. compileall on make_game.py, tools and tests is clean. tests/semantic/test_image_bvh_tri.py gives 8 tests OK, and all test_image_bvh_*.py give 17 tests OK. The full semantic suite gives 447 files, 5957 tests, 3 files failed: test_image_atomics_guard (47 failures), test_image_cube_store_glc (1 error, llvm-mc subprocess not found) and test_image_store_d16 (1 failure). The same three files fail with the same counts on pristine main, so none of them come from this PR. GPU suite: 247 shaders translated, 247 pass spirv-val. Native 192/241 passed, 48 skipped. Emulated (LEONIDA_W64_EMULATE=1) 223/241 passed, 17 skipped. cs_bvh and cs_bvh32 pass in both modes. The only failure is ms_wave_info_s3 in both modes, the known bug that other PRs fix. This is identical to the main baseline, so there is no regression. Note on the new test: I copied the new test_a_nan_with_a_payload_returns_the_canonical_nan into a clean copy of main and it also passes there (8 tests OK). It therefore guards the new usel_k helper against a future regression (a pass-through canon would fail it), but it does not detect the #6623 bug itself. That is expected, because the bug only appears in KosmicKrisp's MSL output and is invisible to the SPIR-V-level interpreter and to NVIDIA. The change reads correct to me: for k=0xFFFFFFFF, x | (c ? 0 : k) gives child when the box hits and 0xFFFFFFFF otherwise, and the canon path gives (x & ~m) | (k & m) with m taken from the NaN condition. I could not check the KosmicKrisp effect, and the contract table in docs/design.md does not need an entry because no instruction rule changed. AI-assisted (Claude Code): the checks above were run by Claude Code on a private copy of the PR diff; nothing was posted or pushed by the tool. |
Reviewed head: ac66532 Review: ItsNotRexed#7595 (comment) Board: ItsNotRexed#8919 AI-assisted integration.
…omputed word A translation-only check of the ProjectLeonida#6623 workaround's form: it fails on main's OpSelect form (8 such selects) and passes with usel_k, on any machine, unlike the GPU and interpreter runs that can't see the KosmicKrisp typing. AI-assisted: yes
|
Tested
This is Intel's proprietary driver, not KosmicKrisp/Mesa, so it doesn't reproduce #6623 either way; it checks that nothing regresses on a non-Mesa driver. AI-assisted (Claude Code); no game files. |
|
Reopened as #9868 (same change, rebased onto current main). Generated by Claude Code |
Claimed in the coordination issue as: #6623, in #7496 (#7496 (comment))
Depends on: nothing
Fixes #6623
What and why
On KosmicKrisp (Mesa 26.3.1, Vulkan on Metal),
cs_bvhandcs_bvh32return0x7fc00000where the miss word should be0xffffffff. The cause is in KosmicKrisp's type inference (src/kosmickrisp/compiler/msl_type_inference.c):OpSelectgets the first concrete type that reaches it.image_bvh*_intersect_raylowering, the result words share registers with bitcast floats from the triangle branch, so that type is float.(NAN), which Metal reads as0x7FC00000.This affects two selects. The
MESA_KK_DEBUG=msldump shows 16(NAN)literals incs_bvh:0xFFFFFFFF"no hit" index, which is what the test catches;canon()'s0xFFC00000NaN word in the triangle branch, which has the same bug.KosmicKrisp's bitwise ops never take a float type. When a float value reaches one, it inserts an
as_type<uint>cast. So this PR adds a local helper,usel_k(c, k, x), that buildsc ? k : xas(x & keep) | (k & pick), wherekeepandpickare selects between two constants. Fork = 0xFFFFFFFFthat is justx | pick. Only those two call sites change. The result words are the same on every driver, andspirv-valpasses.This is a workaround for KosmicKrisp; it doesn't fix it. The real fix belongs in Mesa's
nir_to_msl, either by printing float NaN constants asas_type<float>(0x...u)or by keeping shared registers typed uint. #6627's docs note still applies to older builds of the translator.Tested
Apple M5, macOS, Vulkan SDK with KosmicKrisp (Mesa 26.3.1) and MoltenVK 1.4.2, no game files. "Before" is upstream main and "after" is this branch:
run_gpu_tests.py --filter cs_bvh, KosmicKrispbvh out = 00000068 00000048 00000040 ffffffff | c1200000 bf800000 be800000 be800000, 0 mismatchesrun_gpu_tests.py --filter cs_bvh, MoltenVK(NAN)literals in the KosmicKrisp MSL ofcs_bvh/cs_bvh32run_gpu_tests.py, KosmicKrispcs_bvh/cs_bvh32changed)run_gpu_tests.py, MoltenVKscripts/run_semantic_tests.py tests/semanticpytest tests/test_*bvh*.pyFailures that are the same before and after, and that this PR doesn't touch:
ps_cndmask_sign_modsandps_valu16_mad_sel.cs_fma_fused.test_image_atomics_guardandtest_image_store_d16.tools/bvh_slot_check.py.On Linux (no GPU),
pytest tests/semantic/test_image_bvh_*.pygives 16 passed and 1610 subtests passed, both on main and on this branch.Not measured:
image_bvh*_intersect_ray, not which instructions translate.cs_bvhrun would be welcome.canon()'s NaN path. No GPU test here checks a NaN result word from a BVH triangle, so that half is verified only through the Metal dump.AI-assisted: yes
Checklist