From 32ac90d8c2c54f15fc0df99f3f564a655274bd25 Mon Sep 17 00:00:00 2001 From: "duncan.hopkins" Date: Fri, 1 Dec 2023 11:02:17 +0000 Subject: [PATCH] zink: Fixed header location and compiling issue with [[deprecated]] from newer MoltenVK versions. From Vulkan 1.3.250 the MoltenVK include filenames changed. Now include the newer 'MoltenVK/mvk_vulkan.h' instead of the older `MoltenVK/vk_mvk_moltenvk.h` headers. From Vulkan 1.3.275 the MoltenVK include location changed. The meson build options 'moltenvk-dir' now needs to point at the root of the Vulkan SDK install. It will look for the presence of the older 'MoltenVK/include' loction and the newer 'macos/include' location. Tested against Vulkan SDK versions: 1.3.250, 1.3.261, 1.3.268, 1.3.275. Will not work compile with Vulkan 1.3.234 or earlier. Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/meson.build | 10 +++++++++- src/gallium/drivers/zink/zink_instance.py | 7 ++++--- src/gallium/drivers/zink/zink_resource.c | 7 ++++--- src/gallium/drivers/zink/zink_screen.c | 10 +++++++--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/zink/meson.build b/src/gallium/drivers/zink/meson.build index 831ccaae88c..8b66bbe08e0 100644 --- a/src/gallium/drivers/zink/meson.build +++ b/src/gallium/drivers/zink/meson.build @@ -81,7 +81,15 @@ if host_machine.system() == 'darwin' # MoltenVK options if with_moltenvk_dir != '' - inc_zink_vk += include_directories(join_paths(with_moltenvk_dir, 'include')) + fs = import('fs') + moltenvk_includes = join_paths(with_moltenvk_dir, 'MoltenVK', 'include') + if not fs.is_dir(moltenvk_includes) + moltenvk_includes = join_paths(with_moltenvk_dir, 'macos', 'include') + if not fs.is_dir(moltenvk_includes) + error(f'moltenvk includes cannot be found in moltenvk-dir="@with_moltenvk_dir@"') + endif + endif + inc_zink_vk += include_directories(moltenvk_includes) else error('moltenvk-dir is required but not set.') endif diff --git a/src/gallium/drivers/zink/zink_instance.py b/src/gallium/drivers/zink/zink_instance.py index 0fbd14e5a58..6b657931bf7 100644 --- a/src/gallium/drivers/zink/zink_instance.py +++ b/src/gallium/drivers/zink/zink_instance.py @@ -72,10 +72,11 @@ header_code = """ #include -#if defined(__APPLE__) +#ifdef __APPLE__ +#include "MoltenVK/mvk_vulkan.h" // Source of MVK_VERSION -#include "MoltenVK/vk_mvk_moltenvk.h" -#endif +#include "MoltenVK/mvk_config.h" +#endif /* __APPLE__ */ struct pipe_screen; struct zink_screen; diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 293a653fef4..dbe7bf76c70 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -59,10 +59,11 @@ #define DRM_FORMAT_MOD_LINEAR 0 #endif -#if defined(__APPLE__) +#ifdef __APPLE__ +#include "MoltenVK/mvk_vulkan.h" // Source of MVK_VERSION -#include "MoltenVK/vk_mvk_moltenvk.h" -#endif +#include "MoltenVK/mvk_config.h" +#endif /* __APPLE__ */ #define ZINK_EXTERNAL_MEMORY_HANDLE 999 diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 495c835d1c2..5ccd5647b48 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -80,10 +80,14 @@ bool zink_tracing = false; #endif #endif -#if defined(__APPLE__) +#ifdef __APPLE__ +#include "MoltenVK/mvk_vulkan.h" // Source of MVK_VERSION -#include "MoltenVK/vk_mvk_moltenvk.h" -#endif +#include "MoltenVK/mvk_config.h" +#define VK_NO_PROTOTYPES +#include "MoltenVK/mvk_deprecated_api.h" +#include "MoltenVK/mvk_private_api.h" +#endif /* __APPLE__ */ #ifdef HAVE_LIBDRM #include "drm-uapi/dma-buf.h"