use older macOS surface

This commit is contained in:
lizzie 2025-11-27 01:37:58 +00:00
parent 61b131ed4e
commit c3be6fea9f
2 changed files with 14 additions and 10 deletions

View file

@ -10,7 +10,8 @@
#ifdef _WIN32
#define VK_USE_PLATFORM_WIN32_KHR
#elif defined(__APPLE__)
#define VK_USE_PLATFORM_METAL_EXT
//#define VK_USE_PLATFORM_METAL_EXT
#define VK_USE_PLATFORM_MACOS_MVK
#elif defined(__ANDROID__)
#define VK_USE_PLATFORM_ANDROID_KHR
#elif defined(__HAIKU__)
@ -32,6 +33,9 @@
#ifndef VK_KHR_MAINTENANCE_9_EXTENSION_NAME
#define VK_KHR_MAINTENANCE_9_EXTENSION_NAME "VK_KHR_maintenance9"
#endif
#ifndef VK_EXT_METAL_SURFACE_EXTENSION_NAME
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
#endif
#ifndef VK_MVK_MACOS_SURFACE_EXTENSION_NAME
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
#endif

View file

@ -32,14 +32,14 @@ vk::SurfaceKHR CreateSurface(
}
#elif defined(__APPLE__)
if (window_info.type == Core::Frontend::WindowSystemType::Cocoa) {
const VkMetalSurfaceCreateInfoEXT metal_ci = {
.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT,
.pNext = nullptr,
.flags = 0,
.pLayer = static_cast<const CAMetalLayer*>(window_info.render_surface),
};
const auto vkCreateMetalSurfaceEXT = reinterpret_cast<PFN_vkCreateMetalSurfaceEXT>(dld.vkGetInstanceProcAddr(*instance, "vkCreateMetalSurfaceEXT"));
if (!vkCreateMetalSurfaceEXT || vkCreateMetalSurfaceEXT(*instance, &metal_ci, nullptr, &unsafe_surface) != VK_SUCCESS) {
// const VkMetalSurfaceCreateInfoEXT metal_ci = {
// .sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT,
// .pNext = nullptr,
// .flags = 0,
// .pLayer = static_cast<const CAMetalLayer*>(window_info.render_surface),
// };
// const auto vkCreateMetalSurfaceEXT = reinterpret_cast<PFN_vkCreateMetalSurfaceEXT>(dld.vkGetInstanceProcAddr(*instance, "vkCreateMetalSurfaceEXT"));
// if (!vkCreateMetalSurfaceEXT || vkCreateMetalSurfaceEXT(*instance, &metal_ci, nullptr, &unsafe_surface) != VK_SUCCESS) {
// TODO: Way to fallback? - where's my vulkan headers
// Attempt to make a macOS surface instead then...
// This is the deprecated VkMacOSSurfaceCreateInfoMVK(3) version; but should work if the above failed
@ -56,7 +56,7 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
LOG_ERROR(Render_Vulkan, "Failed to initialize Metal/macOS surface");
}
// }
}
#elif defined(__ANDROID__)
if (window_info.type == Core::Frontend::WindowSystemType::Android) {