Browse Source

use older macOS surface

liz-dynarmic-macos-fbsd-port
lizzie 2 months ago
parent
commit
5766921c9a
  1. 6
      src/video_core/vulkan_common/vulkan.h
  2. 18
      src/video_core/vulkan_common/vulkan_surface.cpp

6
src/video_core/vulkan_common/vulkan.h

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

18
src/video_core/vulkan_common/vulkan_surface.cpp

@ -32,14 +32,14 @@ vk::SurfaceKHR CreateSurface(
} }
#elif defined(__APPLE__) #elif defined(__APPLE__)
if (window_info.type == Core::Frontend::WindowSystemType::Cocoa) { 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 // TODO: Way to fallback? - where's my vulkan headers
// Attempt to make a macOS surface instead then... // Attempt to make a macOS surface instead then...
// This is the deprecated VkMacOSSurfaceCreateInfoMVK(3) version; but should work if the above failed // 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); throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
} }
LOG_ERROR(Render_Vulkan, "Failed to initialize Metal/macOS surface"); LOG_ERROR(Render_Vulkan, "Failed to initialize Metal/macOS surface");
}
// }
} }
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
if (window_info.type == Core::Frontend::WindowSystemType::Android) { if (window_info.type == Core::Frontend::WindowSystemType::Android) {

Loading…
Cancel
Save