[PR #2178] macOS: through the Vulkan loader, the test tools opt in to portability enumeration; validation runs on MoltenVK (TEST-MAC-LOADER-PORTABILITY) #2181

Open
opened 2026-11-26 21:20:19 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2178
Author: @Tauwni
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/mac-loader-portability-enumeration


📝 Commits (4)

  • dfad849 macOS: through the Vulkan loader, the test tools opt in to portability enumeration, so MoltenVK is found
  • de37175 docs/testing.md: the three validation messages MoltenVK 1.4.2 reports that are not failures, and the filter
  • 000258e docs/testing.md: link the MoltenVK issue for its vkGetDescriptorSetLayoutSupport count
  • 5b835b6 Merge main into fix/mac-loader-portability-enumeration

📊 Changes

4 files changed (+190 additions, -2 deletions)

View changed files

📝 docs/testing.md (+16 -1)
📝 runtime/test/vulkan_loader.h (+100 -1)
📝 tests/test_vk_subgroup_info.py (+38 -0)
📝 tools/vk_subgroup_info.py (+36 -0)

📄 Description

Claimed in the coordination issue as: TEST-MAC-LOADER-PORTABILITY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7180966128)

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=1 is LEONIDA_VULKAN_LOADER, the standard loader. But behind the loader, MoltenVK is a portability driver:

  • the loader lists it only for an instance created with VK_KHR_portability_enumeration and VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
  • a device it exposes must enable VK_KHR_portability_subset.

None of the tools asked for either, so through the loader they found no device:

vkCreateInstance: Found drivers that contain devices which support the portability subset, but the instance does not enumerate portability drivers!

tools/vk_subgroup_info.py returned vkCreateInstance failed (-9) instead, so run_gpu_tests.py lost the probes it reads (per_vertex_inputs, among others). In practice, validation couldn't run on MoltenVK.

  • runtime/test/vulkan_loader.h: when LEONIDA_VULKAN_LOADER is set on macOS, load_vulkan() returns a vkGetInstanceProcAddr wrapper. It wraps vkCreateInstance, adding the extension and its flag where the loader offers them, and vkCreateDevice, adding VK_KHR_portability_subset where the device offers it. Everything else goes to the loader unchanged. Every tool gets this from load_vulkan(), so no tool changes.
  • tools/vk_subgroup_info.py: the same instance opt-in, plus 2 unit tests.
  • Direct MoltenVK, the default, is unchanged, and so are other platforms.
  • docs/testing.md: how to run with validation on a Mac.

Tested

Apple M3, macOS 26.5.1, main ad41fd517 + this commit, Vulkan loader 1.4.363 and validation layers from Homebrew:

  • MoltenVK through the loader: run_gpu_tests.py 193/268. That's the same failures as direct MoltenVK on main (cs_fma_fused, cs_imgatomic_ext, ps_ssharp, ps_array_resinfo, ps_get_lod_array), with open fixes in #1724, #1518, #1774 and #2169. ctest 106/106 both ways.
  • KosmicKrisp and llvmpipe through the loader: unchanged (same results as on main).
  • tests/test_vk_subgroup_info.py (57 tests), test_make_game_translator_flags.py, test_make_game_wave64.py and the docs tests: OK.

