Skip to content

Commit ea87b48

Browse files
committed
gfx/common/vulkan: force MVK_CONFIG_USE_MTLHEAP=0 on Apple to avoid placement-heap crash
MoltenVK 1.3.0 flipped MVK_CONFIG_USE_MTLHEAP to active by default for non-AMD GPUs, routing VkDeviceMemory through a placement MTLHeap. Placement heaps need macOS 13+ AND supportsPlacementHeaps; older Intel Macs satisfy neither and abort at swapchain-image allocation: -[MTLHeapDescriptorInternal validateWithDevice:]:335: failed assertion `Placement heap type is not supported.' Force the path off in vulkan_context_init() before the loader is opened, while still respecting an explicit user override. "0" is boolean-false on 1.2.x and MVK_CONFIG_USE_MTLHEAP_NEVER on 1.3.x, so the fix is version-agnostic. Fixes #18985.
1 parent 0c0eb03 commit ea87b48

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

gfx/common/vulkan_common.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,20 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
24982498
int use_mab = settings->bools.video_use_metal_arg_buffers;
24992499
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", use_mab ? "1" : "0", 1);
25002500
}
2501+
/* MoltenVK 1.3.0 flipped MVK_CONFIG_USE_MTLHEAP to active by default
2502+
* for all non-AMD GPUs, so VkDeviceMemory now allocates from a
2503+
* placement MTLHeap. Placement heaps require macOS 13+ and a GPU
2504+
* that reports supportsPlacementHeaps; older Intel Macs (Mac GPU
2505+
* family 2 on macOS 12 and earlier) abort at swapchain-image
2506+
* allocation time with:
2507+
* -[MTLHeapDescriptorInternal validateWithDevice:]:
2508+
* failed assertion `Placement heap type is not supported.'
2509+
* Force the path off here so the assertion can never fire. The
2510+
* value "0" is interpreted as boolean-false by 1.2.x and as the
2511+
* MVK_CONFIG_USE_MTLHEAP_NEVER enum value by 1.3.x, so it is
2512+
* forward- and backward-compatible. See libretro/RetroArch#18985. */
2513+
if (!getenv("MVK_CONFIG_USE_MTLHEAP"))
2514+
setenv("MVK_CONFIG_USE_MTLHEAP", "0", 1);
25012515
/* Try Vulkan loader first (enables validation layers if installed).
25022516
* Falls back to MoltenVK directly if loader not available. */
25032517
vulkan_library = dylib_load("libvulkan.dylib");

0 commit comments

Comments
 (0)