mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Cocoa: Update MoltenVK support for LunarG SDK
GLFW now checks for the libvulkan.1.dylib loader instead of what is now the ICD. This removes checking for libMoltenVK.dylib to avoid cryptic errors. This unfortunately also breaks compatibility with the standalone MoltenVK SDK. This also removes support for the static loader library as that is not present in the LunarG SDK. Related to #870.
This commit is contained in:
parent
8d98a6e37d
commit
ab3bfb4205
@ -28,12 +28,10 @@ if (WIN32)
|
|||||||
"$ENV{VK_SDK_PATH}/Bin32")
|
"$ENV{VK_SDK_PATH}/Bin32")
|
||||||
endif()
|
endif()
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set(CMAKE_FIND_FRAMEWORK NEVER)
|
find_library(VULKAN_LIBRARY vulkan.1 HINTS
|
||||||
find_library(VULKAN_LIBRARY MoltenVK)
|
"$ENV{VULKAN_SDK}/macOS/lib")
|
||||||
set(CMAKE_FIND_FRAMEWORK ONLY)
|
|
||||||
find_library(VULKAN_STATIC_LIBRARY MoltenVK)
|
|
||||||
find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS
|
find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS
|
||||||
"${VULKAN_LIBRARY}/Headers")
|
"$ENV{VULKAN_SDK}/macOS/include")
|
||||||
else()
|
else()
|
||||||
find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS
|
find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS
|
||||||
"$ENV{VULKAN_SDK}/include")
|
"$ENV{VULKAN_SDK}/include")
|
||||||
|
@ -141,15 +141,6 @@ if (MINGW)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
# Dependencies required by the MoltenVK static library
|
|
||||||
set(GLFW_VULKAN_DEPS
|
|
||||||
"-lc++"
|
|
||||||
"-framework Cocoa"
|
|
||||||
"-framework Metal"
|
|
||||||
"-framework QuartzCore")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Detect and select backend APIs
|
# Detect and select backend APIs
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -180,7 +171,7 @@ endif()
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (GLFW_VULKAN_STATIC)
|
if (GLFW_VULKAN_STATIC)
|
||||||
if (VULKAN_FOUND AND VULKAN_STATIC_LIBRARY)
|
if (VULKAN_FOUND AND VULKAN_STATIC_LIBRARY)
|
||||||
list(APPEND glfw_LIBRARIES "${VULKAN_STATIC_LIBRARY}" ${GLFW_VULKAN_DEPS})
|
list(APPEND glfw_LIBRARIES "${VULKAN_STATIC_LIBRARY}")
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
message(WARNING "Linking Vulkan loader static library into GLFW")
|
message(WARNING "Linking Vulkan loader static library into GLFW")
|
||||||
endif()
|
endif()
|
||||||
|
@ -106,9 +106,9 @@ located in the `deps/` directory.
|
|||||||
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
||||||
- [Vulkan headers](https://www.khronos.org/registry/vulkan/) for Vulkan tests
|
- [Vulkan headers](https://www.khronos.org/registry/vulkan/) for Vulkan tests
|
||||||
|
|
||||||
The Vulkan example additionally requires the Vulkan SDK to be installed, or it
|
The Vulkan example additionally requires the LunarG Vulkan SDK to be installed,
|
||||||
will not be included in the build. On macOS you need to provide the path to the
|
or it will not be included in the build. On macOS you need to provide the path
|
||||||
MoltenVK SDK manually as it has no standard installation location.
|
to the SDK manually as it has no standard installation location.
|
||||||
|
|
||||||
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
||||||
find that tool.
|
find that tool.
|
||||||
|
@ -132,7 +132,7 @@ mode on platforms where this is available, specifically Windows and X11.
|
|||||||
@subsection news_33_moltenvk Support for Vulkan on macOS via MoltenVK
|
@subsection news_33_moltenvk Support for Vulkan on macOS via MoltenVK
|
||||||
|
|
||||||
GLFW now supports the `VK_MVK_macos_surface` window surface creation extension
|
GLFW now supports the `VK_MVK_macos_surface` window surface creation extension
|
||||||
provided by [MoltenVK](https://moltengl.com/moltenvk/).
|
provided by MoltenVK in the [LunarG Vulkan SDK](https://vulkan.lunarg.com/).
|
||||||
|
|
||||||
@see @ref vulkan_guide
|
@see @ref vulkan_guide
|
||||||
|
|
||||||
|
@ -10,21 +10,14 @@ documentation and is not a replacement for either. It assumes some familiarity
|
|||||||
with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to
|
with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to
|
||||||
the Vulkan documentation to explain the details of Vulkan functions.
|
the Vulkan documentation to explain the details of Vulkan functions.
|
||||||
|
|
||||||
To develop for Vulkan you should install an SDK for your platform, for example
|
To develop for Vulkan you should download the [LunarG Vulkan
|
||||||
the [LunarG Vulkan SDK](https://vulkan.lunarg.com/) for Windows and Linux or
|
SDK](https://vulkan.lunarg.com/) for your platform. Apart from headers and link
|
||||||
[MoltenVK](https://moltengl.com/moltenvk/) for macOS. Apart from headers and
|
libraries, they also provide the validation layers necessary for development.
|
||||||
link libraries, they should also provide the validation layers necessary for
|
|
||||||
development.
|
|
||||||
|
|
||||||
The GLFW library does not need the Vulkan SDK to enable support for Vulkan.
|
The GLFW library does not need the Vulkan SDK to enable support for Vulkan.
|
||||||
However, any Vulkan-specific test and example programs are built only if the
|
However, any Vulkan-specific test and example programs are built only if the
|
||||||
CMake files find a Vulkan SDK.
|
CMake files find a Vulkan SDK.
|
||||||
|
|
||||||
@macos Because MoltenVK is typically not installed system-wide, you will need to
|
|
||||||
point CMake to it using the `CMAKE_FRAMEWORK_PATH` variable when configuring the
|
|
||||||
GLFW source tree. Set this variable to the `MoltenVK/macOS` subdirectory of the
|
|
||||||
SDK, either on the command-line or in the CMake GUI.
|
|
||||||
|
|
||||||
For details on a specific function in this category, see the @ref vulkan. There
|
For details on a specific function in this category, see the @ref vulkan. There
|
||||||
are also guides for the other areas of the GLFW API.
|
are also guides for the other areas of the GLFW API.
|
||||||
|
|
||||||
@ -39,7 +32,7 @@ are also guides for the other areas of the GLFW API.
|
|||||||
|
|
||||||
By default, GLFW will look for the Vulkan loader on demand at runtime via its
|
By default, GLFW will look for the Vulkan loader on demand at runtime via its
|
||||||
standard name (`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other
|
standard name (`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other
|
||||||
Unix-like systems and `libMoltenVK.dylib` on macOS). This means that GLFW does
|
Unix-like systems and `libvulkan.1.dylib` on macOS). This means that GLFW does
|
||||||
not need to be linked against the loader. However, it also means that if you
|
not need to be linked against the loader. However, it also means that if you
|
||||||
are using the static library form of the Vulkan loader GLFW will either fail to
|
are using the static library form of the Vulkan loader GLFW will either fail to
|
||||||
find it or (worse) use the wrong one.
|
find it or (worse) use the wrong one.
|
||||||
@ -48,9 +41,14 @@ The @ref GLFW_VULKAN_STATIC CMake option makes GLFW link directly against the
|
|||||||
static library form. Not linking against the Vulkan loader will then be
|
static library form. Not linking against the Vulkan loader will then be
|
||||||
a compile-time error.
|
a compile-time error.
|
||||||
|
|
||||||
@macos When using the static library form of MoltenVK (i.e. `MetalVK.framework`
|
@macos Because the Vulkan loader and ICD are not installed globally on macOS,
|
||||||
and not `libMoltenVK.dylib`) you must also link against its dependencies: the
|
you need to set up the application bundle according to the LunarG SDK
|
||||||
`Cocoa`, `Metal` and `QuartzCore` system frameworks and the `libc++` library.
|
documentation. To help the GLFW CMake files find the SDK, you can set the
|
||||||
|
`VULKAN_SDK` environment variable.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
env VULKAN_SDK=/example/path/to/vulkansdk-macos cmake .
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@section vulkan_include Including the Vulkan and GLFW header files
|
@section vulkan_include Including the Vulkan and GLFW header files
|
||||||
@ -164,9 +162,9 @@ If it fails it will return `NULL` and GLFW will not be able to create Vulkan
|
|||||||
window surfaces. You can still use Vulkan for off-screen rendering and compute
|
window surfaces. You can still use Vulkan for off-screen rendering and compute
|
||||||
work.
|
work.
|
||||||
|
|
||||||
The returned array will always contain `VK_KHR_surface`, so if you don't
|
If successful the returned array will always include `VK_KHR_surface`, so if
|
||||||
require any additional extensions you can pass this list directly to the
|
you don't require any additional extensions you can pass this list directly to
|
||||||
`VkInstanceCreateInfo` struct.
|
the `VkInstanceCreateInfo` struct.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
VkInstanceCreateInfo ici;
|
VkInstanceCreateInfo ici;
|
||||||
|
@ -54,7 +54,7 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
#elif defined(_GLFW_WIN32)
|
#elif defined(_GLFW_WIN32)
|
||||||
_glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
|
_glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
|
||||||
#elif defined(_GLFW_COCOA)
|
#elif defined(_GLFW_COCOA)
|
||||||
_glfw.vk.handle = _glfw_dlopen("libMoltenVK.dylib");
|
_glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
|
||||||
#else
|
#else
|
||||||
_glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
|
_glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,7 +55,7 @@ if (VULKAN_FOUND)
|
|||||||
add_executable(vulkan WIN32 vulkan.c ${ICON})
|
add_executable(vulkan WIN32 vulkan.c ${ICON})
|
||||||
target_include_directories(vulkan PRIVATE "${VULKAN_INCLUDE_DIR}")
|
target_include_directories(vulkan PRIVATE "${VULKAN_INCLUDE_DIR}")
|
||||||
if (GLFW_VULKAN_STATIC)
|
if (GLFW_VULKAN_STATIC)
|
||||||
target_link_libraries(vulkan "${VULKAN_STATIC_LIBRARY}" ${GLFW_VULKAN_DEPS})
|
target_link_libraries(vulkan "${VULKAN_STATIC_LIBRARY}")
|
||||||
else()
|
else()
|
||||||
target_link_libraries(vulkan "${VULKAN_LIBRARY}")
|
target_link_libraries(vulkan "${VULKAN_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user