From 959ae9019d36ae88a16aa01829ea7d122d249696 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 28 Aug 2017 02:30:41 -0700 Subject: [PATCH] Instantiate the CAMetalLayer so SDL_Vulkan_CreateSurface() doesn't fail Error message was: [mvk-info] MoltenVK version 0.18.2. Vulkan version 1.0.51. [***MoltenVK ERROR***] VK_ERROR_INITIALIZATION_FAILED: On-screen rendering requires a view that is backed by a layer of type CAMetalLayer. 2017-08-28 02:17:29.579 testvulkan[95627:1716939] ERROR: SDL_Vulkan_CreateSurface(): vkCreateMacOSSurfaceMVK failed: VK_ERROR_INITIALIZATION_FAILED --- src/video/cocoa/SDL_cocoametalview.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index 0fa6c195b14e8..5485588fbc6af 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -94,8 +94,9 @@ - (void)updateDrawableSize SDL_cocoametalview *metalview = [[SDL_cocoametalview alloc] initWithFrame:view.frame useHighDPI:(window->flags & SDL_WINDOW_ALLOW_HIGHDPI)]; + // Instantiate the CAMetalLayer + metalview.wantsLayer = YES; [view addSubview:metalview]; - return metalview; }