mirror of
https://github.com/glfw/glfw.git
synced 2026-02-17 21:12:34 +01:00
Cocoa: Add basic support for Vulkan via MoltenVK
This adds basic support for MoltenVK, a Vulkan implementation on top of Metal, on macOS 10.11 and later. It looks for MoltenVK in the process via RTLD_DEFAULT symbol lookup if _GLFW_VULKAN_STATIC is disabled. glfwCreateWindowSurface now creates and sets a CAMetalLayer for the window content view, which is required for MoltenVK to function. You must help CMake find MoltenVK for the Vulkan test to be built. Fixes #870.
This commit is contained in:
@@ -176,7 +176,11 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
#if defined(GLFW_INCLUDE_VULKAN)
|
||||
#include <vulkan/vulkan.h>
|
||||
#if defined(__APPLE__)
|
||||
#include <MoltenVK/vulkan/vulkan.h>
|
||||
#else
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
|
||||
@@ -4225,6 +4229,9 @@ GLFWAPI int glfwVulkanSupported(void);
|
||||
* returned array, as it is an error to specify an extension more than once in
|
||||
* the `VkInstanceCreateInfo` struct.
|
||||
*
|
||||
* @remark @macos This function currently only supports the
|
||||
* `VK_MVK_macos_surface` extension from MoltenVK.
|
||||
*
|
||||
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is guaranteed to be valid only until the
|
||||
* library is terminated.
|
||||
@@ -4305,6 +4312,10 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
|
||||
* `VK_MVK_macos_surface` extension does not provide
|
||||
* a `vkGetPhysicalDevice*PresentationSupport` type function.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. For
|
||||
* synchronization details of Vulkan objects, see the Vulkan specification.
|
||||
*
|
||||
@@ -4354,6 +4365,12 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
||||
* @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
|
||||
* eliminate almost all occurrences of these errors.
|
||||
*
|
||||
* @remark @macos This function currently only supports the
|
||||
* `VK_MVK_macos_surface` extension from MoltenVK.
|
||||
*
|
||||
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
||||
* the window content view, which is required for MoltenVK to function.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. For
|
||||
* synchronization details of Vulkan objects, see the Vulkan specification.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user