Repository navigation
macOS: through the Vulkan loader, the test tools opt in to portability enumeration; validation runs on MoltenVK (TEST-MAC-LOADER-PORTABILITY) - #2178
Conversation
…y enumeration, so MoltenVK is found With LEONIDA_VULKAN_LOADER (the only way to reach VK_LAYER_KHRONOS_validation on a Mac) the loader lists MoltenVK only for an instance created with VK_KHR_portability_enumeration and its flag, and a device it exposes must enable VK_KHR_portability_subset. runtime/test/vulkan_loader.h now wraps vkCreateInstance / vkCreateDevice to add both where offered; tools/vk_subgroup_info.py opts in the same way. Direct MoltenVK is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… that are not failures, and the filter VUID-09582 is MoltenVK's own conservative count: vkGetDescriptorSetLayoutSupport compares the set with maxPerSetDescriptors = 4 x (31 + 256 + 16) = 1212, its per-stage counts without argument buffers. With the filter, vk_bindless_test (ps_tex), vk_bindless_grow_test and vk_null_descriptor_test pass under validation on an Apple M3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update at
With the filter on an Apple M3, under
AI-assisted (Claude Code). |
…youtSupport count Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I ran the whole GPU suite under validation, using this branch merged onto Result: 195/268 passed, 70 skipped. The three failures are the ones the suite also has without validation: AI-assisted (Claude Code). No game data. |
wavehs
left a comment
There was a problem hiding this comment.
macOS arm64 check of #2178 (TEST-MAC-LOADER-PORTABILITY). This one is squarely on my platform: portability enumeration through libvulkan with both Mac drivers, on the C++ tools and on tools/vk_subgroup_info.py.
Tested head 5b835b636 merged onto main bdbc7e923 as merge 50a9c7f5b (clean, no conflicts).
Environment: Apple M3 Pro arm64, macOS 27.2.1, Apple clang 21.0.0, CMake 4.5.0, CPython 3.15.2, Vulkan-Headers 1.4.363.0, MoltenVK 1.4.0 (ICD at /opt/homebrew/etc/vulkan/icd.d/MoltenVK_icd.json), KosmicKrisp = Mesa 26.3.0, loader /opt/homebrew/lib/libvulkan.1.dylib.
The fix does what it says on both paths
- C++ tool through the loader, MoltenVK ICD:
vk_compute_test cs_bounds.spv 1 dumpprintsdevice: Apple M3 Pro (subgroup 4..32)and1 groups x 64: 0 mismatcheswith the expected eight words. Before the change the same command cannot even create the instance (see NC 1). - Same tool through the loader with the KosmicKrisp ICD (
VK_ICD_FILENAMES=.../kosmickrisp_mesa_icd.aarch64.json): still runs and reports 0 mismatches, so the new wrapper does not disturb the non-portability Mac driver. - Through the loader with no
VK_DRIVER_FILESat all, MoltenVK is still found (the loader's default ICD directory), so the documentedVK_DRIVER_FILESis a way to pin the driver, not a requirement. tools/vk_subgroup_info.pythrough the loader now prints the MoltenVK device JSON ("device": "Apple M3 Pro",per_vertex_inputs: false, ...) instead of failing.python -I tests/test_vk_subgroup_info.py: 57 tests OK, including the two newPortabilityEnumerationTestcases (extension offered + loader env, and neither/no Darwin/platform guard).
Negative controls
- C++: revert only
runtime/test/vulkan_loader.h, rebuildvk_compute_test, same command through the loader with MoltenVK:FAILED vkCreateInstance(&ici, nullptr, &inst) -> -9 (line 232)-VK_ERROR_INCOMPATIBLE_DRIVER, the loader refusing to hand out a portability-only ICD to an instance that did not opt in. - Python: revert only
tools/vk_subgroup_info.py, same env:{"error": "RuntimeError: vkCreateInstance failed (-9)"}. Restored.
What I could not verify: the validation-layer half of the docs change
docs/testing.md also documents LEONIDA_VK_VALIDATION=1 on MoltenVK, the VK_LAYER_PATH/DYLD_FALLBACK_LIBRARY_PATH setup, and three VUIDs to filter. vulkan-validationlayers is not installed here (/opt/homebrew/opt/vulkan-validationlayers does not exist), so none of that is tested in this review: the layer messages, their IDs and the per-test effects are taken from the PR, not reproduced. The portability-enumeration mechanism that the layer needs in order to see MoltenVK at all is verified above.
Nits
std::vector<const char*> names(info->ppEnabledExtensionNames, info->ppEnabledExtensionNames + info->enabledExtensionCount)(runtime/test/vulkan_loader.h, bothcreate_instanceandcreate_device) forms an iterator pair from a null pointer when the count is 0, which is technically undefined behaviour even though libc++/libstdc++ produce an empty vector. The tools here pass at least one extension in practice, but acount ? ... : nullptrguard (or assigning only when non-zero) costs nothing and keeps UBSan quiet on a future tool.last_instance()is a single global written by everycreate_instanceand read bycreate_device. All the test tools create one instance, so this is fine today; if one ever creates two and then a device on the first, the wrapper fetchesvkCreateDevice/vkEnumerateDeviceExtensionPropertiesthrough the wrong instance handle. The function pointers are the same across instances in the loader, so it would still work, but a comment saying "one instance per tool" would record the assumption.- The instance wrapper turns portability enumeration on whenever the loader offers the extension, even if the tool's own
VkInstanceCreateInfodid not ask for it - that is the point of the change, and the extension is only added when offered, so a non-portability loader/driver sees no difference.
Not run: the validation layer (above), Windows/Linux loader paths (the wrapper is #ifdef __APPLE__), and the full GPU suite (only cs_bounds and the subgroup-info probe were run through the loader; the direct-MoltenVK path every earlier run used is untouched by this PR).
python -I scripts/check_no_game_data.py on the four changed files: clean.
No game files. AI-assisted.
… one-instance assumption written down From wavehs's review: copy ppEnabledExtensionNames only when the count is not 0, and say why last_instance() is enough for the test tools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@wavehs thanks for the thorough review and the negative controls. Both nits are in
Rerun on the Apple M3 (macOS 26.5.1) with test programs rebuilt from this head. On the validation half you couldn't check: I ran the whole suite under the layer on this machine (195/268, the same three failures as without it; my comment above has the details). AI-assisted (Claude Code). |
Claimed in the coordination issue as: TEST-MAC-LOADER-PORTABILITY (#1608 (comment))
What and why
On a Mac, the test tools open MoltenVK directly, which can't load layers. The way to run with
LEONIDA_VK_VALIDATION=1isLEONIDA_VULKAN_LOADER, the standard loader. But behind the loader, MoltenVK is a portability driver:VK_KHR_portability_enumerationandVK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;VK_KHR_portability_subset.None of the tools asked for either, so through the loader they found no device:
tools/vk_subgroup_info.pyreturnedvkCreateInstance failed (-9)instead, sorun_gpu_tests.pylost the probes it reads (per_vertex_inputs, among others). In practice, validation couldn't run on MoltenVK.runtime/test/vulkan_loader.h: whenLEONIDA_VULKAN_LOADERis set on macOS,load_vulkan()returns avkGetInstanceProcAddrwrapper. It wrapsvkCreateInstance, adding the extension and its flag where the loader offers them, andvkCreateDevice, addingVK_KHR_portability_subsetwhere the device offers it. Everything else goes to the loader unchanged. Every tool gets this fromload_vulkan(), so no tool changes.tools/vk_subgroup_info.py: the same instance opt-in, plus 2 unit tests.docs/testing.md: how to run with validation on a Mac.Tested
Apple M3, macOS 26.5.1,
mainad41fd517+ this commit, Vulkan loader 1.4.363 and validation layers from Homebrew:run_gpu_tests.py193/268. That's the same failures as direct MoltenVK onmain(cs_fma_fused,cs_imgatomic_ext,ps_ssharp,ps_array_resinfo,ps_get_lod_array), with open fixes in tests: cs_fma_fused takes its f16 operands at run time, like its f32 ones (TEST-FMA-FUSED-F16-RUNTIME) #1724, cs_imgatomic_ext: use the volume T# key vk_store_test now expects (GPU-IMG-ATOMIC-EXT-VOLUME-TAG) #1518, rdna2spirv: --explicit-lod-bias applies the S# LOD bias where MoltenVK drops the sampler's; ps_ssharp passes on Macs (SHADER-EXPLICIT-LOD-BIAS-MVK) #1774 and vk_texture_test: tag index 1 as bound in both sampled arrays it fills; ps_array_resinfo and ps_get_lod_array pass again (TEST-TEXTURE-ARRAY-KIND) #2169. ctest 106/106 both ways.main).tests/test_vk_subgroup_info.py(57 tests),test_make_game_translator_flags.py,test_make_game_wave64.pyand the docs tests: OK.What validation reports on MoltenVK, now that it can run (the runtime is unchanged;
docs/testing.mdnow lists these and the filter, see the update below):VUID-RuntimeSpirv-shaderDenormPreserveFloat16-06296. That is the documentedDenormPreserve 16trade-off (design.md, "Float controls (f16 denormals)"): MoltenVK reportsshaderDenormPreserveFloat16false.vk_bindless_grow,vk_null_descriptor,vk_bindless_test:VUID-vkCreateDescriptorSetLayout-support-09582. The bindless set layout has 11777 descriptors, against MoltenVK'smaxPerSetDescriptorsof 1212, andvkGetDescriptorSetLayoutSupportanswers false for it.size_bindingskeeps the default counts above that limit on purpose ("it never shrinks step 1"). The draws pass, but the layout is outside the spec on MoltenVK.Update (
de37175f5,000258e00, thenmainmerged):docs/testing.mdlists the three validation messages MoltenVK 1.4.2 reports that are not test failures, plus theVK_LAYER_MESSAGE_ID_FILTERthat hides them:06296andVUID-VkShaderModuleCreateInfo-pCode-08740: theDenormPreserve 16trade-off;09582: MoltenVK's own count,4 × (31 + 256 + 16) = 1212, which ignores argument buffers (KhronosGroup/MoltenVK#2573).With the filter,
vk_bindless_test,vk_bindless_grow_testandvk_null_descriptor_testpass under validation. So does the wholerun_gpu_tests.pysuite atmaina73a57e13(195/268, the same three failures as without validation).GPUs tested: Apple M3 (10-core GPU), MoltenVK 1.4.2 and KosmicKrisp (Mesa 26.3.1), macOS 26.5.1 (25F80); llvmpipe (Mesa 26.3.1)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly.🤖 Generated with Claude Code