What validation reports on MoltenVK, now that it can run (the runtime is unchanged; docs/testing.md now lists these and the filter, see the update below):

  • Nearly every translated shader: VUID-RuntimeSpirv-shaderDenormPreserveFloat16-06296. That is the documented DenormPreserve 16 trade-off (design.md, "Float controls (f16 denormals)"): MoltenVK reports shaderDenormPreserveFloat16 false.
  • vk_bindless_grow, vk_null_descriptor, vk_bindless_test: VUID-vkCreateDescriptorSetLayout-support-09582. The bindless set layout has 11777 descriptors, against MoltenVK's maxPerSetDescriptors of 1212, and vkGetDescriptorSetLayoutSupport answers false for it. size_bindings keeps 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, then main merged): docs/testing.md lists the three validation messages MoltenVK 1.4.2 reports that are not test failures, plus the VK_LAYER_MESSAGE_ID_FILTER that hides them:

  • 06296 and VUID-VkShaderModuleCreateInfo-pCode-08740: the DenormPreserve 16 trade-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_test and vk_null_descriptor_test pass under validation. So does the whole run_gpu_tests.py suite at main a73a57e13 (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

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

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2178 **Author:** [@Tauwni](https://github.com/Tauwni) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/mac-loader-portability-enumeration` --- ### 📝 Commits (4) - [`dfad849`](https://github.com/ubiquitarianism/leonida/commit/dfad84913a3f00568cdcae55074aa3fe6714e546) macOS: through the Vulkan loader, the test tools opt in to portability enumeration, so MoltenVK is found - [`de37175`](https://github.com/ubiquitarianism/leonida/commit/de37175f503c1ed5083ebfabde5b81aa1881c07b) docs/testing.md: the three validation messages MoltenVK 1.4.2 reports that are not failures, and the filter - [`000258e`](https://github.com/ubiquitarianism/leonida/commit/000258e00583fe8e64db136662761f34baa8654c) docs/testing.md: link the MoltenVK issue for its vkGetDescriptorSetLayoutSupport count - [`5b835b6`](https://github.com/ubiquitarianism/leonida/commit/5b835b636e48e2abca36bda69878b0269ce6b144) Merge main into fix/mac-loader-portability-enumeration ### 📊 Changes **4 files changed** (+190 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/testing.md` (+16 -1) 📝 `runtime/test/vulkan_loader.h` (+100 -1) 📝 `tests/test_vk_subgroup_info.py` (+38 -0) 📝 `tools/vk_subgroup_info.py` (+36 -0) </details> ### 📄 Description Claimed in the coordination issue as: TEST-MAC-LOADER-PORTABILITY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7180966128) ### 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=1` is `LEONIDA_VULKAN_LOADER`, the standard loader. But behind the loader, MoltenVK is a portability driver: - the loader lists it only for an instance created with `VK_KHR_portability_enumeration` and `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR`; - a device it exposes must enable `VK_KHR_portability_subset`. None of the tools asked for either, so through the loader they found no device: ``` vkCreateInstance: Found drivers that contain devices which support the portability subset, but the instance does not enumerate portability drivers! ``` `tools/vk_subgroup_info.py` returned `vkCreateInstance failed (-9)` instead, so `run_gpu_tests.py` lost the probes it reads (`per_vertex_inputs`, among others). In practice, validation couldn't run on MoltenVK. - `runtime/test/vulkan_loader.h`: when `LEONIDA_VULKAN_LOADER` is set on macOS, `load_vulkan()` returns a `vkGetInstanceProcAddr` wrapper. It wraps `vkCreateInstance`, adding the extension and its flag where the loader offers them, and `vkCreateDevice`, adding `VK_KHR_portability_subset` where the device offers it. Everything else goes to the loader unchanged. Every tool gets this from `load_vulkan()`, so no tool changes. - `tools/vk_subgroup_info.py`: the same instance opt-in, plus 2 unit tests. - Direct MoltenVK, the default, is unchanged, and so are other platforms. - `docs/testing.md`: how to run with validation on a Mac. ### Tested Apple M3, macOS 26.5.1, `main` `ad41fd517` + this commit, Vulkan loader 1.4.363 and validation layers from Homebrew: - MoltenVK through the loader: `run_gpu_tests.py` 193/268. That's the same failures as direct MoltenVK on `main` (`cs_fma_fused`, `cs_imgatomic_ext`, `ps_ssharp`, `ps_array_resinfo`, `ps_get_lod_array`), with open fixes in #1724, #1518, #1774 and #2169. ctest 106/106 both ways. - KosmicKrisp and llvmpipe through the loader: unchanged (same results as on `main`). - `tests/test_vk_subgroup_info.py` (57 tests), `test_make_game_translator_flags.py`, `test_make_game_wave64.py` and the docs tests: OK. What validation reports on MoltenVK, now that it can run (the runtime is unchanged; `docs/testing.md` now lists these and the filter, see the update below): - Nearly every translated shader: `VUID-RuntimeSpirv-shaderDenormPreserveFloat16-06296`. That is the documented `DenormPreserve 16` trade-off (design.md, "Float controls (f16 denormals)"): MoltenVK reports `shaderDenormPreserveFloat16` false. - `vk_bindless_grow`, `vk_null_descriptor`, `vk_bindless_test`: `VUID-vkCreateDescriptorSetLayout-support-09582`. The bindless set layout has 11777 descriptors, against MoltenVK's `maxPerSetDescriptors` of 1212, and `vkGetDescriptorSetLayoutSupport` answers false for it. `size_bindings` keeps 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`, then `main` merged):** `docs/testing.md` lists the three validation messages MoltenVK 1.4.2 reports that are not test failures, plus the `VK_LAYER_MESSAGE_ID_FILTER` that hides them: - `06296` and `VUID-VkShaderModuleCreateInfo-pCode-08740`: the `DenormPreserve 16` trade-off; - `09582`: MoltenVK's own count, `4 × (31 + 256 + 16) = 1212`, which ignores argument buffers ([KhronosGroup/MoltenVK#2573](https://github.com/KhronosGroup/MoltenVK/issues/2573)). With the filter, `vk_bindless_test`, `vk_bindless_grow_test` and `vk_null_descriptor_test` pass under validation. So does the whole `run_gpu_tests.py` suite at `main` `a73a57e13` (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 - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2181
No description provided.