@ -431,6 +431,16 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
return YES ;
}
- ( BOOL ) wantsUpdateLayer
{
return YES ;
}
- ( id ) makeBackingLayer
{
return window - > ns . layer ;
}
- ( void ) cursorUpdate : ( NSEvent * ) event
{
updateCursorImage ( window ) ;
@ -1653,13 +1663,18 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
void _glfwPlatformGetRequiredInstanceExtensions ( char * * extensions )
{
if ( !_glfw . vk . KHR_surface || !_glfw . vk . MVK_macos_surface )
return ;
extensions [ 0 ] = "VK_KHR_surface ";
extensions [ 1 ] = "VK_MVK_macos_surface ";
}
int _glfwPlatformGetPhysicalDevicePresentationSupport ( VkInstance instance ,
VkPhysicalDevice device ,
uint32_t queuefamily )
{
return GLFW_FALS E ;
return GLFW_TRU E ;
}
VkResult _glfwPlatformCreateWindowSurface ( VkInstance instance ,
@ -1667,7 +1682,57 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
const VkAllocationCallbacks * allocator ,
VkSurfaceKHR * surface )
{
#if MAC_OS_X_VERSION_MAX_ALLOWED > = 101100
VkResult err ;
VkMacOSSurfaceCreateInfoMVK sci ;
PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK ;
vkCreateMacOSSurfaceMVK = ( PFN_vkCreateMacOSSurfaceMVK )
vkGetInstanceProcAddr ( instance , "vkCreateMacOSSurfaceMVK ") ;
if ( !vkCreateMacOSSurfaceMVK )
{
_glfwInputError ( GLFW_API_UNAVAILABLE ,
"Cocoa : Vulkan instance missing VK_MVK_macos_surface extension ") ;
return VK_ERROR_EXTENSION_NOT_PRESENT ;
}
/ / HACK : Dynamically load Core Animation to avoid adding an extra
/ / dependency for the majority who don ' t use MoltenVK
NSBundle * bundle = [ NSBundle bundleWithPath : @ "/ System / Library / Frameworks / QuartzCore . framework "] ;
if ( !bundle )
{
_glfwInputError ( GLFW_PLATFORM_ERROR ,
"Cocoa : Failed to find QuartzCore . framework ") ;
return VK_ERROR_EXTENSION_NOT_PRESENT ;
}
/ / NOTE : Create the layer here as makeBackingLayer should not return nil
window - > ns . layer = [ [ bundle classNamed : @ "CAMetalLayer "] layer ] ;
if ( !window - > ns . layer )
{
_glfwInputError ( GLFW_PLATFORM_ERROR ,
"Cocoa : Failed to create layer for view ") ;
return VK_ERROR_EXTENSION_NOT_PRESENT ;
}
[ window - > ns . view setWantsLayer : YES ] ;
memset ( & sci , 0 , sizeof ( sci ) ) ;
sci . sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK ;
sci . pView = window - > ns . view ;
err = vkCreateMacOSSurfaceMVK ( instance , & sci , allocator , surface ) ;
if ( err )
{
_glfwInputError ( GLFW_PLATFORM_ERROR ,
"Cocoa : Failed to create Vulkan surface : %s",
_glfwGetVulkanResultString ( err ) ) ;
}
return err ;
#else
return VK_ERROR_EXTENSION_NOT_PRESENT ;
#endif
}