Signed-off-by: Chip Davis cdavis@codeweavers.com ---
Notes: Try 2: Drop support for the demos; they require Objective-C. Check for MoltenVK instead of if we're building for Mac. Check for the name of the library to load in configure.
Try 3: Allow for the possibility of supporting either MoltenVK or XCB. Check the soname of libvulkan in a previous change.
configure.ac | 11 ++++++++++- libs/vkd3d-utils/vkd3d_utils_main.c | 4 ++++ libs/vkd3d-utils/vkd3d_utils_private.h | 8 ++++++++ libs/vkd3d/device.c | 2 +- tests/vkd3d_api.c | 18 ++++++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index 6eb8a76..36f248a 100644 --- a/configure.ac +++ b/configure.ac @@ -77,7 +77,10 @@ AC_CHECK_LIB([pthread], [pthread_create], AC_SUBST([VULKAN_LIBS]) VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr], [VULKAN_LIBS="-lvulkan"], - [AC_MSG_ERROR([libvulkan not found.])]) + [VKD3D_CHECK_SONAME([MoltenVK], [vkGetInstanceProcAddr], + [VULKAN_LIBS="-lMoltenVK" + AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN],["$ac_cv_lib_soname_MoltenVK"])], + [AC_MSG_ERROR([libvulkan and libMoltenVK not found.])])])
HAVE_SPIRV_TOOLS=no AS_IF([test "x$with_spirv_tools" = "xyes"], @@ -89,6 +92,12 @@ PKG_CHECK_MODULES([XCB], [xcb xcb-keysyms], [AC_DEFINE([HAVE_XCB], [1], [Define to 1 if you have libxcb.]) HAVE_XCB=yes])
+AC_CHECK_HEADERS(MoltenVK/vk_mvk_moltenvk.h) +AS_CASE(["$host_os"], + [darwin*|macosx*], + [AS_IF([test "x$ac_cv_header_MoltenVK_vk_mvk_moltenvk_h" = "xno"], + [AC_MSG_ERROR([MoltenVK is required to use vkd3d on Mac OS.])])]) + AS_IF([test "x$HAVE_XCB" = xyes], [enable_demos_default=yes], [enable_demos_default=no]) diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index 2c4d89a..1504f20 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -34,7 +34,11 @@ HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, static const char * const instance_extensions[] = { VK_KHR_SURFACE_EXTENSION_NAME, +#ifdef HAVE_MOLTENVK_VK_MVK_MOLTENVK_H + VK_MVK_MACOS_SURFACE_EXTENSION_NAME, +#elif defined(HAVE_XCB) VK_KHR_XCB_SURFACE_EXTENSION_NAME, +#endif }; static const char * const device_extensions[] = { diff --git a/libs/vkd3d-utils/vkd3d_utils_private.h b/libs/vkd3d-utils/vkd3d_utils_private.h index 6aa0df6..9f610b4 100644 --- a/libs/vkd3d-utils/vkd3d_utils_private.h +++ b/libs/vkd3d-utils/vkd3d_utils_private.h @@ -20,7 +20,15 @@ #define __VKD3D_UTILS_PRIVATE_H
#define VK_NO_PROTOTYPES + +#include "config.h" + +#ifdef HAVE_MOLTENVK_VK_MVK_MOLTENVK_H +#define VK_USE_PLATFORM_MACOS_MVK +#endif +#ifdef HAVE_XCB #define VK_USE_PLATFORM_XCB_KHR +#endif
#include <pthread.h> #include <vkd3d.h> diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 047c298..4e5a9b0 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -214,7 +214,7 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance, { if (!(instance->libvulkan = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) { - ERR("Failed to load libvulkan.\n"); + ERR("Failed to load libvulkan: %s\n", dlerror()); return E_FAIL; }
diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c index e2d9d01..be27d9d 100644 --- a/tests/vkd3d_api.c +++ b/tests/vkd3d_api.c @@ -19,8 +19,12 @@ #define COBJMACROS #define INITGUID #define WIDL_C_INLINE_WRAPPERS +#ifdef HAVE_MOLTENVK_VK_MVK_MOLTENVK_H +#define VK_USE_PLATFORM_MACOS_MVK +#else #define VK_USE_PLATFORM_XCB_KHR #define VK_USE_PLATFORM_XLIB_KHR +#endif #include "vkd3d_test.h" #include <vkd3d.h>
@@ -215,8 +219,13 @@ static void test_additional_instance_extensions(void) struct vulkan_extension extensions[] = { {VK_KHR_SURFACE_EXTENSION_NAME}, +#ifdef HAVE_MOLTENVK_VK_MVK_MOLTENVK_H + {VK_MVK_MACOS_SURFACE_EXTENSION_NAME}, +#endif +#ifdef HAVE_XCB {VK_KHR_XCB_SURFACE_EXTENSION_NAME}, {VK_KHR_XLIB_SURFACE_EXTENSION_NAME}, +#endif };
const char *enabled_extensions[ARRAY_SIZE(extensions)]; @@ -249,6 +258,14 @@ static void test_additional_instance_extensions(void) if (!extensions[i].is_supported) continue;
+#ifdef HAVE_MOLTENVK_VK_MVK_MOLTENVK_H + if (!strcmp(extensions[i].name, VK_MVK_MACOS_SURFACE_EXTENSION_NAME)) + { + pfn = vkGetInstanceProcAddr(vk_instance, "vkCreateMacOSSurfaceMVK"); + ok(pfn, "Failed to get proc addr for vkCreateMacOSSurfaceMVK.\n"); + } +#endif +#ifdef HAVE_XCB if (!strcmp(extensions[i].name, VK_KHR_XCB_SURFACE_EXTENSION_NAME)) { pfn = vkGetInstanceProcAddr(vk_instance, "vkCreateXcbSurfaceKHR"); @@ -259,6 +276,7 @@ static void test_additional_instance_extensions(void) pfn = vkGetInstanceProcAddr(vk_instance, "vkCreateXlibSurfaceKHR"); ok(pfn, "Failed to get proc addr for vkCreateXlibSurfaceKHR.\n"); } +#endif }
refcount = vkd3d_instance_decref(instance);