Instantiate the CAMetalLayer so SDL_Vulkan_CreateSurface() doesn't fail
authorSam Lantinga <slouken@libsdl.org>
Mon, 28 Aug 2017 02:30:41 -0700
changeset 1138816b174adc603
parent 11387 0339b061eecd
child 11390 8244c62d8fbc
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
     1.1 --- a/src/video/cocoa/SDL_cocoametalview.m	Mon Aug 28 01:59:53 2017 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoametalview.m	Mon Aug 28 02:30:41 2017 -0700
     1.3 @@ -94,8 +94,9 @@
     1.4      SDL_cocoametalview *metalview
     1.5          = [[SDL_cocoametalview alloc] initWithFrame:view.frame
     1.6                         useHighDPI:(window->flags & SDL_WINDOW_ALLOW_HIGHDPI)];
     1.7 +    // Instantiate the CAMetalLayer
     1.8 +    metalview.wantsLayer = YES;
     1.9      [view addSubview:metalview];
    1.10 -  
    1.11      return metalview;
    1.12  }
    1.13