Repository navigation
Description
Re-filed from the old #9786 (listed in #18): that repository went private. Re-verified on this repository's main d42773d07; runtime/test/vk_bindless_test.cpp and runtime/test/shaders/ps_imgatomic.asm are identical to the old tree, so the measurements carry over.
What happens. runtime/test/vk_bindless_test in its ps_imgatomic mode fails intermittently on MoltenVK 1.4.2 on an Apple M5 Pro: 1 to 5 of the 256 checked texels come back wrong, always with fewer updates than expected (lost atomics), while the render-target check stays exact (0 of 4096 pixels). The same SPIR-V and the same binary pass every time through KosmicKrisp (Mesa).
GPU: Apple M5 Pro (16-core GPU, Metal 4)
Driver: MoltenVK 1.4.2 (Homebrew bottle), Vulkan 1.4.357
KosmicKrisp (Mesa 26.3.1, Homebrew), Vulkan 1.4.363, through vulkan-loader 1.4.363
Subgroup: 4..32 (MoltenVK), 32..32 (KosmicKrisp)
OS: macOS 26.7.3 (25G342), arm64
Commit: main d42773d07
Tools: llvm-mc 23.1.6 (Homebrew), SPIRV-Tools v2026.4, Apple clang 21.0.0, CMake 4.5.1
Reproduce:
python3 -I runtime/test/shaders/build.py <out> vs_ids ps_imgatomic
# MoltenVK, loaded directly by the test program (the default):
for i in $(seq 1 20); do runtime/build/linux/vk_bindless_test <out>/spirv/vs_ids.spv <out>/spirv/ps_imgatomic.spv; done
# KosmicKrisp:
LEONIDA_VULKAN_LOADER=$(brew --prefix)/lib/libvulkan.1.dylib \
VK_DRIVER_FILES=$(brew --prefix)/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json \
runtime/build/linux/vk_bindless_test <out>/spirv/vs_ids.spv <out>/spirv/ps_imgatomic.spv- MoltenVK: 9 pass, 11 fail in 20 runs at
d42773d07. At the oldmainit was 11 pass / 9 fail in 20 runs at two commits (152 commits apart), and earlier sessions on the same machine gave 1/5, 3/10, 4/8, 6/10 and 9/12 failures, so roughly half. - KosmicKrisp: 10/10 pass, 0 texels wrong, at both the old and the current tree.
Examples printed by the test on a failing run, all consistent with one or a few atomic updates not landing:
2D umax texel 15: got 0x000002ff, want 0x000003ff
2D or texel 7: got 0x00000000, want 0xff000000
2D umin texel 5: got 0x00000128, want 0x00000028
3D umax texel 12: got 0x00000fc4, want 0x00000fcc
What I ruled out:
- The module is atomic, not a read-modify-write:
spirv-disshows fourOpImageTexelPointerwithOpAtomicUMax,OpAtomicUMinandOpAtomicOr. - The test's synchronization: the same binary passes 10/10 on KosmicKrisp, and the render-target readback is exact in every failing run.
- The MoltenVK install: the formula was re-poured from the Homebrew bottle (
brew reinstall molten-vk) and the runs repeated; the picture is unchanged. - Metal API validation:
MTL_DEBUG_LAYER=1reports no validation errors or hazards, and the intermittent wrong texels remain.
In the full suite on the old tree: run_gpu_tests.py 182/244 passed, 60 skipped, 2 failed (cs_fma_fused, the known MoltenVK 1.4.2 row, and ps_imgatomic); with LEONIDA_W64_EMULATE=1, 213/244 passed, 30 skipped, 1 failed (cs_fma_fused only), so ps_imgatomic is a flake and not a translation difference.
Question: does ps_imgatomic reproduce on other Apple GPUs or on MoltenVK main? If it is MoltenVK-side, the macOS CI job's EXPECTED_FAILURES (today ps_ssharp and cs_fma_fused) would need this one too, because a suite run reaches it about half the time.
AI-assisted run; synthetic fixtures only, no game data.
Activity
GeorgiyDemo commentedon Nov 24, 2026
Two extra series on the same machine (
maind42773d07, MoltenVK 1.4.2, 20 runs each, same binary and SPIR-V):MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=1MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1So it is not the submission path or the descriptor path: serializing submissions and switching to Metal argument buffers leave the rate where it is. Together with
MTL_DEBUG_LAYER=1reporting nothing and the same module passing 10/10 on KosmicKrisp, that points at the shader-level atomic path in MoltenVK rather than at the test's synchronization.AI-assisted; synthetic fixtures only, no game data.
hugo0024 commentedon Nov 24, 2026
It reproduces on a second Apple chip: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1,
maind0da7dade, 101 of 150 single runs fail. What that run narrowed down, with the numbers in #860: MoltenVK lowers the four atomics to Metal's texture atomics; it fails as often with the descriptor index used directly instead of the first-lane broadcast (54 of 60) and with the image copies in a submission of their own after the draw (42 of 60); and a wrongumaxorumintexel always holds the max or min of only some of its own 64 pixels. AI-assisted; synthetic fixtures only.docs/testing.md: Known problems row for ps_imgatomic on MoltenVK 1.4.…
EvgHaze commentedon Nov 25, 2026
A third Apple chip says this one is not MoltenVK-wide — it does not reproduce on an M3 at all.
0 of 256 texels wrongand0 of 4096 render-target pixels wrongin every runSo the numbers now are: M5 Pro 11 of 20 fail, M5 101 of 150 fail (from the comments above), M3 0 of 30. That is not a random flake that a different machine sometimes shows — it looks bounded by the GPU generation, and if so the useful next step is a boundary rather than another reproduction:
supportsFamily:forMTLGPUFamilyApple*) and whether Metal 4's texture atomics are in use at all, because the lowering named in docs/testing.md: Known problems row for ps_imgatomic on MoltenVK 1.4.2 (DOC-IMGATOMIC-MVK) #860 is the one path that changes between these generations.I can run an M4 check too if one is reachable; on this hardware there is nothing to reproduce, so what I can offer is the negative datapoint, which is what rules out "MoltenVK 1.4.2 loses atomics on every Apple GPU".
AI-assisted. No game data: the fixtures are hand-written and every number above is test output.
gpu-test-results: Apple M6 on MoltenVK 1.4.2 (macOS 27.0) at 9e7720c …